OLD | NEW |
| (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 int zero() { return 0; } | |
6 int one() { return 1; } | |
7 int minus1() { return 0 - 1; } | |
8 int two() { return 2; } | |
9 int three() { return 3; } | |
10 int five() { return 5; } | |
11 int minus5() { return 0 - 5; } | |
12 int ninetyNine() { return 99; } | |
13 int four99() { return 499; } | |
14 int four99times99() { return 499 * 99; } | |
15 int four99times99plus1() { return 499 * 99 + 1; } | |
16 | |
17 void postPlusPlusTest() { | |
18 var x = zero(); | |
19 var y = x++; | |
20 Expect.equals(0, y); | |
21 Expect.equals(1, x); | |
22 Expect.equals(1, x++); | |
23 Expect.equals(2, x); | |
24 } | |
25 | |
26 void prePlusPlusTest() { | |
27 var x = zero(); | |
28 var y = ++x; | |
29 Expect.equals(1, x); | |
30 Expect.equals(1, y); | |
31 Expect.equals(2, ++x); | |
32 Expect.equals(2, ++y); | |
33 } | |
34 | |
35 void postMinusMinusTest() { | |
36 var x = four99(); | |
37 var y = x--; | |
38 Expect.equals(499, y); | |
39 Expect.equals(498, x); | |
40 Expect.equals(498, x--); | |
41 Expect.equals(497, x); | |
42 } | |
43 | |
44 void preMinusMinusTest() { | |
45 var x = four99(); | |
46 var y = --x; | |
47 Expect.equals(498, y); | |
48 Expect.equals(498, x); | |
49 Expect.equals(497, --x); | |
50 Expect.equals(497, x); | |
51 } | |
52 | |
53 void main() { | |
54 postPlusPlusTest(); | |
55 prePlusPlusTest(); | |
56 postMinusMinusTest(); | |
57 preMinusMinusTest(); | |
58 } | |
OLD | NEW |