OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test canonicalization of simple arithmetic equivalences. | 4 // Test canonicalization of simple arithmetic equivalences. |
5 | 5 |
| 6 import "package:expect/expect.dart"; |
| 7 |
6 main() { | 8 main() { |
7 for (var i = 0; i < 5000; i++) { | 9 for (var i = 0; i < 5000; i++) { |
8 Expect.isTrue(mul1double(i) is double); | 10 Expect.isTrue(mul1double(i) is double); |
9 Expect.equals(i.toDouble(), mul1double(i)); | 11 Expect.equals(i.toDouble(), mul1double(i)); |
10 Expect.equals(0.0, mul0double(i)); | 12 Expect.equals(0.0, mul0double(i)); |
11 Expect.equals(i.toDouble(), add0double(i)); | 13 Expect.equals(i.toDouble(), add0double(i)); |
12 | 14 |
13 Expect.equals(i, mul1int(i)); | 15 Expect.equals(i, mul1int(i)); |
14 Expect.equals(i, add0int(i)); | 16 Expect.equals(i, add0int(i)); |
15 Expect.equals(0, mul0int(i)); | 17 Expect.equals(0, mul0int(i)); |
(...skipping 11 matching lines...) Expand all Loading... |
27 mul0double(x) => 0.0 * x; | 29 mul0double(x) => 0.0 * x; |
28 add0double(x) => 0.0 + x; | 30 add0double(x) => 0.0 + x; |
29 | 31 |
30 mul1int(x) => 1 * x; | 32 mul1int(x) => 1 * x; |
31 mul0int(x) => 0 * x; | 33 mul0int(x) => 0 * x; |
32 add0int(x) => 0 + x; | 34 add0int(x) => 0 + x; |
33 and0(x) => 0 & x; | 35 and0(x) => 0 & x; |
34 or0(x) => 0 | x; | 36 or0(x) => 0 | x; |
35 xor0(x) => 0 ^ x; | 37 xor0(x) => 0 ^ x; |
36 and1(x) => (-1) & x; | 38 and1(x) => (-1) & x; |
OLD | NEW |