| 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 // Testing Mints. Note that the tests may not work on 64-bit machines, | 4 // Testing Mints. Note that the tests may not work on 64-bit machines, |
| 5 // as Smi's would be used to represent many of the numbers. | 5 // as Smi's would be used to represent many of the numbers. |
| 6 | 6 |
| 7 #library("MediumIntegerTest.dart"); | 7 #library("MediumIntegerTest.dart"); |
| 8 #import("dart:coreimpl"); | 8 #import("dart:coreimpl"); |
| 9 | 9 |
| 10 class MediumIntegerTest { | 10 class MediumIntegerTest { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 checkSmi(b); | 123 checkSmi(b); |
| 124 checkBigint(a * b); | 124 checkBigint(a * b); |
| 125 Expect.equals(46116860184273879040, a * b); | 125 Expect.equals(46116860184273879040, a * b); |
| 126 b = 1000000000000000000; | 126 b = 1000000000000000000; |
| 127 checkMint(a); | 127 checkMint(a); |
| 128 checkMint(b); | 128 checkMint(b); |
| 129 checkBigint(a * b); | 129 checkBigint(a * b); |
| 130 Expect.equals(4611686018427387904000000000000000000, a * b); | 130 Expect.equals(4611686018427387904000000000000000000, a * b); |
| 131 } | 131 } |
| 132 | 132 |
| 133 static testMintAnd(mint) { |
| 134 // Issue 1845. |
| 135 final int t = 0; |
| 136 var res = mint & (t - 1); |
| 137 Expect.equals(mint, res); |
| 138 } |
| 139 |
| 133 // TODO(srdjan): Add more tests. | 140 // TODO(srdjan): Add more tests. |
| 134 | 141 |
| 135 static void testMain() { | 142 static void testMain() { |
| 136 checkMint(getMint()); | 143 checkMint(getMint()); |
| 137 Expect.equals(1234567890123456789, getMint()); | 144 Expect.equals(1234567890123456789, getMint()); |
| 138 testSmiOverflow(); | 145 testSmiOverflow(); |
| 139 testMintAdd(); | 146 testMintAdd(); |
| 140 testMintSub(); | 147 testMintSub(); |
| 141 testMintMul(); | 148 testMintMul(); |
| 142 testMintDiv(); | 149 testMintDiv(); |
| 150 testMintAnd(-1925149952); |
| 151 testMintAnd(1925149952); |
| 143 var a = 100000000000; | 152 var a = 100000000000; |
| 144 var b = 100000000001; | 153 var b = 100000000001; |
| 145 checkMint(a); | 154 checkMint(a); |
| 146 checkMint(b); | 155 checkMint(b); |
| 147 Expect.equals(false, a.hashCode() == b.hashCode()); | 156 Expect.equals(false, a.hashCode() == b.hashCode()); |
| 148 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); | 157 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); |
| 149 } | 158 } |
| 150 } | 159 } |
| 151 | 160 |
| 152 main() { | 161 main() { |
| 153 MediumIntegerTest.testMain(); | 162 for (int i = 0; i < 1000; i++) { |
| 163 MediumIntegerTest.testMain(); |
| 164 } |
| 154 } | 165 } |
| OLD | NEW |