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

Side by Side Diff: tests/language/src/IncrOpTest.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, 8 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
« no previous file with comments | « tests/language/src/ImportCoreNoPrefixTest.dart ('k') | tests/language/src/IndexTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 increment operator.
5
6 class A {
7 static var yy;
8 static set y(v) {
9 yy = v;
10 }
11
12 static get y() {
13 return yy;
14 }
15 }
16
17 class IncrOpTest {
18 var x;
19 static var y;
20
21 IncrOpTest() {}
22
23 static testMain() {
24 var a = 3;
25 var c = a++ + 1;
26 Expect.equals(4, c);
27 Expect.equals(4, a);
28 c = a-- + 1;
29 Expect.equals(5, c);
30 Expect.equals(3, a);
31
32 c = --a + 1;
33 Expect.equals(3, c);
34 Expect.equals(2, a);
35
36 c = 2 + ++a;
37 Expect.equals(5, c);
38 Expect.equals(3, a);
39
40 var obj = new IncrOpTest();
41 obj.x = 100;
42 Expect.equals(100, obj.x);
43 obj.x++;
44 Expect.equals(101, obj.x);
45 Expect.equals(102, ++obj.x);
46 Expect.equals(102, obj.x++);
47 Expect.equals(103, obj.x);
48
49 A.y = 55;
50 Expect.equals(55, A.y++);
51 Expect.equals(56, A.y);
52 Expect.equals(57, ++A.y);
53 Expect.equals(57, A.y);
54 Expect.equals(56, --A.y);
55
56 IncrOpTest.y = 55;
57 Expect.equals(55, IncrOpTest.y++);
58 Expect.equals(56, IncrOpTest.y);
59 Expect.equals(57, ++IncrOpTest.y);
60 Expect.equals(57, IncrOpTest.y);
61 Expect.equals(56, --IncrOpTest.y);
62
63 var list = new List(4);
64 for (int i = 0; i < list.length; i++) {
65 list[i] = i;
66 }
67 for (int i = 0; i < list.length; i++) {
68 list[i]++;
69 }
70 for (int i = 0; i < list.length; i++) {
71 Expect.equals(i + 1, list[i]);
72 ++list[i];
73 }
74 Expect.equals(1 + 2, list[1]);
75 Expect.equals(1 + 2, list[1]--);
76 Expect.equals(1 + 1, list[1]);
77 Expect.equals(1 + 0, --list[1]);
78 }
79 }
80
81 main() {
82 IncrOpTest.testMain();
83 }
OLDNEW
« no previous file with comments | « tests/language/src/ImportCoreNoPrefixTest.dart ('k') | tests/language/src/IndexTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698