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

Side by Side Diff: tests/corelib/int_modulo_arith_test.dart

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 import "dart:math" show pow; 7 import "dart:math" show pow;
8 8
9 var smallNumber = 1234567890; // is 31-bit integer. 9 var smallNumber = 1234567890; // is 31-bit integer.
10 var mediumNumber = 1234567890123456; // is 53-bit integer 10 var mediumNumber = 1234567890123456; // is 53-bit integer
11 var bigNumber = 590295810358705600000; // is > 64-bit integer, exact as double. 11 var bigNumber = 590295810358705600000; // is > 64-bit integer, exact as double.
12 12
13 testModPow() { 13 testModPow() {
14 test(x, e, m, expectedResult) { 14 test(x, e, m, expectedResult) {
15 // Check that expected result is correct, using an unoptimized version. 15 // Check that expected result is correct, using an unoptimized version.
16 assert(() { 16 assert(() {
17 if (1 is double) return true; // Don't have bignums. 17 if (1 is double) return true; // Don't have bignums.
18 slowModPow(x, e, m) { 18 slowModPow(x, e, m) {
19 var r = 1; 19 var r = 1;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 test(19, 1234567890, 519818059); 111 test(19, 1234567890, 519818059);
112 test(1000000001, 1234567890, 1001100101); 112 test(1000000001, 1234567890, 1001100101);
113 113
114 test(12345, 12346, 12345); 114 test(12345, 12346, 12345);
115 test(12345, 12346, 12345); 115 test(12345, 12346, 12345);
116 116
117 test(smallNumber, 137, 42); 117 test(smallNumber, 137, 42);
118 test(137, smallNumber, 856087223); 118 test(137, smallNumber, 856087223);
119 test(mediumNumber, 137, 77); 119 test(mediumNumber, 137, 77);
120 test(137, mediumNumber, 540686667207353); 120 test(137, mediumNumber, 540686667207353);
121 test(bigNumber, 137, 128); /// bignum: ok 121 test(bigNumber, 137, 128); // /// bignum: ok
122 // Bigger numbers as modulo is tested in big_integer_arith_vm_test.dart. 122 // Bigger numbers as modulo is tested in big_integer_arith_vm_test.dart.
123 // Big doubles are not co-prime, so there is nothing to test for dart2js. 123 // Big doubles are not co-prime, so there is nothing to test for dart2js.
124 } 124 }
125 125
126 testGcd() { 126 testGcd() {
127 // Call testFunc with all combinations and orders of plus/minus 127 // Call testFunc with all combinations and orders of plus/minus
128 // value and other. 128 // value and other.
129 callCombos(value, other, testFunc) { 129 callCombos(value, other, testFunc) {
130 testFunc(value, other); 130 testFunc(value, other);
131 testFunc(value, -other); 131 testFunc(value, -other);
(...skipping 30 matching lines...) Expand all
162 callCombos(value, other, (a, b) { 162 callCombos(value, other, (a, b) {
163 Expect.throws(() => a.gcd(b), null, "$a.gcd($b)"); 163 Expect.throws(() => a.gcd(b), null, "$a.gcd($b)");
164 }); 164 });
165 } 165 }
166 166
167 testThrows(2.5, 5); // Not a method on double. 167 testThrows(2.5, 5); // Not a method on double.
168 testThrows(5, 2.5); // Not accepting non-int arguments. 168 testThrows(5, 2.5); // Not accepting non-int arguments.
169 169
170 // Format: 170 // Format:
171 // test(value1, value2, expectedResult); 171 // test(value1, value2, expectedResult);
172 test(1, 1, 1); // both are 1 172 test(1, 1, 1); // both are 1
173 test(1, 2, 1); // one is 1 173 test(1, 2, 1); // one is 1
174 test(3, 5, 1); // coprime. 174 test(3, 5, 1); // coprime.
175 test(37, 37, 37); // Same larger prime. 175 test(37, 37, 37); // Same larger prime.
176 176
177 test(9999, 7272, 909); // Larger numbers 177 test(9999, 7272, 909); // Larger numbers
178 178
179 test(0, 1000, 1000); // One operand is zero. 179 test(0, 1000, 1000); // One operand is zero.
180 test(0, 0, 0); // Both operands are zero. 180 test(0, 0, 0); // Both operands are zero.
181 181
182 // Multiplying both operands by a number multiplies result by same number. 182 // Multiplying both operands by a number multiplies result by same number.
183 test(693, 609, 21); 183 test(693, 609, 21);
184 test(693 << 5, 609 << 5, 21 << 5); 184 test(693 << 5, 609 << 5, 21 << 5);
185 test(693 * 937, 609 * 937, 21 * 937); 185 test(693 * 937, 609 * 937, 21 * 937);
186 test(693 * pow(2, 32), 609 * pow(2, 32), 21 * pow(2, 32)); 186 test(693 * pow(2, 32), 609 * pow(2, 32), 21 * pow(2, 32));
187 test(693 * pow(2, 52), 609 * pow(2, 52), 21 * pow(2, 52)); 187 test(693 * pow(2, 52), 609 * pow(2, 52), 21 * pow(2, 52));
188 test(693 * pow(2, 53), 609 * pow(2, 53), 21 * pow(2, 53)); // Regression. 188 test(693 * pow(2, 53), 609 * pow(2, 53), 21 * pow(2, 53)); // Regression.
189 test(693 * pow(2, 99), 609 * pow(2, 99), 21 * pow(2, 99)); 189 test(693 * pow(2, 99), 609 * pow(2, 99), 21 * pow(2, 99));
190 190
(...skipping 10 matching lines...) Expand all
201 (pow(2, 26) - 1) * pow(2, 22), 201 (pow(2, 26) - 1) * pow(2, 22),
202 (pow(2, 26) - 1) * pow(2, 14)); 202 (pow(2, 26) - 1) * pow(2, 14));
203 } 203 }
204 204
205 main() { 205 main() {
206 testModPow(); /// modPow: ok 206 testModPow(); /// modPow: ok
207 testModInverse(); 207 testModInverse();
208 testGcd(); 208 testGcd();
209 } 209 }
210 210
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698