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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 int zero() { return 0; } | 7 int zero() { |
8 int one() { return 1; } | 8 return 0; |
9 int minus1() { return 0 - 1; } | 9 } |
10 int two() { return 2; } | 10 |
11 int three() { return 3; } | 11 int one() { |
12 int five() { return 5; } | 12 return 1; |
13 int minus5() { return 0 - 5; } | 13 } |
14 int ninetyNine() { return 99; } | 14 |
15 int four99() { return 499; } | 15 int minus1() { |
16 int four99times99() { return 499 * 99; } | 16 return 0 - 1; |
17 int four99times99plus1() { return 499 * 99 + 1; } | 17 } |
| 18 |
| 19 int two() { |
| 20 return 2; |
| 21 } |
| 22 |
| 23 int three() { |
| 24 return 3; |
| 25 } |
| 26 |
| 27 int five() { |
| 28 return 5; |
| 29 } |
| 30 |
| 31 int minus5() { |
| 32 return 0 - 5; |
| 33 } |
| 34 |
| 35 int ninetyNine() { |
| 36 return 99; |
| 37 } |
| 38 |
| 39 int four99() { |
| 40 return 499; |
| 41 } |
| 42 |
| 43 int four99times99() { |
| 44 return 499 * 99; |
| 45 } |
| 46 |
| 47 int four99times99plus1() { |
| 48 return 499 * 99 + 1; |
| 49 } |
18 | 50 |
19 void postPlusPlusTest() { | 51 void postPlusPlusTest() { |
20 var x = zero(); | 52 var x = zero(); |
21 var y = x++; | 53 var y = x++; |
22 Expect.equals(0, y); | 54 Expect.equals(0, y); |
23 Expect.equals(1, x); | 55 Expect.equals(1, x); |
24 Expect.equals(1, x++); | 56 Expect.equals(1, x++); |
25 Expect.equals(2, x); | 57 Expect.equals(2, x); |
26 } | 58 } |
27 | 59 |
(...skipping 23 matching lines...) Expand all Loading... |
51 Expect.equals(497, --x); | 83 Expect.equals(497, --x); |
52 Expect.equals(497, x); | 84 Expect.equals(497, x); |
53 } | 85 } |
54 | 86 |
55 void main() { | 87 void main() { |
56 postPlusPlusTest(); | 88 postPlusPlusTest(); |
57 prePlusPlusTest(); | 89 prePlusPlusTest(); |
58 postMinusMinusTest(); | 90 postMinusMinusTest(); |
59 preMinusMinusTest(); | 91 preMinusMinusTest(); |
60 } | 92 } |
OLD | NEW |