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 library Int32test; | 5 library Int32test; |
6 import 'package:fixnum/fixnum.dart'; | 6 import 'package:fixnum/fixnum.dart'; |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 | 8 |
9 void main() { | 9 void main() { |
10 group("isX tests", () { | 10 group("isX tests", () { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 }); | 266 }); |
267 | 267 |
268 group("conversions", () { | 268 group("conversions", () { |
269 test("toSigned", () { | 269 test("toSigned", () { |
270 expect(Int32.ONE.toSigned(2), Int32.ONE); | 270 expect(Int32.ONE.toSigned(2), Int32.ONE); |
271 expect(Int32.ONE.toSigned(1), -Int32.ONE); | 271 expect(Int32.ONE.toSigned(1), -Int32.ONE); |
272 expect(Int32.MAX_VALUE.toSigned(32), Int32.MAX_VALUE); | 272 expect(Int32.MAX_VALUE.toSigned(32), Int32.MAX_VALUE); |
273 expect(Int32.MIN_VALUE.toSigned(32), Int32.MIN_VALUE); | 273 expect(Int32.MIN_VALUE.toSigned(32), Int32.MIN_VALUE); |
274 expect(Int32.MAX_VALUE.toSigned(31), -Int32.ONE); | 274 expect(Int32.MAX_VALUE.toSigned(31), -Int32.ONE); |
275 expect(Int32.MIN_VALUE.toSigned(31), Int32.ZERO); | 275 expect(Int32.MIN_VALUE.toSigned(31), Int32.ZERO); |
276 expect(() => Int32.ONE.toSigned(0), throws); | 276 expect(() => Int32.ONE.toSigned(0), throwsRangeError); |
277 expect(() => Int32.ONE.toSigned(33), throws); | 277 expect(() => Int32.ONE.toSigned(33), throwsRangeError); |
278 }); | 278 }); |
279 test("toUnsigned", () { | 279 test("toUnsigned", () { |
280 expect(Int32.ONE.toUnsigned(1), Int32.ONE); | 280 expect(Int32.ONE.toUnsigned(1), Int32.ONE); |
281 expect(Int32.ONE.toUnsigned(0), Int32.ZERO); | 281 expect(Int32.ONE.toUnsigned(0), Int32.ZERO); |
282 expect(Int32.MAX_VALUE.toUnsigned(32), Int32.MAX_VALUE); | 282 expect(Int32.MAX_VALUE.toUnsigned(32), Int32.MAX_VALUE); |
283 expect(Int32.MIN_VALUE.toUnsigned(32), Int32.MIN_VALUE); | 283 expect(Int32.MIN_VALUE.toUnsigned(32), Int32.MIN_VALUE); |
284 expect(Int32.MAX_VALUE.toUnsigned(31), Int32.MAX_VALUE); | 284 expect(Int32.MAX_VALUE.toUnsigned(31), Int32.MAX_VALUE); |
285 expect(Int32.MIN_VALUE.toUnsigned(31), Int32.ZERO); | 285 expect(Int32.MIN_VALUE.toUnsigned(31), Int32.ZERO); |
286 expect(() => Int32.ONE.toUnsigned(-1), throws); | 286 expect(() => Int32.ONE.toUnsigned(-1), throwsRangeError); |
287 expect(() => Int32.ONE.toUnsigned(33), throws); | 287 expect(() => Int32.ONE.toUnsigned(33), throwsRangeError); |
288 }); | 288 }); |
289 test("toDouble", () { | 289 test("toDouble", () { |
290 expect(new Int32(17).toDouble(), same(17.0)); | 290 expect(new Int32(17).toDouble(), same(17.0)); |
291 expect(new Int32(-17).toDouble(), same(-17.0)); | 291 expect(new Int32(-17).toDouble(), same(-17.0)); |
292 }); | 292 }); |
293 test("toInt", () { | 293 test("toInt", () { |
294 expect(new Int32(17).toInt(), 17); | 294 expect(new Int32(17).toInt(), 17); |
295 expect(new Int32(-17).toInt(), -17); | 295 expect(new Int32(-17).toInt(), -17); |
296 }); | 296 }); |
297 test("toInt32", () { | 297 test("toInt32", () { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 expect(new Int32(-1).shiftRightUnsigned(8).toHexString(), "ffffff"); | 358 expect(new Int32(-1).shiftRightUnsigned(8).toHexString(), "ffffff"); |
359 }); | 359 }); |
360 }); | 360 }); |
361 | 361 |
362 group("toRadixString", () { | 362 group("toRadixString", () { |
363 test("returns base n string representation", () { | 363 test("returns base n string representation", () { |
364 expect(new Int32(123456789).toRadixString(5), "223101104124"); | 364 expect(new Int32(123456789).toRadixString(5), "223101104124"); |
365 }); | 365 }); |
366 }); | 366 }); |
367 } | 367 } |
OLD | NEW |