| 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', prefix: 'Math'); | 8 #import('dart:math', prefix: 'Math'); |
| 9 #source('../intx.dart'); | 9 #source('../intx.dart'); |
| 10 #source('../int32.dart'); | 10 #source('../int32.dart'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 test.doTestBoolean(new BooleanOp("!=", (a, b) => a != b)); | 27 test.doTestBoolean(new BooleanOp("!=", (a, b) => a != b)); |
| 28 test.doTestBoolean(new BooleanOp("<", (a, b) => a < b)); | 28 test.doTestBoolean(new BooleanOp("<", (a, b) => a < b)); |
| 29 test.doTestBoolean(new BooleanOp("<=", (a, b) => a <= b)); | 29 test.doTestBoolean(new BooleanOp("<=", (a, b) => a <= b)); |
| 30 test.doTestBoolean(new BooleanOp(">", (a, b) => a > b)); | 30 test.doTestBoolean(new BooleanOp(">", (a, b) => a > b)); |
| 31 test.doTestBoolean(new BooleanOp(">=", (a, b) => a >= b)); | 31 test.doTestBoolean(new BooleanOp(">=", (a, b) => a >= b)); |
| 32 test.doTestBinary(new BinaryOp("%", (a, b) => a % b)); | 32 test.doTestBinary(new BinaryOp("%", (a, b) => a % b)); |
| 33 test.doTestBinary(new BinaryOp("~/", (a, b) => a ~/ b)); | 33 test.doTestBinary(new BinaryOp("~/", (a, b) => a ~/ b)); |
| 34 test.doTestBinary(new BinaryOp("remainder", (a, b) => a.remainder(b))); | 34 test.doTestBinary(new BinaryOp("remainder", (a, b) => a.remainder(b))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 final int DISCARD = 0; | 37 const int DISCARD = 0; |
| 38 | 38 |
| 39 int64 _randomInt64() { | 39 int64 _randomInt64() { |
| 40 int i = 0; | 40 int i = 0; |
| 41 for (int b = 0; b < 64; b++) { | 41 for (int b = 0; b < 64; b++) { |
| 42 double rand = Math.random(); | 42 double rand = Math.random(); |
| 43 for (int j = 0; j < DISCARD; j++) { | 43 for (int j = 0; j < DISCARD; j++) { |
| 44 rand = Math.random(); | 44 rand = Math.random(); |
| 45 } | 45 } |
| 46 i = (i << 1) | ((rand > 0.5) ? 1 : 0); | 46 i = (i << 1) | ((rand > 0.5) ? 1 : 0); |
| 47 } | 47 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool test(int64 val0, int64 val1) => op(val0, val1); | 90 bool test(int64 val0, int64 val1) => op(val0, val1); |
| 91 } | 91 } |
| 92 | 92 |
| 93 class ShiftOp extends Op { | 93 class ShiftOp extends Op { |
| 94 ShiftOp(String name, Function op) : super(name, op); | 94 ShiftOp(String name, Function op) : super(name, op); |
| 95 int ref(int val0, int shift) => trunc64(op(val0, shift)); | 95 int ref(int val0, int shift) => trunc64(op(val0, shift)); |
| 96 int64 test(int64 val0, int shift) => op(val0, shift); | 96 int64 test(int64 val0, int shift) => op(val0, shift); |
| 97 } | 97 } |
| 98 | 98 |
| 99 class int64VMTest { | 99 class int64VMTest { |
| 100 static final int BASE_VALUES = 32; | 100 static const int BASE_VALUES = 32; |
| 101 static final int RANDOM_TESTS = 32; | 101 static const int RANDOM_TESTS = 32; |
| 102 List<int64> TEST_VALUES; | 102 List<int64> TEST_VALUES; |
| 103 | 103 |
| 104 int64VMTest() { | 104 int64VMTest() { |
| 105 Set<int64> testSet = new Set<int64>(); | 105 Set<int64> testSet = new Set<int64>(); |
| 106 for (int i = 0; i < BASE_VALUES; i++) { | 106 for (int i = 0; i < BASE_VALUES; i++) { |
| 107 testSet.add(new int64.fromInt(i)); | 107 testSet.add(new int64.fromInt(i)); |
| 108 testSet.add(new int64.fromInt(-i)); | 108 testSet.add(new int64.fromInt(-i)); |
| 109 | 109 |
| 110 testSet.add(int64.MIN_VALUE + i); | 110 testSet.add(int64.MIN_VALUE + i); |
| 111 testSet.add(int64.MAX_VALUE - i); | 111 testSet.add(int64.MAX_VALUE - i); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 for (int i = 0; i < RANDOM_TESTS; i++) { | 319 for (int i = 0; i < RANDOM_TESTS; i++) { |
| 320 int64 randomLong = _randomInt64(); | 320 int64 randomLong = _randomInt64(); |
| 321 for (int shift = -64; shift <= 64; shift++) { | 321 for (int shift = -64; shift <= 64; shift++) { |
| 322 _doTestShift(op, randomLong, shift); | 322 _doTestShift(op, randomLong, shift); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 } | 326 } |
| OLD | NEW |