| 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('../fixnum.dart'); | 6 #import('../fixnum.dart'); |
| 7 | 7 |
| 8 void main() { | 8 void main() { |
| 9 Expect.equals("0", new int32.fromInt(0).toString()); | 9 Expect.equals("0", new int32.fromInt(0).toString()); |
| 10 Expect.equals("1", new int32.fromInt(1).toString()); | 10 Expect.equals("1", new int32.fromInt(1).toString()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 Expect.equals("-100", (new int32.fromInt(-1) << 8).toHexString()); | 24 Expect.equals("-100", (new int32.fromInt(-1) << 8).toHexString()); |
| 25 Expect.equals("ffffff", | 25 Expect.equals("ffffff", |
| 26 new int32.fromInt(-1).shiftRightUnsigned(8).toHexString()); | 26 new int32.fromInt(-1).shiftRightUnsigned(8).toHexString()); |
| 27 | 27 |
| 28 Expect.equals("123456789", new int32.fromInt(123456789).toString()); | 28 Expect.equals("123456789", new int32.fromInt(123456789).toString()); |
| 29 Expect.equals("75bcd15", new int32.fromInt(123456789).toHexString()); | 29 Expect.equals("75bcd15", new int32.fromInt(123456789).toHexString()); |
| 30 Expect.equals("223101104124", new int32.fromInt(123456789).toRadixString(5)); | 30 Expect.equals("223101104124", new int32.fromInt(123456789).toRadixString(5)); |
| 31 | 31 |
| 32 try { | 32 try { |
| 33 new int32.fromInt(17) >> -1; | 33 new int32.fromInt(17) >> -1; |
| 34 Expect.fail("x >> -1 should throw IllegalArgumentException"); | 34 Expect.fail("x >> -1 should throw ArgumentError"); |
| 35 } on IllegalArgumentException catch (e) { | 35 } on ArgumentError catch (e) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 try { | 38 try { |
| 39 new int32.fromInt(17) << -1; | 39 new int32.fromInt(17) << -1; |
| 40 Expect.fail("x >> -1 should throw IllegalArgumentException"); | 40 Expect.fail("x >> -1 should throw ArgumentError"); |
| 41 } on IllegalArgumentException catch (e) { | 41 } on ArgumentError catch (e) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 try { | 44 try { |
| 45 new int32.fromInt(17).shiftRightUnsigned(-1); | 45 new int32.fromInt(17).shiftRightUnsigned(-1); |
| 46 Expect.fail("x >> -1 should throw IllegalArgumentException"); | 46 Expect.fail("x >> -1 should throw ArgumentError"); |
| 47 } on IllegalArgumentException catch (e) { | 47 } on ArgumentError catch (e) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 // wraparound | 50 // wraparound |
| 51 Expect.equals("-67153019", (new int32.fromInt(123456789) * | 51 Expect.equals("-67153019", (new int32.fromInt(123456789) * |
| 52 new int32.fromInt(987654321)).toString()); | 52 new int32.fromInt(987654321)).toString()); |
| 53 Expect.equals("121932631112635269", (new int64.fromInt(123456789) * | 53 Expect.equals("121932631112635269", (new int64.fromInt(123456789) * |
| 54 new int32.fromInt(987654321)).toString()); | 54 new int32.fromInt(987654321)).toString()); |
| 55 Expect.equals("121932631112635269", (new int32.fromInt(123456789) * | 55 Expect.equals("121932631112635269", (new int32.fromInt(123456789) * |
| 56 new int64.fromInt(987654321)).toString()); | 56 new int64.fromInt(987654321)).toString()); |
| 57 Expect.equals("121932631112635269", (new int64.fromInt(123456789) * | 57 Expect.equals("121932631112635269", (new int64.fromInt(123456789) * |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 try { | 151 try { |
| 152 new int32.fromInt(17) < null; | 152 new int32.fromInt(17) < null; |
| 153 Expect.fail("x >= null should throw NullPointerException"); | 153 Expect.fail("x >= null should throw NullPointerException"); |
| 154 } on NullPointerException catch (e) { | 154 } on NullPointerException catch (e) { |
| 155 } | 155 } |
| 156 | 156 |
| 157 Expect.isFalse(new int32.fromInt(17) == null); | 157 Expect.isFalse(new int32.fromInt(17) == null); |
| 158 } | 158 } |
| OLD | NEW |