OLD | NEW |
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 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 test(0x3FFFFFFF, 0x40000000, 1); | 196 test(0x3FFFFFFF, 0x40000000, 1); |
197 | 197 |
198 test(pow(2, 54), pow(2, 53), pow(2, 53)); | 198 test(pow(2, 54), pow(2, 53), pow(2, 53)); |
199 | 199 |
200 test((pow(2, 52) - 1) * pow(2, 14), | 200 test((pow(2, 52) - 1) * pow(2, 14), |
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 |
OLD | NEW |