| 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 Bigints. | 4 // Testing Bigints. |
| 5 // TODO(srdjan): Make sure the numbers are Bigint and not Mint or Smi. | 5 // TODO(srdjan): Make sure the numbers are Bigint and not Mint or Smi. |
| 6 | 6 |
| 7 #library("BigIntegerTest.dart"); | 7 #library("BigIntegerTest.dart"); |
| 8 | 8 |
| 9 class BigIntegerTest { | 9 class BigIntegerTest { |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Expect.equals(0, a & b); | 131 Expect.equals(0, a & b); |
| 132 Expect.equals(-1, a | b); | 132 Expect.equals(-1, a | b); |
| 133 } | 133 } |
| 134 | 134 |
| 135 static testShiftAmount() { | 135 static testShiftAmount() { |
| 136 Expect.equals(0, 12 >> 111111111111111111111111111111); | 136 Expect.equals(0, 12 >> 111111111111111111111111111111); |
| 137 Expect.equals(-1, -12 >> 111111111111111111111111111111); | 137 Expect.equals(-1, -12 >> 111111111111111111111111111111); |
| 138 bool exceptionCaught = false; | 138 bool exceptionCaught = false; |
| 139 try { | 139 try { |
| 140 var a = 1 << 1111111111111111111111111111; | 140 var a = 1 << 1111111111111111111111111111; |
| 141 } on OutOfMemoryError catch (e) { | 141 } on OutOfMemoryException catch (e) { |
| 142 exceptionCaught = true; | 142 exceptionCaught = true; |
| 143 } | 143 } |
| 144 Expect.equals(true, exceptionCaught); | 144 Expect.equals(true, exceptionCaught); |
| 145 } | 145 } |
| 146 | 146 |
| 147 static testMain() { | 147 static testMain() { |
| 148 Expect.equals(1234567890123456789, foo()); | 148 Expect.equals(1234567890123456789, foo()); |
| 149 testSmiOverflow(); | 149 testSmiOverflow(); |
| 150 testBigintAdd(); | 150 testBigintAdd(); |
| 151 testBigintSub(); | 151 testBigintSub(); |
| 152 testBigintMul(); | 152 testBigintMul(); |
| 153 testBigintRemainder(); | 153 testBigintRemainder(); |
| 154 testBigintTruncDiv(); | 154 testBigintTruncDiv(); |
| 155 testBigintDiv(); | 155 testBigintDiv(); |
| 156 testBigintNegate(); | 156 testBigintNegate(); |
| 157 testShiftAmount(); | 157 testShiftAmount(); |
| 158 Expect.equals(1234567890123456, (1234567890123456).abs()); | 158 Expect.equals(1234567890123456, (1234567890123456).abs()); |
| 159 Expect.equals(1234567890123456, (-1234567890123456).abs()); | 159 Expect.equals(1234567890123456, (-1234567890123456).abs()); |
| 160 var a = 10000000000000000000; | 160 var a = 10000000000000000000; |
| 161 var b = 10000000000000000001; | 161 var b = 10000000000000000001; |
| 162 Expect.equals(false, a.hashCode() == b.hashCode()); | 162 Expect.equals(false, a.hashCode() == b.hashCode()); |
| 163 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); | 163 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 main() { | 167 main() { |
| 168 BigIntegerTest.testMain(); | 168 BigIntegerTest.testMain(); |
| 169 } | 169 } |
| OLD | NEW |