Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: tests/language/src/OperatorTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class OperatorTest {
6 static int i1, i2;
7
8 OperatorTest() {}
9
10 static testMain() {
11 var op1 = new Operator(1);
12 var op2 = new Operator(2);
13 Expect.equals(3, op1 + op2);
14 Expect.equals(-1, op1 - op2);
15 Expect.equals(0.5, op1 / op2);
16 Expect.equals(0, op1 ~/ op2);
17 Expect.equals(2, op1 * op2);
18 Expect.equals(1, op1 % op2);
19 Expect.equals(true, !(op1 == op2));
20 Expect.equals(true, op1 < op2);
21 Expect.equals(true, !(op1 > op2));
22 Expect.equals(true, op1 <= op2);
23 Expect.equals(true, !(op1 >= op2));
24 Expect.equals(3, (op1 | op2));
25 Expect.equals(3, (op1 ^ op2));
26 Expect.equals(0, (op1 & op2));
27 Expect.equals(4, (op1 << op2));
28 Expect.equals(0, (op1 >> op2));
29 Expect.equals(~1, ~op1);
30 Expect.equals(-1, -op1);
31
32 op1.value += op2.value;
33 Expect.equals(3, op1.value);
34
35 op2.value += (op2.value += op2.value);
36 Expect.equals(6, op2.value);
37
38 op2.value -= (op2.value -= op2.value);
39 Expect.equals(6, op2.value);
40
41 op1.value = op2.value = 42;
42 Expect.equals(42, op1.value);
43 Expect.equals(42, op2.value);
44
45 i1 = i2 = 42;
46 Expect.equals(42, i1);
47 Expect.equals(42, i2);
48 i1 += 7;
49 Expect.equals(49, i1);
50 i1 += (i2 = 17);
51 Expect.equals(66, i1);
52 Expect.equals(17, i2);
53
54 i1 += i2 += 3;
55 Expect.equals(86, i1);
56 Expect.equals(20, i2);
57 }
58 }
59
60 class Operator {
61 int value;
62
63 Operator(int i) {
64 value = i;
65 }
66
67 operator +(Operator other) {
68 return value + other.value;
69 }
70
71 operator -(Operator other) {
72 return value - other.value;
73 }
74
75 operator /(Operator other) {
76 return value / other.value;
77 }
78
79 operator *(Operator other) {
80 return value * other.value;
81 }
82
83 operator %(Operator other) {
84 return value % other.value;
85 }
86
87 operator ==(Operator other) {
88 return value == other.value;
89 }
90
91 operator <(Operator other) {
92 return value < other.value;
93 }
94
95 operator >(Operator other) {
96 return value > other.value;
97 }
98
99 operator <=(Operator other) {
100 return value <= other.value;
101 }
102
103 operator >=(Operator other) {
104 return value >= other.value;
105 }
106
107 operator |(Operator other) {
108 return value | other.value;
109 }
110
111 operator ^(Operator other) {
112 return value ^ other.value;
113 }
114
115 operator &(Operator other) {
116 return value & other.value;
117 }
118
119 operator <<(Operator other) {
120 return value << other.value;
121 }
122
123 operator >>(Operator other) {
124 return value >> other.value;
125 }
126
127 operator ~/(Operator other) {
128 return value ~/ other.value;
129 }
130
131 operator ~() {
132 return ~value;
133 }
134
135 operator negate() {
136 return -value;
137 }
138 }
139
140 main() {
141 OperatorTest.testMain();
142 }
OLDNEW
« no previous file with comments | « tests/language/src/OperatorIndexEvaluationOrderTest.dart ('k') | tests/language/src/OptimizationTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698