Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: tests/language/arithmetic_canonicalization_test.dart

Issue 11773040: Canonicalize away simple arithmetic equivalences. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test, address comments Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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;
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698