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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co mpilation 4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co mpilation
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Test arithmetic on 64-bit integers. 8 // Test arithmetic on 64-bit integers.
9 9
10 test_and_1() { 10 test_and_1() {
11 try { // Avoid optimizing this function. 11 try {
12 // Avoid optimizing this function.
12 f(a, b) { 13 f(a, b) {
13 var s = b; 14 var s = b;
14 var t = a & s; 15 var t = a & s;
15 return t == b; 16 return t == b;
16 } 17 }
18
17 var x = 0xffffffff; 19 var x = 0xffffffff;
18 for (var i = 0; i < 20; i++) f(x, 0); 20 for (var i = 0; i < 20; i++) f(x, 0);
19 Expect.equals(true, f(x, 0)); 21 Expect.equals(true, f(x, 0));
20 Expect.equals(false, f(x, -1)); // Triggers deoptimization. 22 Expect.equals(false, f(x, -1)); // Triggers deoptimization.
21 } finally { } 23 } finally {}
22 } 24 }
23 25
24 test_and_2() { 26 test_and_2() {
25 try { // Avoid optimizing this function. 27 try {
28 // Avoid optimizing this function.
26 f(a, b) { 29 f(a, b) {
27 return a & b; 30 return a & b;
28 } 31 }
32
29 var x = 0xffffffff; 33 var x = 0xffffffff;
30 for (var i = 0; i < 20; i++) f(x, x); 34 for (var i = 0; i < 20; i++) f(x, x);
31 Expect.equals(x, f(x, x)); 35 Expect.equals(x, f(x, x));
32 Expect.equals(1234, f(0xffffffff, 1234)); 36 Expect.equals(1234, f(0xffffffff, 1234));
33 Expect.equals(0x100000001, f(0x100000001,-1)); 37 Expect.equals(0x100000001, f(0x100000001, -1));
34 Expect.equals(-0x40000000, f(-0x40000000, -1)); 38 Expect.equals(-0x40000000, f(-0x40000000, -1));
35 Expect.equals(0x40000000, f(0x40000000, -1)); 39 Expect.equals(0x40000000, f(0x40000000, -1));
36 Expect.equals(0x3fffffff, f(0x3fffffff, -1)); 40 Expect.equals(0x3fffffff, f(0x3fffffff, -1));
37 } finally { } 41 } finally {}
38 } 42 }
39 43
40 test_xor_1() { 44 test_xor_1() {
41 try { // Avoid optimizing this function. 45 try {
46 // Avoid optimizing this function.
42 f(a, b) { 47 f(a, b) {
43 var s = b; 48 var s = b;
44 var t = a ^ s; 49 var t = a ^ s;
45 return t; 50 return t;
46 } 51 }
52
47 var x = 0xffffffff; 53 var x = 0xffffffff;
48 for (var i = 0; i < 20; i++) f(x, x); 54 for (var i = 0; i < 20; i++) f(x, x);
49 Expect.equals(0, f(x, x)); 55 Expect.equals(0, f(x, x));
50 Expect.equals(-x - 1, f(x, -1)); 56 Expect.equals(-x - 1, f(x, -1));
51 var y = 0xffffffffffffffff; 57 var y = 0xffffffffffffffff;
52 Expect.equals(-y - 1, f(y, -1)); // Triggers deoptimization. 58 Expect.equals(-y - 1, f(y, -1)); // Triggers deoptimization.
53 } finally { } 59 } finally {}
54 } 60 }
55 61
56 test_or_1() { 62 test_or_1() {
57 try { // Avoid optimizing this function. 63 try {
64 // Avoid optimizing this function.
58 f(a, b) { 65 f(a, b) {
59 var s = b; 66 var s = b;
60 var t = a | s; 67 var t = a | s;
61 return t; 68 return t;
62 } 69 }
70
63 var x = 0xffffffff; 71 var x = 0xffffffff;
64 for (var i = 0; i < 20; i++) f(x, x); 72 for (var i = 0; i < 20; i++) f(x, x);
65 Expect.equals(x, f(x, x)); 73 Expect.equals(x, f(x, x));
66 Expect.equals(-1, f(x, -1)); 74 Expect.equals(-1, f(x, -1));
67 var y = 0xffffffffffffffff; 75 var y = 0xffffffffffffffff;
68 Expect.equals(-1, f(y, -1)); // Triggers deoptimization. 76 Expect.equals(-1, f(y, -1)); // Triggers deoptimization.
69 } finally { } 77 } finally {}
70 } 78 }
71 79
72 test_func(x, y) => (x & y) + 1.0; 80 test_func(x, y) => (x & y) + 1.0;
73 81
74 test_mint_double_op() { 82 test_mint_double_op() {
75 for (var i = 0; i < 20; i++) test_func(4294967295, 1); 83 for (var i = 0; i < 20; i++) test_func(4294967295, 1);
76 Expect.equals(2.0, test_func(4294967295, 1)); 84 Expect.equals(2.0, test_func(4294967295, 1));
77 } 85 }
78 86
79 main() { 87 main() {
80 for (var i = 0; i < 5; i++) { 88 for (var i = 0; i < 5; i++) {
81 test_and_1(); 89 test_and_1();
82 test_and_2(); 90 test_and_2();
83 test_xor_1(); 91 test_xor_1();
84 test_or_1(); 92 test_or_1();
85 test_mint_double_op(); 93 test_mint_double_op();
86 } 94 }
87 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698