| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Test canonicalization of simple arithmetic equivalences. |
| 5 |
| 6 main() { |
| 7 for (var i = 0; i < 5000; i++) { |
| 8 Expect.isTrue(mul1double(i) is double); |
| 9 Expect.equals(i.toDouble(), mul1double(i)); |
| 10 Expect.equals(0.0, mul0double(i)); |
| 11 Expect.equals(i.toDouble(), add0double(i)); |
| 12 |
| 13 Expect.equals(i, mul1int(i)); |
| 14 Expect.equals(i, add0int(i)); |
| 15 Expect.equals(0, mul0int(i)); |
| 16 Expect.equals(0, and0(i)); |
| 17 Expect.equals(i, and1(i)); |
| 18 Expect.equals(i, or0(i)); |
| 19 Expect.equals(i, xor0(i)); |
| 20 } |
| 21 |
| 22 Expect.isTrue(mul0double(double.NAN).isNaN); |
| 23 Expect.isFalse(add0double(-0.0).isNegative); |
| 24 } |
| 25 |
| 26 mul1double(x) => 1.0 * x; |
| 27 mul0double(x) => 0.0 * x; |
| 28 add0double(x) => 0.0 + x; |
| 29 |
| 30 mul1int(x) => 1 * x; |
| 31 mul0int(x) => 0 * x; |
| 32 add0int(x) => 0 + x; |
| 33 and0(x) => 0 & x; |
| 34 or0(x) => 0 | x; |
| 35 xor0(x) => 0 ^ x; |
| 36 and1(x) => (-1) & x; |
| OLD | NEW |