OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Testing Bigints with and without intrinsics. | 5 // Testing Bigints with and without intrinsics. |
6 // VMOptions= | 6 // VMOptions= |
7 // VMOptions=--no_intrinsify | 7 // VMOptions=--no_intrinsify |
8 | 8 |
9 library big_integer_test; | 9 library big_integer_test; |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 Expect.equals(true, m.isEven); | 228 Expect.equals(true, m.isEven); |
229 try { | 229 try { |
230 x.modInverse(m); | 230 x.modInverse(m); |
231 Expect.fail("Did not throw UnimplementedError"); | 231 Expect.fail("Did not throw UnimplementedError"); |
232 } on UnimplementedError catch (e) { | 232 } on UnimplementedError catch (e) { |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 testBigintModInverse() { | 236 testBigintModInverse() { |
237 var x, m; | 237 var x, m; |
| 238 x = 0; |
| 239 m = 1000000001; |
| 240 Expect.equals(0, x.modInverse(m)); // Not coprime. |
238 x = 1234567890; | 241 x = 1234567890; |
239 m = 19; | 242 m = 19; |
240 Expect.equals(11, x.modInverse(m)); | 243 Expect.equals(11, x.modInverse(m)); |
241 x = 1234567890; | 244 x = 1234567890; |
242 m = 1000000001; | 245 m = 1000000001; |
243 Expect.equals(189108911, x.modInverse(m)); | 246 Expect.equals(189108911, x.modInverse(m)); |
244 x = 19; | 247 x = 19; |
245 m = 1000000001; | 248 m = 1000000001; |
246 Expect.equals(0, x.modInverse(m)); // Not coprime. | 249 Expect.equals(0, x.modInverse(m)); // Not coprime. |
247 x = 19; | 250 x = 19; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 testBigintModInverse(); | 334 testBigintModInverse(); |
332 testBigintNegate(); | 335 testBigintNegate(); |
333 testShiftAmount(); | 336 testShiftAmount(); |
334 Expect.equals(12345678901234567890, (12345678901234567890).abs()); | 337 Expect.equals(12345678901234567890, (12345678901234567890).abs()); |
335 Expect.equals(12345678901234567890, (-12345678901234567890).abs()); | 338 Expect.equals(12345678901234567890, (-12345678901234567890).abs()); |
336 var a = 10000000000000000000; | 339 var a = 10000000000000000000; |
337 var b = 10000000000000000001; | 340 var b = 10000000000000000001; |
338 Expect.equals(false, a.hashCode == b.hashCode); | 341 Expect.equals(false, a.hashCode == b.hashCode); |
339 Expect.equals(true, a.hashCode == (b - 1).hashCode); | 342 Expect.equals(true, a.hashCode == (b - 1).hashCode); |
340 } | 343 } |
OLD | NEW |