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

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

Issue 1759973002: Add --no-background-compilation to tests that expect to run code in optimized form (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: more Created 4 years, 9 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
« no previous file with comments | « tests/language/mint_compares_test.dart ('k') | tests/language/mul_recipr_test.dart » ('j') | 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 --no-background-co mpilation
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 }
38 } 38 }
39 Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException); 39 Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException);
(...skipping 22 matching lines...) Expand all
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;
74 return x0 + x1 + y0 + y1; 74 return x0 + x1 + y0 + y1;
75 } 75 }
76 76
77 foo2(i) { 77 foo2(i) {
78 // Make sure x has a range computed. 78 // Make sure x has a range computed.
79 var x = 0; 79 var x = 0;
80 if (i < 0) { 80 if (i < 0) {
81 x = -i; 81 x = -i;
82 } else { 82 } else {
83 x = i; 83 x = i;
84 } 84 }
85 return i % x; 85 return i % x;
86 } 86 }
87 87
88 88
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 | « tests/language/mint_compares_test.dart ('k') | tests/language/mul_recipr_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698