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

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

Issue 131333004: Similar fix to merging trunc-div/mod: only one merge for now. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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/flow_graph_optimizer.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
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 // Dart test optimization of modulo operator on Smi. 4 // Dart test optimization of modulo operator on Smi.
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 9
10 main() { 10 main() {
11 // Prime IC cache. 11 // Prime IC cache.
12 noDom(1); 12 noDom(1);
13 noDom(-1); 13 noDom(-1);
14 for (int i = -30; i < 30; i++) { 14 for (int i = -30; i < 30; i++) {
15 Expect.equals(i % 256, foo(i)); 15 Expect.equals(i % 256, foo(i));
16 Expect.equals(i % -256, boo(i)); 16 Expect.equals(i % -256, boo(i));
17 Expect.throws(() => hoo(i), (e) => e is IntegerDivisionByZeroException); 17 Expect.throws(() => hoo(i), (e) => e is IntegerDivisionByZeroException);
18 18
19 Expect.equals(i ~/ 254 + i % 254, fooTwo(i)); 19 Expect.equals(i ~/ 254 + i % 254, fooTwo(i));
20 Expect.equals(i ~/ -254 + i % -254, booTwo(i)); 20 Expect.equals(i ~/ -254 + i % -254, booTwo(i));
21 Expect.throws(() => hooTwo(i), (e) => e is IntegerDivisionByZeroException); 21 Expect.throws(() => hooTwo(i), (e) => e is IntegerDivisionByZeroException);
22 if (i > 0) { 22 if (i > 0) {
23 Expect.equals(i % 10, noDom(i)); 23 Expect.equals(i % 10, noDom(i));
24 } else { 24 } else {
25 Expect.equals(i ~/ 10, noDom(i)); 25 Expect.equals(i ~/ 10, noDom(i));
26 } 26 }
27 Expect.equals((i ~/ 10) + (i ~/ 10) + (i % 10), threeOp(i)); 27 Expect.equals((i ~/ 10) + (i % 10) + (i % 10), threeOp(i));
28 Expect.equals((i ~/ 10) + (i ~/ 12) + (i % 10) + (i % 12), fourOp(i)); 28 Expect.equals((i ~/ 10) + (i ~/ 12) + (i % 10) + (i % 12), fourOp(i));
29 29
30 // Zero test is done outside the loop. 30 // Zero test is done outside the loop.
31 if (i < 0) { 31 if (i < 0) {
32 Expect.equals(i % -i, foo2(i)); 32 Expect.equals(i % -i, foo2(i));
33 Expect.equals(i ~/ -i + i % -i, fooTwo2(i)); 33 Expect.equals(i ~/ -i + i % -i, fooTwo2(i));
34 } else if (i > 0) { 34 } else if (i > 0) {
35 Expect.equals(i % i, foo2(i)); 35 Expect.equals(i % i, foo2(i));
36 Expect.equals(i ~/ i + i % i, fooTwo2(i)); 36 Expect.equals(i ~/ i + i % i, fooTwo2(i));
37 } 37 }
(...skipping 15 matching lines...) Expand all
53 if (a > 0) { 53 if (a > 0) {
54 x = a % 10; 54 x = a % 10;
55 } else { 55 } else {
56 x = a ~/ 10; 56 x = a ~/ 10;
57 } 57 }
58 return x; 58 return x;
59 } 59 }
60 60
61 threeOp(a) { 61 threeOp(a) {
62 var x = a ~/ 10; 62 var x = a ~/ 10;
63 var y = a ~/ 10; 63 var y = a % 10;
64 var z = a % 10; 64 var z = a % 10;
65 return x + y + z; 65 return x + y + z;
66 } 66 }
67 67
68 68
69 fourOp(a) { 69 fourOp(a) {
70 var x0 = a ~/ 10; 70 var x0 = a ~/ 10;
71 var x1 = a ~/ 12; 71 var x1 = a ~/ 12;
72 var y0 = a % 10; 72 var y0 = a % 10;
73 var y1 = a % 12; 73 var y1 = a % 12;
(...skipping 15 matching lines...) Expand all
89 fooTwo2(i) { 89 fooTwo2(i) {
90 // Make sure x has a range computed. 90 // Make sure x has a range computed.
91 var x = 0; 91 var x = 0;
92 if (i < 0) { 92 if (i < 0) {
93 x = -i; 93 x = -i;
94 } else { 94 } else {
95 x = i; 95 x = i;
96 } 96 }
97 return i ~/ x + i % x; 97 return i ~/ x + i % x;
98 } 98 }
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698