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 // Test basic integer operations. | |
5 | |
6 class IntTest { | |
7 static void testMain() { | |
8 Expect.equals(0, 0 + 0); | |
9 Expect.equals(1, 1 + 0); | |
10 Expect.equals(2, 1 + 1); | |
11 Expect.equals(3, -1 + 4); | |
12 Expect.equals(3, 4 + -1); | |
13 | |
14 Expect.equals(1, 1 - 0); | |
15 Expect.equals(0, 1 - 1); | |
16 Expect.equals(1, 2 - 1); | |
17 Expect.equals(2, 4 - 2); | |
18 Expect.equals(-2, 2 - 4); | |
19 | |
20 Expect.equals(0, 3 * 0); | |
21 Expect.equals(0, 0 * 3); | |
22 Expect.equals(1, 1 * 1); | |
23 Expect.equals(5, 5 * 1); | |
24 Expect.equals(15, 3 * 5); | |
25 Expect.equals(-1, 1 * -1); | |
26 Expect.equals(-15, -5 * 3); | |
27 Expect.equals(15, -5 * -3); | |
28 | |
29 Expect.equals(1, 2 ~/ 2); | |
30 Expect.equals(2, 2 ~/ 1); | |
31 Expect.equals(2, 4 ~/ 2); | |
32 Expect.equals(2, 5 ~/ 2); | |
33 Expect.equals(-2, -5 ~/ 2); | |
34 Expect.equals(-2, -4 ~/ 2); | |
35 Expect.equals(-2, 5 ~/ -2); | |
36 Expect.equals(-2, 4 ~/ -2); | |
37 | |
38 Expect.equals(3, 7 % 4); | |
39 Expect.equals(2, 9 % 7); | |
40 Expect.equals(2, -7 % 9); | |
41 Expect.equals(7, 7 % -9); | |
42 Expect.equals(7, 7 % 9); | |
43 Expect.equals(2, -7 % -9); | |
44 | |
45 Expect.equals(3, (7).remainder(4)); | |
46 Expect.equals(2, (9).remainder(7)); | |
47 Expect.equals(-7, (-7).remainder(9)); | |
48 Expect.equals(7, (7).remainder(-9)); | |
49 Expect.equals(7, (7).remainder(9)); | |
50 Expect.equals(-7, (-7).remainder(-9)); | |
51 } | |
52 } | |
53 | |
54 | |
55 main() { | |
56 IntTest.testMain(); | |
57 } | |
OLD | NEW |