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

Side by Side Diff: tests/language_strong/div_with_power_of_two2_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) 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 division by power of two. 4 // Test division by power of two.
5 // Test that results before and after optimization are the same. 5 // Test that results before and after optimization are the same.
6 // VMOptions=--optimization-counter-threshold=10 --no-use-osr 6 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 9
10 // [function, [list of tuples argument/result]]. 10 // [function, [list of tuples argument/result]].
11 var expectedResults = 11 var expectedResults = [
12 [ [divBy1, 12 [
13 [[134217730, 134217730], 13 divBy1,
14 [-134217730, -134217730], 14 [
15 [10, 10], 15 [134217730, 134217730],
16 [-10, -10]]], 16 [-134217730, -134217730],
17 [divByNeg1, 17 [10, 10],
18 [[134217730, -134217730], 18 [-10, -10]
19 [-134217730, 134217730], 19 ]
20 [10, -10], 20 ],
21 [-10, 10]]], 21 [
22 [divBy2, 22 divByNeg1,
23 [[134217730, 67108865], 23 [
24 [-134217730, -67108865], 24 [134217730, -134217730],
25 [10, 5], 25 [-134217730, 134217730],
26 [-10, -5]]], 26 [10, -10],
27 [divByNeg2, 27 [-10, 10]
28 [[134217730, -67108865], 28 ]
29 [-134217730, 67108865], 29 ],
30 [10, -5], 30 [
31 [-10, 5]]], 31 divBy2,
32 [divBy4, 32 [
33 [[134217730, 33554432], 33 [134217730, 67108865],
34 [-134217730, -33554432], 34 [-134217730, -67108865],
35 [10, 2], 35 [10, 5],
36 [-10, -2]]], 36 [-10, -5]
37 [divByNeg4, 37 ]
38 [[134217730, -33554432], 38 ],
39 [-134217730, 33554432], 39 [
40 [10, -2], 40 divByNeg2,
41 [-10, 2]]], 41 [
42 [divBy134217728, 42 [134217730, -67108865],
43 [[134217730, 1], 43 [-134217730, 67108865],
44 [-134217730, -1], 44 [10, -5],
45 [10, 0], 45 [-10, 5]
46 [-10, 0]]], 46 ]
47 [divByNeg134217728, 47 ],
48 [[134217730, -1], 48 [
49 [-134217730, 1], 49 divBy4,
50 [10, 0], 50 [
51 [-10, 0]]], 51 [134217730, 33554432],
52 // Use different functions for 64 bit arguments. 52 [-134217730, -33554432],
53 [divBy4_, 53 [10, 2],
54 [[549755813990, 137438953497], 54 [-10, -2]
55 [-549755813990, -137438953497], 55 ]
56 [288230925907525632, 72057731476881408], 56 ],
57 [-288230925907525632, -72057731476881408]]], 57 [
58 [divByNeg4_, 58 divByNeg4,
59 [[549755813990, -137438953497], 59 [
60 [-549755813990, 137438953497], 60 [134217730, -33554432],
61 [288230925907525632, -72057731476881408], 61 [-134217730, 33554432],
62 [-288230925907525632, 72057731476881408]]], 62 [10, -2],
63 [divBy549755813888, 63 [-10, 2]
64 [[549755813990, 1], 64 ]
65 [-549755813990, -1], 65 ],
66 [288230925907525632, 524289], 66 [
67 [-288230925907525632, -524289]]], 67 divBy134217728,
68 [divByNeg549755813888, 68 [
69 [[549755813990, -1], 69 [134217730, 1],
70 [-549755813990, 1], 70 [-134217730, -1],
71 [288230925907525632, -524289], 71 [10, 0],
72 [-288230925907525632, 524289]]], 72 [-10, 0]
73 ]; 73 ]
74 ],
75 [
76 divByNeg134217728,
77 [
78 [134217730, -1],
79 [-134217730, 1],
80 [10, 0],
81 [-10, 0]
82 ]
83 ],
84 // Use different functions for 64 bit arguments.
85 [
86 divBy4_,
87 [
88 [549755813990, 137438953497],
89 [-549755813990, -137438953497],
90 [288230925907525632, 72057731476881408],
91 [-288230925907525632, -72057731476881408]
92 ]
93 ],
94 [
95 divByNeg4_,
96 [
97 [549755813990, -137438953497],
98 [-549755813990, 137438953497],
99 [288230925907525632, -72057731476881408],
100 [-288230925907525632, 72057731476881408]
101 ]
102 ],
103 [
104 divBy549755813888,
105 [
106 [549755813990, 1],
107 [-549755813990, -1],
108 [288230925907525632, 524289],
109 [-288230925907525632, -524289]
110 ]
111 ],
112 [
113 divByNeg549755813888,
114 [
115 [549755813990, -1],
116 [-549755813990, 1],
117 [288230925907525632, -524289],
118 [-288230925907525632, 524289]
119 ]
120 ],
121 ];
74 122
75 divBy0(a) => a ~/ 0; 123 divBy0(a) => a ~/ 0;
76 divBy1(a) => a ~/ 1; 124 divBy1(a) => a ~/ 1;
77 divByNeg1(a) => a ~/ -1; 125 divByNeg1(a) => a ~/ -1;
78 divBy2(a) => a ~/ 2; 126 divBy2(a) => a ~/ 2;
79 divByNeg2(a) => a ~/ -2; 127 divByNeg2(a) => a ~/ -2;
80 divBy4(a) => a ~/ 4; 128 divBy4(a) => a ~/ 4;
81 divByNeg4(a) => a ~/ -4; 129 divByNeg4(a) => a ~/ -4;
82 divBy134217728(a) => a ~/ 134217728; 130 divBy134217728(a) => a ~/ 134217728;
83 divByNeg134217728(a) => a ~/ -134217728; 131 divByNeg134217728(a) => a ~/ -134217728;
84 132
85 divBy4_(a) => a ~/ 4; 133 divBy4_(a) => a ~/ 4;
86 divByNeg4_(a) => a ~/ -4; 134 divByNeg4_(a) => a ~/ -4;
87 divBy549755813888(a) => a ~/ 549755813888; 135 divBy549755813888(a) => a ~/ 549755813888;
88 divByNeg549755813888(a) => a ~/ -549755813888; 136 divByNeg549755813888(a) => a ~/ -549755813888;
89 137
90 main() { 138 main() {
91 for (int i = 0; i < 20; i++) { 139 for (int i = 0; i < 20; i++) {
92 for (var e in expectedResults) { 140 for (var e in expectedResults) {
93 Function f = e[0]; 141 Function f = e[0];
94 List values = e[1]; 142 List values = e[1];
95 for (var v in values) { 143 for (var v in values) {
96 int arg = v[0]; 144 int arg = v[0];
97 int res = v[1]; 145 int res = v[1];
98 Expect.equals(res, f(arg)); 146 Expect.equals(res, f(arg));
99 } 147 }
100 } 148 }
101 Expect.throws(() => divBy0(4), 149 Expect.throws(() => divBy0(4),
102 (e) => e is IntegerDivisionByZeroException 150 (e) => e is IntegerDivisionByZeroException || e is UnsupportedError);
103 || e is UnsupportedError);
104 } 151 }
105 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698