OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Dart test program for testing assign operators. | 4 // Dart test program for testing assign operators. |
5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation | 5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 | |
10 class AssignOpTest { | 9 class AssignOpTest { |
11 AssignOpTest() {} | 10 AssignOpTest() {} |
12 | 11 |
13 static testMain() { | 12 static testMain() { |
14 var b = 0; | 13 var b = 0; |
15 b += 1; | 14 b += 1; |
16 Expect.equals(1, b); | 15 Expect.equals(1, b); |
17 b *= 5; | 16 b *= 5; |
18 Expect.equals(5, b); | 17 Expect.equals(5, b); |
19 b -= 1; | 18 b -= 1; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 o.instf /= 4; | 57 o.instf /= 4; |
59 Expect.equals(.5, o.instf); | 58 Expect.equals(.5, o.instf); |
60 | 59 |
61 var x = 0xFF; | 60 var x = 0xFF; |
62 x >>= 3; | 61 x >>= 3; |
63 Expect.equals(0x1F, x); | 62 Expect.equals(0x1F, x); |
64 x <<= 3; | 63 x <<= 3; |
65 Expect.equals(0xF8, x); | 64 Expect.equals(0xF8, x); |
66 x |= 0xF00; | 65 x |= 0xF00; |
67 Expect.equals(0xFF8, x); | 66 Expect.equals(0xFF8, x); |
68 x &=0xF0; | 67 x &= 0xF0; |
69 Expect.equals(0xF0, x); | 68 Expect.equals(0xF0, x); |
70 x ^=0x11; | 69 x ^= 0x11; |
71 Expect.equals(0xE1, x); | 70 Expect.equals(0xE1, x); |
72 | 71 |
73 var y = 100; | 72 var y = 100; |
74 y += 1 << 3; | 73 y += 1 << 3; |
75 Expect.equals(108, y); | 74 Expect.equals(108, y); |
76 y *= 2 + 1; | 75 y *= 2 + 1; |
77 Expect.equals(324, y); | 76 Expect.equals(324, y); |
78 y -= 3 - 2; | 77 y -= 3 - 2; |
79 Expect.equals(323, y); | 78 Expect.equals(323, y); |
80 y += 3 * 4; | 79 y += 3 * 4; |
81 Expect.equals(335, y); | 80 Expect.equals(335, y); |
82 | 81 |
83 var a = [1, 2, 3]; | 82 var a = [1, 2, 3]; |
84 var ix = 0; | 83 var ix = 0; |
85 a[ix] |= 12; | 84 a[ix] |= 12; |
86 Expect.equals(13, a[ix]); | 85 Expect.equals(13, a[ix]); |
87 } | 86 } |
88 | 87 |
89 static var f; | 88 static var f; |
90 var instf; | 89 var instf; |
91 } | 90 } |
| 91 |
92 main() { | 92 main() { |
93 for (int i = 0; i < 20; i++) { | 93 for (int i = 0; i < 20; i++) { |
94 AssignOpTest.testMain(); | 94 AssignOpTest.testMain(); |
95 } | 95 } |
96 } | 96 } |
OLD | NEW |