| OLD | NEW |
| 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 | 4 |
| 5 // A test to compare the results of the fixnum library with the Dart VM | 5 // A test to compare the results of the fixnum library with the Dart VM |
| 6 | 6 |
| 7 library int64vmtest; | 7 library int64vmtest; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 part '../lib/src/int32.dart'; | 10 part '../lib/src/int32.dart'; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 i = (i << 1) | ((rand > 0.5) ? 1 : 0); | 49 i = (i << 1) | ((rand > 0.5) ? 1 : 0); |
| 50 } | 50 } |
| 51 return new int64.fromInt(i); | 51 return new int64.fromInt(i); |
| 52 } | 52 } |
| 53 | 53 |
| 54 int _randomInt(int n) { | 54 int _randomInt(int n) { |
| 55 double rand = random.nextDouble(); | 55 double rand = random.nextDouble(); |
| 56 for (int i = 0; i < DISCARD; i++) { | 56 for (int i = 0; i < DISCARD; i++) { |
| 57 rand = random.nextDouble(); | 57 rand = random.nextDouble(); |
| 58 } | 58 } |
| 59 return (rand * n).floor().toInt(); | 59 return (rand * n).floor(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 class Op { | 62 class Op { |
| 63 String name; | 63 String name; |
| 64 Function op; | 64 Function op; |
| 65 | 65 |
| 66 Op(String this.name, Function this.op); | 66 Op(String this.name, Function this.op); |
| 67 | 67 |
| 68 // Truncate x to a value in the range [-2^63, 2^63 - 1] | 68 // Truncate x to a value in the range [-2^63, 2^63 - 1] |
| 69 int trunc64(int x) { | 69 int trunc64(int x) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 for (int i = 0; i < RANDOM_TESTS; i++) { | 322 for (int i = 0; i < RANDOM_TESTS; i++) { |
| 323 int64 randomLong = _randomInt64(); | 323 int64 randomLong = _randomInt64(); |
| 324 for (int shift = -64; shift <= 64; shift++) { | 324 for (int shift = -64; shift <= 64; shift++) { |
| 325 _doTestShift(op, randomLong, shift); | 325 _doTestShift(op, randomLong, shift); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| OLD | NEW |