| 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("arithmetic operators", () { | 10 group("arithmetic operators", () { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 new int32.fromInt(0x12345678.remainder(0x22))); | 87 new int32.fromInt(0x12345678.remainder(0x22))); |
| 88 expect(() => new int32.fromInt(17).remainder(null), throws); | 88 expect(() => new int32.fromInt(17).remainder(null), throws); |
| 89 }); | 89 }); |
| 90 }); | 90 }); |
| 91 | 91 |
| 92 group("comparison operators", () { | 92 group("comparison operators", () { |
| 93 test("<", () { | 93 test("<", () { |
| 94 expect(new int32.fromInt(17) < new int32.fromInt(18), true); | 94 expect(new int32.fromInt(17) < new int32.fromInt(18), true); |
| 95 expect(new int32.fromInt(17) < new int32.fromInt(17), false); | 95 expect(new int32.fromInt(17) < new int32.fromInt(17), false); |
| 96 expect(new int32.fromInt(17) < new int32.fromInt(16), false); | 96 expect(new int32.fromInt(17) < new int32.fromInt(16), false); |
| 97 expect(new int32.fromInt(17) < new int64.fromInt(18), true); |
| 98 expect(new int32.fromInt(17) < new int64.fromInt(17), false); |
| 99 expect(new int32.fromInt(17) < new int64.fromInt(16), false); |
| 97 expect(int32.MIN_VALUE < int32.MAX_VALUE, true); | 100 expect(int32.MIN_VALUE < int32.MAX_VALUE, true); |
| 98 expect(int32.MAX_VALUE < int32.MIN_VALUE, false); | 101 expect(int32.MAX_VALUE < int32.MIN_VALUE, false); |
| 99 expect(() => new int32.fromInt(17) < null, throws); | 102 expect(() => new int32.fromInt(17) < null, throws); |
| 100 }); | 103 }); |
| 101 | 104 |
| 102 test("<=", () { | 105 test("<=", () { |
| 103 expect(new int32.fromInt(17) <= new int32.fromInt(18), true); | 106 expect(new int32.fromInt(17) <= new int32.fromInt(18), true); |
| 104 expect(new int32.fromInt(17) <= new int32.fromInt(17), true); | 107 expect(new int32.fromInt(17) <= new int32.fromInt(17), true); |
| 105 expect(new int32.fromInt(17) <= new int32.fromInt(16), false); | 108 expect(new int32.fromInt(17) <= new int32.fromInt(16), false); |
| 109 expect(new int32.fromInt(17) <= new int64.fromInt(18), true); |
| 110 expect(new int32.fromInt(17) <= new int64.fromInt(17), true); |
| 111 expect(new int32.fromInt(17) <= new int64.fromInt(16), false); |
| 106 expect(int32.MIN_VALUE <= int32.MAX_VALUE, true); | 112 expect(int32.MIN_VALUE <= int32.MAX_VALUE, true); |
| 107 expect(int32.MAX_VALUE <= int32.MIN_VALUE, false); | 113 expect(int32.MAX_VALUE <= int32.MIN_VALUE, false); |
| 108 expect(() => new int32.fromInt(17) <= null, throws); | 114 expect(() => new int32.fromInt(17) <= null, throws); |
| 109 }); | 115 }); |
| 110 | 116 |
| 111 test("==", () { | 117 test("==", () { |
| 112 expect(new int32.fromInt(17) == new int32.fromInt(18), false); | 118 expect(new int32.fromInt(17) == new int32.fromInt(18), false); |
| 113 expect(new int32.fromInt(17) == new int32.fromInt(17), true); | 119 expect(new int32.fromInt(17) == new int32.fromInt(17), true); |
| 114 expect(new int32.fromInt(17) == new int32.fromInt(16), false); | 120 expect(new int32.fromInt(17) == new int32.fromInt(16), false); |
| 121 expect(new int32.fromInt(17) == new int64.fromInt(18), false); |
| 122 expect(new int32.fromInt(17) == new int64.fromInt(17), true); |
| 123 expect(new int32.fromInt(17) == new int64.fromInt(16), false); |
| 115 expect(int32.MIN_VALUE == int32.MAX_VALUE, false); | 124 expect(int32.MIN_VALUE == int32.MAX_VALUE, false); |
| 125 expect(new int32.fromInt(17) == new Object(), false); |
| 116 expect(new int32.fromInt(17) == null, false); | 126 expect(new int32.fromInt(17) == null, false); |
| 117 }); | 127 }); |
| 118 | 128 |
| 119 test(">=", () { | 129 test(">=", () { |
| 120 expect(new int32.fromInt(17) >= new int32.fromInt(18), false); | 130 expect(new int32.fromInt(17) >= new int32.fromInt(18), false); |
| 121 expect(new int32.fromInt(17) >= new int32.fromInt(17), true); | 131 expect(new int32.fromInt(17) >= new int32.fromInt(17), true); |
| 122 expect(new int32.fromInt(17) >= new int32.fromInt(16), true); | 132 expect(new int32.fromInt(17) >= new int32.fromInt(16), true); |
| 133 expect(new int32.fromInt(17) >= new int64.fromInt(18), false); |
| 134 expect(new int32.fromInt(17) >= new int64.fromInt(17), true); |
| 135 expect(new int32.fromInt(17) >= new int64.fromInt(16), true); |
| 123 expect(int32.MIN_VALUE >= int32.MAX_VALUE, false); | 136 expect(int32.MIN_VALUE >= int32.MAX_VALUE, false); |
| 124 expect(int32.MAX_VALUE >= int32.MIN_VALUE, true); | 137 expect(int32.MAX_VALUE >= int32.MIN_VALUE, true); |
| 125 expect(() => new int32.fromInt(17) >= null, throws); | 138 expect(() => new int32.fromInt(17) >= null, throws); |
| 126 }); | 139 }); |
| 127 | 140 |
| 128 test(">", () { | 141 test(">", () { |
| 129 expect(new int32.fromInt(17) > new int32.fromInt(18), false); | 142 expect(new int32.fromInt(17) > new int32.fromInt(18), false); |
| 130 expect(new int32.fromInt(17) > new int32.fromInt(17), false); | 143 expect(new int32.fromInt(17) > new int32.fromInt(17), false); |
| 131 expect(new int32.fromInt(17) > new int32.fromInt(16), true); | 144 expect(new int32.fromInt(17) > new int32.fromInt(16), true); |
| 145 expect(new int32.fromInt(17) > new int64.fromInt(18), false); |
| 146 expect(new int32.fromInt(17) > new int64.fromInt(17), false); |
| 147 expect(new int32.fromInt(17) > new int64.fromInt(16), true); |
| 132 expect(int32.MIN_VALUE > int32.MAX_VALUE, false); | 148 expect(int32.MIN_VALUE > int32.MAX_VALUE, false); |
| 133 expect(int32.MAX_VALUE > int32.MIN_VALUE, true); | 149 expect(int32.MAX_VALUE > int32.MIN_VALUE, true); |
| 134 expect(() => new int32.fromInt(17) > null, throws); | 150 expect(() => new int32.fromInt(17) > null, throws); |
| 135 }); | 151 }); |
| 136 }); | 152 }); |
| 137 | 153 |
| 138 group("bitwise operators", () { | 154 group("bitwise operators", () { |
| 139 test("&", () { | 155 test("&", () { |
| 140 expect(new int32.fromInt(0x12345678) & new int32.fromInt(0x22222222), | 156 expect(new int32.fromInt(0x12345678) & new int32.fromInt(0x22222222), |
| 141 new int32.fromInt(0x12345678 & 0x22222222)); | 157 new int32.fromInt(0x12345678 & 0x22222222)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 "ffffff"); | 243 "ffffff"); |
| 228 }); | 244 }); |
| 229 }); | 245 }); |
| 230 | 246 |
| 231 group("toRadixString", () { | 247 group("toRadixString", () { |
| 232 test("returns base n string representation", () { | 248 test("returns base n string representation", () { |
| 233 expect(new int32.fromInt(123456789).toRadixString(5), "223101104124"); | 249 expect(new int32.fromInt(123456789).toRadixString(5), "223101104124"); |
| 234 }); | 250 }); |
| 235 }); | 251 }); |
| 236 } | 252 } |
| OLD | NEW |