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 increment operator. | 4 // Dart test program for testing increment operator. |
5 | 5 |
6 class A { | 6 class A { |
7 static var yy; | 7 static var yy; |
8 static set y(v) { | 8 static set y(v) { |
9 yy = v; | 9 yy = v; |
10 } | 10 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Expect.equals(57, A.y); | 53 Expect.equals(57, A.y); |
54 Expect.equals(56, --A.y); | 54 Expect.equals(56, --A.y); |
55 | 55 |
56 IncrOpTest.y = 55; | 56 IncrOpTest.y = 55; |
57 Expect.equals(55, IncrOpTest.y++); | 57 Expect.equals(55, IncrOpTest.y++); |
58 Expect.equals(56, IncrOpTest.y); | 58 Expect.equals(56, IncrOpTest.y); |
59 Expect.equals(57, ++IncrOpTest.y); | 59 Expect.equals(57, ++IncrOpTest.y); |
60 Expect.equals(57, IncrOpTest.y); | 60 Expect.equals(57, IncrOpTest.y); |
61 Expect.equals(56, --IncrOpTest.y); | 61 Expect.equals(56, --IncrOpTest.y); |
62 | 62 |
63 var list = new List.fixedLength(4); | 63 var list = new List(4); |
64 for (int i = 0; i < list.length; i++) { | 64 for (int i = 0; i < list.length; i++) { |
65 list[i] = i; | 65 list[i] = i; |
66 } | 66 } |
67 for (int i = 0; i < list.length; i++) { | 67 for (int i = 0; i < list.length; i++) { |
68 list[i]++; | 68 list[i]++; |
69 } | 69 } |
70 for (int i = 0; i < list.length; i++) { | 70 for (int i = 0; i < list.length; i++) { |
71 Expect.equals(i + 1, list[i]); | 71 Expect.equals(i + 1, list[i]); |
72 ++list[i]; | 72 ++list[i]; |
73 } | 73 } |
74 Expect.equals(1 + 2, list[1]); | 74 Expect.equals(1 + 2, list[1]); |
75 Expect.equals(1 + 2, list[1]--); | 75 Expect.equals(1 + 2, list[1]--); |
76 Expect.equals(1 + 1, list[1]); | 76 Expect.equals(1 + 1, list[1]); |
77 Expect.equals(1 + 0, --list[1]); | 77 Expect.equals(1 + 0, --list[1]); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 main() { | 81 main() { |
82 IncrOpTest.testMain(); | 82 IncrOpTest.testMain(); |
83 } | 83 } |
OLD | NEW |