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

Side by Side Diff: tests/language/src/AssignOpTest.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 // Dart test program for testing assign operators.
5
6
7 class AssignOpTest {
8 AssignOpTest() {}
9
10 static testMain() {
11 var b = 0;
12 b += 1;
13 Expect.equals(1, b);
14 b *= 5;
15 Expect.equals(5, b);
16 b -= 1;
17 Expect.equals(4, b);
18 b ~/= 2;
19 Expect.equals(2, b);
20
21 f = 0;
22 f += 1;
23 Expect.equals(1, f);
24 f *= 5;
25 Expect.equals(5, f);
26 f -= 1;
27 Expect.equals(4, f);
28 f ~/= 2;
29 Expect.equals(2, f);
30 f /= 4;
31 Expect.equals(.5, f);
32
33 AssignOpTest.f = 0;
34 AssignOpTest.f += 1;
35 Expect.equals(1, AssignOpTest.f);
36 AssignOpTest.f *= 5;
37 Expect.equals(5, AssignOpTest.f);
38 AssignOpTest.f -= 1;
39 Expect.equals(4, AssignOpTest.f);
40 AssignOpTest.f ~/= 2;
41 Expect.equals(2, AssignOpTest.f);
42 AssignOpTest.f /= 4;
43 Expect.equals(.5, f);
44
45 var o = new AssignOpTest();
46 o.instf = 0;
47 o.instf += 1;
48 Expect.equals(1, o.instf);
49 o.instf *= 5;
50 Expect.equals(5, o.instf);
51 o.instf -= 1;
52 Expect.equals(4, o.instf);
53 o.instf ~/= 2;
54 Expect.equals(2, o.instf);
55 o.instf /= 4;
56 Expect.equals(.5, o.instf);
57
58 var x = 0xFF;
59 x >>= 3;
60 Expect.equals(0x1F, x);
61 x <<= 3;
62 Expect.equals(0xF8, x);
63 x |= 0xF00;
64 Expect.equals(0xFF8, x);
65 x &=0xF0;
66 Expect.equals(0xF0, x);
67 x ^=0x11;
68 Expect.equals(0xE1, x);
69
70 var y = 100;
71 y += 1 << 3;
72 Expect.equals(108, y);
73 y *= 2 + 1;
74 Expect.equals(324, y);
75 y -= 3 - 2;
76 Expect.equals(323, y);
77 y += 3 * 4;
78 Expect.equals(335, y);
79
80 var a = [1, 2, 3];
81 var ix = 0;
82 a[ix] |= 12;
83 Expect.equals(13, a[ix]);
84 }
85
86 static var f;
87 var instf;
88 }
89 main() {
90 for (int i = 0; i < 2000; i++) {
91 AssignOpTest.testMain();
92 }
93 }
OLDNEW
« no previous file with comments | « tests/language/src/AssignInstanceMethodNegativeTest.dart ('k') | tests/language/src/AssignStaticTypeTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698