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 #import("dart:coreimpl"); | 8 #import("dart:coreimpl"); |
9 | 9 |
10 class BigIntegerTest { | 10 class BigIntegerTest { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 Expect.equals(0, a & b); | 136 Expect.equals(0, a & b); |
137 Expect.equals(-1, a | b); | 137 Expect.equals(-1, a | b); |
138 } | 138 } |
139 | 139 |
140 static testShiftAmount() { | 140 static testShiftAmount() { |
141 Expect.equals(0, 12 >> 111111111111111111111111111111); | 141 Expect.equals(0, 12 >> 111111111111111111111111111111); |
142 Expect.equals(-1, -12 >> 111111111111111111111111111111); | 142 Expect.equals(-1, -12 >> 111111111111111111111111111111); |
143 bool exceptionCaught = false; | 143 bool exceptionCaught = false; |
144 try { | 144 try { |
145 var a = 1 << 1111111111111111111111111111; | 145 var a = 1 << 1111111111111111111111111111; |
146 } catch (OutOfMemoryException e) { | 146 } on OutOfMemoryException catch (e) { |
147 exceptionCaught = true; | 147 exceptionCaught = true; |
148 } | 148 } |
149 Expect.equals(true, exceptionCaught); | 149 Expect.equals(true, exceptionCaught); |
150 } | 150 } |
151 | 151 |
152 static testMain() { | 152 static testMain() { |
153 Expect.equals(1234567890123456789, foo()); | 153 Expect.equals(1234567890123456789, foo()); |
154 testSmiOverflow(); | 154 testSmiOverflow(); |
155 testBigintAdd(); | 155 testBigintAdd(); |
156 testBigintSub(); | 156 testBigintSub(); |
(...skipping 10 matching lines...) Expand all Loading... |
167 checkBigint(a); | 167 checkBigint(a); |
168 checkBigint(b); | 168 checkBigint(b); |
169 Expect.equals(false, a.hashCode() == b.hashCode()); | 169 Expect.equals(false, a.hashCode() == b.hashCode()); |
170 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); | 170 Expect.equals(true, a.hashCode() == (b - 1).hashCode()); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 main() { | 174 main() { |
175 BigIntegerTest.testMain(); | 175 BigIntegerTest.testMain(); |
176 } | 176 } |
OLD | NEW |