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 // VMOptions=--optimization-counter-threshold=20 --no-use-osr | 5 // VMOptions=--optimization-counter-threshold=20 --no-use-osr --no-background-co
mpilation |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 main() { | 9 main() { |
10 for (var i = 0; i < 50; i++) { | 10 for (var i = 0; i < 50; i++) { |
11 Expect.isTrue(mul1double(i) is double); | 11 Expect.isTrue(mul1double(i) is double); |
12 Expect.equals(i.toDouble(), mul1double(i)); | 12 Expect.equals(i.toDouble(), mul1double(i)); |
13 Expect.equals(0.0, mul0double(i)); | 13 Expect.equals(0.0, mul0double(i)); |
14 Expect.equals(i.toDouble(), add0double(i)); | 14 Expect.equals(i.toDouble(), add0double(i)); |
15 | 15 |
(...skipping 14 matching lines...) Expand all Loading... |
30 mul0double(x) => 0.0 * x; | 30 mul0double(x) => 0.0 * x; |
31 add0double(x) => 0.0 + x; | 31 add0double(x) => 0.0 + x; |
32 | 32 |
33 mul1int(x) => 1 * x; | 33 mul1int(x) => 1 * x; |
34 mul0int(x) => 0 * x; | 34 mul0int(x) => 0 * x; |
35 add0int(x) => 0 + x; | 35 add0int(x) => 0 + x; |
36 and0(x) => 0 & x; | 36 and0(x) => 0 & x; |
37 or0(x) => 0 | x; | 37 or0(x) => 0 | x; |
38 xor0(x) => 0 ^ x; | 38 xor0(x) => 0 ^ x; |
39 and1(x) => (-1) & x; | 39 and1(x) => (-1) & x; |
OLD | NEW |