| 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 int64test; | 5 library int64test; |
| 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", () { |
| 11 int64 n1 = new int64.fromInt(1234); | 11 Int64 n1 = new Int64.fromInt(1234); |
| 12 int64 n2 = new int64.fromInt(9876); | 12 Int64 n2 = new Int64.fromInt(9876); |
| 13 int64 n3 = new int64.fromInt(-1234); | 13 Int64 n3 = new Int64.fromInt(-1234); |
| 14 int64 n4 = new int64.fromInt(-9876); | 14 Int64 n4 = new Int64.fromInt(-9876); |
| 15 int64 n5 = new int64.fromInts(0x12345678, 0xabcdabcd); | 15 Int64 n5 = new Int64.fromInts(0x12345678, 0xabcdabcd); |
| 16 int64 n6 = new int64.fromInts(0x77773333, 0x22224444); | 16 Int64 n6 = new Int64.fromInts(0x77773333, 0x22224444); |
| 17 | 17 |
| 18 test("+", () { | 18 test("+", () { |
| 19 expect(n1 + n2, new int64.fromInt(11110)); | 19 expect(n1 + n2, new Int64.fromInt(11110)); |
| 20 expect(n3 + n2, new int64.fromInt(8642)); | 20 expect(n3 + n2, new Int64.fromInt(8642)); |
| 21 expect(n3 + n4, new int64.fromInt(-11110)); | 21 expect(n3 + n4, new Int64.fromInt(-11110)); |
| 22 expect(n5 + n6, new int64.fromInts(0x89ab89ab, 0xcdeff011)); | 22 expect(n5 + n6, new Int64.fromInts(0x89ab89ab, 0xcdeff011)); |
| 23 expect(int64.MAX_VALUE + 1, int64.MIN_VALUE); | 23 expect(Int64.MAX_VALUE + 1, Int64.MIN_VALUE); |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 test("-", () { | 26 test("-", () { |
| 27 expect(n1 - n2, new int64.fromInt(-8642)); | 27 expect(n1 - n2, new Int64.fromInt(-8642)); |
| 28 expect(n3 - n2, new int64.fromInt(-11110)); | 28 expect(n3 - n2, new Int64.fromInt(-11110)); |
| 29 expect(n3 - n4, new int64.fromInt(8642)); | 29 expect(n3 - n4, new Int64.fromInt(8642)); |
| 30 expect(n5 - n6, new int64.fromInts(0x9abd2345, 0x89ab6789)); | 30 expect(n5 - n6, new Int64.fromInts(0x9abd2345, 0x89ab6789)); |
| 31 expect(int64.MIN_VALUE - 1, int64.MAX_VALUE); | 31 expect(Int64.MIN_VALUE - 1, Int64.MAX_VALUE); |
| 32 }); | 32 }); |
| 33 | 33 |
| 34 test("unary -", () { | 34 test("unary -", () { |
| 35 expect(-n1, new int64.fromInt(-1234)); | 35 expect(-n1, new Int64.fromInt(-1234)); |
| 36 expect(-int64.ZERO, int64.ZERO); | 36 expect(-Int64.ZERO, Int64.ZERO); |
| 37 }); | 37 }); |
| 38 | 38 |
| 39 test("*", () { | 39 test("*", () { |
| 40 expect(new int64.fromInt(1111) * new int64.fromInt(3), | 40 expect(new Int64.fromInt(1111) * new Int64.fromInt(3), |
| 41 new int64.fromInt(3333)); | 41 new Int64.fromInt(3333)); |
| 42 expect(new int64.fromInt(1111) * new int64.fromInt(-3), | 42 expect(new Int64.fromInt(1111) * new Int64.fromInt(-3), |
| 43 new int64.fromInt(-3333)); | 43 new Int64.fromInt(-3333)); |
| 44 expect(new int64.fromInt(-1111) * new int64.fromInt(3), | 44 expect(new Int64.fromInt(-1111) * new Int64.fromInt(3), |
| 45 new int64.fromInt(-3333)); | 45 new Int64.fromInt(-3333)); |
| 46 expect(new int64.fromInt(-1111) * new int64.fromInt(-3), | 46 expect(new Int64.fromInt(-1111) * new Int64.fromInt(-3), |
| 47 new int64.fromInt(3333)); | 47 new Int64.fromInt(3333)); |
| 48 expect(new int64.fromInt(100) * new int64.fromInt(0), | 48 expect(new Int64.fromInt(100) * new Int64.fromInt(0), |
| 49 new int64.fromInt(0)); | 49 new Int64.fromInt(0)); |
| 50 | 50 |
| 51 expect(new int64.fromInts(0x12345678, 0x12345678) * | 51 expect(new Int64.fromInts(0x12345678, 0x12345678) * |
| 52 new int64.fromInts(0x1234, 0x12345678), | 52 new Int64.fromInts(0x1234, 0x12345678), |
| 53 new int64.fromInts(0x7ff63f7c, 0x1df4d840)); | 53 new Int64.fromInts(0x7ff63f7c, 0x1df4d840)); |
| 54 expect(new int64.fromInts(0xf2345678, 0x12345678) * | 54 expect(new Int64.fromInts(0xf2345678, 0x12345678) * |
| 55 new int64.fromInts(0x1234, 0x12345678), | 55 new Int64.fromInts(0x1234, 0x12345678), |
| 56 new int64.fromInts(0x7ff63f7c, 0x1df4d840)); | 56 new Int64.fromInts(0x7ff63f7c, 0x1df4d840)); |
| 57 expect(new int64.fromInts(0xf2345678, 0x12345678) * | 57 expect(new Int64.fromInts(0xf2345678, 0x12345678) * |
| 58 new int64.fromInts(0xffff1234, 0x12345678), | 58 new Int64.fromInts(0xffff1234, 0x12345678), |
| 59 new int64.fromInts(0x297e3f7c, 0x1df4d840)); | 59 new Int64.fromInts(0x297e3f7c, 0x1df4d840)); |
| 60 | 60 |
| 61 // RHS int32 | 61 // RHS Int32 |
| 62 expect((new int64.fromInt(123456789) * new int32.fromInt(987654321)), | 62 expect((new Int64.fromInt(123456789) * new Int32.fromInt(987654321)), |
| 63 new int64.fromInts(0x1b13114, 0xfbff5385)); | 63 new Int64.fromInts(0x1b13114, 0xfbff5385)); |
| 64 expect((new int64.fromInt(123456789) * new int32.fromInt(987654321)), | 64 expect((new Int64.fromInt(123456789) * new Int32.fromInt(987654321)), |
| 65 new int64.fromInts(0x1b13114, 0xfbff5385)); | 65 new Int64.fromInts(0x1b13114, 0xfbff5385)); |
| 66 | 66 |
| 67 // Wraparound | 67 // Wraparound |
| 68 expect((new int64.fromInt(123456789) * new int64.fromInt(987654321)), | 68 expect((new Int64.fromInt(123456789) * new Int64.fromInt(987654321)), |
| 69 new int64.fromInts(0x1b13114, 0xfbff5385)); | 69 new Int64.fromInts(0x1b13114, 0xfbff5385)); |
| 70 | 70 |
| 71 expect(int64.MIN_VALUE * new int64.fromInt(2), new int64.fromInt(0)); | 71 expect(Int64.MIN_VALUE * new Int64.fromInt(2), new Int64.fromInt(0)); |
| 72 expect(int64.MIN_VALUE * new int64.fromInt(1), int64.MIN_VALUE); | 72 expect(Int64.MIN_VALUE * new Int64.fromInt(1), Int64.MIN_VALUE); |
| 73 expect(int64.MIN_VALUE * new int64.fromInt(-1), int64.MIN_VALUE); | 73 expect(Int64.MIN_VALUE * new Int64.fromInt(-1), Int64.MIN_VALUE); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 test("~/", () { | 76 test("~/", () { |
| 77 int64 deadBeef = new int64.fromInts(0xDEADBEEF, 0xDEADBEEF); | 77 Int64 deadBeef = new Int64.fromInts(0xDEADBEEF, 0xDEADBEEF); |
| 78 int64 ten = new int64.fromInt(10); | 78 Int64 ten = new Int64.fromInt(10); |
| 79 | 79 |
| 80 expect(deadBeef ~/ ten, new int64.fromInts(0xfcaaf97e, 0x63115fe5)); | 80 expect(deadBeef ~/ ten, new Int64.fromInts(0xfcaaf97e, 0x63115fe5)); |
| 81 expect(int64.ONE ~/ int64.TWO, int64.ZERO); | 81 expect(Int64.ONE ~/ Int64.TWO, Int64.ZERO); |
| 82 expect(int64.MAX_VALUE ~/ int64.TWO, | 82 expect(Int64.MAX_VALUE ~/ Int64.TWO, |
| 83 new int64.fromInts(0x3fffffff, 0xffffffff)); | 83 new Int64.fromInts(0x3fffffff, 0xffffffff)); |
| 84 expect(int64.ZERO ~/ new int64.fromInt(1000), int64.ZERO); | 84 expect(Int64.ZERO ~/ new Int64.fromInt(1000), Int64.ZERO); |
| 85 expect(int64.MIN_VALUE ~/ int64.MIN_VALUE, int64.ONE); | 85 expect(Int64.MIN_VALUE ~/ Int64.MIN_VALUE, Int64.ONE); |
| 86 expect(new int64.fromInt(1000) ~/ int64.MIN_VALUE, int64.ZERO); | 86 expect(new Int64.fromInt(1000) ~/ Int64.MIN_VALUE, Int64.ZERO); |
| 87 expect(int64.MIN_VALUE ~/ new int64.fromInt(8192), | 87 expect(Int64.MIN_VALUE ~/ new Int64.fromInt(8192), |
| 88 new int64.fromInt(-1125899906842624)); | 88 new Int64.fromInt(-1125899906842624)); |
| 89 expect(int64.MIN_VALUE ~/ new int64.fromInt(8193), | 89 expect(Int64.MIN_VALUE ~/ new Int64.fromInt(8193), |
| 90 new int64.fromInt(-1125762484664320)); | 90 new Int64.fromInt(-1125762484664320)); |
| 91 expect(new int64.fromInt(-1000) ~/ new int64.fromInt(8192), int64.ZERO); | 91 expect(new Int64.fromInt(-1000) ~/ new Int64.fromInt(8192), Int64.ZERO); |
| 92 expect(new int64.fromInt(-1000) ~/ new int64.fromInt(8193), int64.ZERO); | 92 expect(new Int64.fromInt(-1000) ~/ new Int64.fromInt(8193), Int64.ZERO); |
| 93 expect(new int64.fromInt(-1000000000) ~/ new int64.fromInt(8192), | 93 expect(new Int64.fromInt(-1000000000) ~/ new Int64.fromInt(8192), |
| 94 new int64.fromInt(-122070)); | 94 new Int64.fromInt(-122070)); |
| 95 expect(new int64.fromInt(-1000000000) ~/ new int64.fromInt(8193), | 95 expect(new Int64.fromInt(-1000000000) ~/ new Int64.fromInt(8193), |
| 96 new int64.fromInt(-122055)); | 96 new Int64.fromInt(-122055)); |
| 97 expect(new int64.fromInt(1000000000) ~/ new int64.fromInt(8192), | 97 expect(new Int64.fromInt(1000000000) ~/ new Int64.fromInt(8192), |
| 98 new int64.fromInt(122070)); | 98 new Int64.fromInt(122070)); |
| 99 expect(new int64.fromInt(1000000000) ~/ new int64.fromInt(8193), | 99 expect(new Int64.fromInt(1000000000) ~/ new Int64.fromInt(8193), |
| 100 new int64.fromInt(122055)); | 100 new Int64.fromInt(122055)); |
| 101 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000000, 0x00000400), | 101 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000000, 0x00000400), |
| 102 new int64.fromInts(0x1fffff, 0xffffffff)); | 102 new Int64.fromInts(0x1fffff, 0xffffffff)); |
| 103 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000000, 0x00040000), | 103 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000000, 0x00040000), |
| 104 new int64.fromInts(0x1fff, 0xffffffff)); | 104 new Int64.fromInts(0x1fff, 0xffffffff)); |
| 105 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000000, 0x04000000), | 105 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000000, 0x04000000), |
| 106 new int64.fromInts(0x1f, 0xffffffff)); | 106 new Int64.fromInts(0x1f, 0xffffffff)); |
| 107 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000004, 0x00000000), | 107 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000004, 0x00000000), |
| 108 new int64.fromInt(536870911)); | 108 new Int64.fromInt(536870911)); |
| 109 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000400, 0x00000000), | 109 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000400, 0x00000000), |
| 110 new int64.fromInt(2097151)); | 110 new Int64.fromInt(2097151)); |
| 111 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00040000, 0x00000000), | 111 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00040000, 0x00000000), |
| 112 new int64.fromInt(8191)); | 112 new Int64.fromInt(8191)); |
| 113 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x04000000, 0x00000000), | 113 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x04000000, 0x00000000), |
| 114 new int64.fromInt(31)); | 114 new Int64.fromInt(31)); |
| 115 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000000, 0x00000300), | 115 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000000, 0x00000300), |
| 116 new int64.fromInts(0x2AAAAA, 0xAAAAAAAA)); | 116 new Int64.fromInts(0x2AAAAA, 0xAAAAAAAA)); |
| 117 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00000000, 0x30000000), | 117 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00000000, 0x30000000), |
| 118 new int64.fromInts(0x2, 0xAAAAAAAA)); | 118 new Int64.fromInts(0x2, 0xAAAAAAAA)); |
| 119 expect(int64.MAX_VALUE ~/ new int64.fromInts(0x00300000, 0x00000000), | 119 expect(Int64.MAX_VALUE ~/ new Int64.fromInts(0x00300000, 0x00000000), |
| 120 new int64.fromInt(0x2AA)); | 120 new Int64.fromInt(0x2AA)); |
| 121 expect(int64.MAX_VALUE ~/ new int64.fromInt(0x123456), | 121 expect(Int64.MAX_VALUE ~/ new Int64.fromInt(0x123456), |
| 122 new int64.fromInts(0x708, 0x002E9501)); | 122 new Int64.fromInts(0x708, 0x002E9501)); |
| 123 expect(int64.MAX_VALUE % new int64.fromInt(0x123456), | 123 expect(Int64.MAX_VALUE % new Int64.fromInt(0x123456), |
| 124 new int64.fromInt(0x3BDA9)); | 124 new Int64.fromInt(0x3BDA9)); |
| 125 expect(new int64.fromInt(5) ~/ new int64.fromInt(5), | 125 expect(new Int64.fromInt(5) ~/ new Int64.fromInt(5), |
| 126 new int64.fromInt(1)); | 126 new Int64.fromInt(1)); |
| 127 expect(new int64.fromInt(1000) ~/ new int64.fromInt(3), | 127 expect(new Int64.fromInt(1000) ~/ new Int64.fromInt(3), |
| 128 new int64.fromInt(333)); | 128 new Int64.fromInt(333)); |
| 129 expect(new int64.fromInt(1000) ~/ new int64.fromInt(-3), | 129 expect(new Int64.fromInt(1000) ~/ new Int64.fromInt(-3), |
| 130 new int64.fromInt(-333)); | 130 new Int64.fromInt(-333)); |
| 131 expect(new int64.fromInt(-1000) ~/ new int64.fromInt(3), | 131 expect(new Int64.fromInt(-1000) ~/ new Int64.fromInt(3), |
| 132 new int64.fromInt(-333)); | 132 new Int64.fromInt(-333)); |
| 133 expect(new int64.fromInt(-1000) ~/ new int64.fromInt(-3), | 133 expect(new Int64.fromInt(-1000) ~/ new Int64.fromInt(-3), |
| 134 new int64.fromInt(333)); | 134 new Int64.fromInt(333)); |
| 135 expect(new int64.fromInt(3) ~/ new int64.fromInt(1000), | 135 expect(new Int64.fromInt(3) ~/ new Int64.fromInt(1000), |
| 136 new int64.fromInt(0)); | 136 new Int64.fromInt(0)); |
| 137 expect(new int64.fromInts( 0x12345678, 0x12345678) ~/ | 137 expect(new Int64.fromInts( 0x12345678, 0x12345678) ~/ |
| 138 new int64.fromInts(0x0, 0x123), | 138 new Int64.fromInts(0x0, 0x123), |
| 139 new int64.fromInts(0x1003d0, 0xe84f5ae8)); | 139 new Int64.fromInts(0x1003d0, 0xe84f5ae8)); |
| 140 expect(new int64.fromInts(0x12345678, 0x12345678) ~/ | 140 expect(new Int64.fromInts(0x12345678, 0x12345678) ~/ |
| 141 new int64.fromInts(0x1234, 0x12345678), | 141 new Int64.fromInts(0x1234, 0x12345678), |
| 142 new int64.fromInts(0x0, 0x10003)); | 142 new Int64.fromInts(0x0, 0x10003)); |
| 143 expect(new int64.fromInts(0xf2345678, 0x12345678) ~/ | 143 expect(new Int64.fromInts(0xf2345678, 0x12345678) ~/ |
| 144 new int64.fromInts(0x1234, 0x12345678), | 144 new Int64.fromInts(0x1234, 0x12345678), |
| 145 new int64.fromInts(0xffffffff, 0xffff3dfe)); | 145 new Int64.fromInts(0xffffffff, 0xffff3dfe)); |
| 146 expect(new int64.fromInts(0xf2345678, 0x12345678) ~/ | 146 expect(new Int64.fromInts(0xf2345678, 0x12345678) ~/ |
| 147 new int64.fromInts(0xffff1234, 0x12345678), | 147 new Int64.fromInts(0xffff1234, 0x12345678), |
| 148 new int64.fromInts(0x0, 0xeda)); | 148 new Int64.fromInts(0x0, 0xeda)); |
| 149 expect(new int64.fromInt(829893893) ~/ new int32.fromInt(1919), | 149 expect(new Int64.fromInt(829893893) ~/ new Int32.fromInt(1919), |
| 150 new int32.fromInt(432461)); | 150 new Int32.fromInt(432461)); |
| 151 expect(new int64.fromInt(829893893) ~/ new int64.fromInt(1919), | 151 expect(new Int64.fromInt(829893893) ~/ new Int64.fromInt(1919), |
| 152 new int32.fromInt(432461)); | 152 new Int32.fromInt(432461)); |
| 153 expect(new int64.fromInt(829893893) ~/ 1919, | 153 expect(new Int64.fromInt(829893893) ~/ 1919, |
| 154 new int32.fromInt(432461)); | 154 new Int32.fromInt(432461)); |
| 155 expect(() => new int64.fromInt(1) ~/ new int64.fromInt(0), | 155 expect(() => new Int64.fromInt(1) ~/ new Int64.fromInt(0), |
| 156 throwsA(new isInstanceOf<IntegerDivisionByZeroException>())); | 156 throwsA(new isInstanceOf<IntegerDivisionByZeroException>())); |
| 157 expect(int64.MIN_VALUE ~/ new int64.fromInt(2), | 157 expect(Int64.MIN_VALUE ~/ new Int64.fromInt(2), |
| 158 new int64.fromInts(0xc0000000, 0x00000000)); | 158 new Int64.fromInts(0xc0000000, 0x00000000)); |
| 159 expect(int64.MIN_VALUE ~/ new int64.fromInt(1), int64.MIN_VALUE); | 159 expect(Int64.MIN_VALUE ~/ new Int64.fromInt(1), Int64.MIN_VALUE); |
| 160 expect(int64.MIN_VALUE ~/ new int64.fromInt(-1), int64.MIN_VALUE); | 160 expect(Int64.MIN_VALUE ~/ new Int64.fromInt(-1), Int64.MIN_VALUE); |
| 161 expect(() => new int64.fromInt(17) ~/ int64.ZERO, throws); | 161 expect(() => new Int64.fromInt(17) ~/ Int64.ZERO, throws); |
| 162 expect(() => new int64.fromInt(17) ~/ null, throwsArgumentError); | 162 expect(() => new Int64.fromInt(17) ~/ null, throwsArgumentError); |
| 163 }); | 163 }); |
| 164 | 164 |
| 165 test("%", () { | 165 test("%", () { |
| 166 // Define % as Euclidean mod, with positive result for all arguments | 166 // Define % as Euclidean mod, with positive result for all arguments |
| 167 expect(int64.ZERO % new int64.fromInt(1000), new int64.fromInt(0)); | 167 expect(Int64.ZERO % new Int64.fromInt(1000), new Int64.fromInt(0)); |
| 168 expect(int64.MIN_VALUE % int64.MIN_VALUE, new int64.fromInt(0)); | 168 expect(Int64.MIN_VALUE % Int64.MIN_VALUE, new Int64.fromInt(0)); |
| 169 expect(new int64.fromInt(1000) % int64.MIN_VALUE, | 169 expect(new Int64.fromInt(1000) % Int64.MIN_VALUE, |
| 170 new int64.fromInt(1000)); | 170 new Int64.fromInt(1000)); |
| 171 expect(int64.MIN_VALUE % new int64.fromInt(8192), new int64.fromInt(0)); | 171 expect(Int64.MIN_VALUE % new Int64.fromInt(8192), new Int64.fromInt(0)); |
| 172 expect(int64.MIN_VALUE % new int64.fromInt(8193), | 172 expect(Int64.MIN_VALUE % new Int64.fromInt(8193), |
| 173 new int64.fromInt(6145)); | 173 new Int64.fromInt(6145)); |
| 174 expect(new int64.fromInt(-1000) % new int64.fromInt(8192), | 174 expect(new Int64.fromInt(-1000) % new Int64.fromInt(8192), |
| 175 new int64.fromInt(7192)); | 175 new Int64.fromInt(7192)); |
| 176 expect(new int64.fromInt(-1000) % new int64.fromInt(8193), | 176 expect(new Int64.fromInt(-1000) % new Int64.fromInt(8193), |
| 177 new int64.fromInt(7193)); | 177 new Int64.fromInt(7193)); |
| 178 expect(new int64.fromInt(-1000000000) % new int64.fromInt(8192), | 178 expect(new Int64.fromInt(-1000000000) % new Int64.fromInt(8192), |
| 179 new int64.fromInt(5632)); | 179 new Int64.fromInt(5632)); |
| 180 expect(new int64.fromInt(-1000000000) % new int64.fromInt(8193), | 180 expect(new Int64.fromInt(-1000000000) % new Int64.fromInt(8193), |
| 181 new int64.fromInt(4808)); | 181 new Int64.fromInt(4808)); |
| 182 expect(new int64.fromInt(1000000000) % new int64.fromInt(8192), | 182 expect(new Int64.fromInt(1000000000) % new Int64.fromInt(8192), |
| 183 new int64.fromInt(2560)); | 183 new Int64.fromInt(2560)); |
| 184 expect(new int64.fromInt(1000000000) % new int64.fromInt(8193), | 184 expect(new Int64.fromInt(1000000000) % new Int64.fromInt(8193), |
| 185 new int64.fromInt(3385)); | 185 new Int64.fromInt(3385)); |
| 186 expect(int64.MAX_VALUE % new int64.fromInts(0x00000000, 0x00000400), | 186 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00000000, 0x00000400), |
| 187 new int64.fromInts(0x0, 0x3ff)); | 187 new Int64.fromInts(0x0, 0x3ff)); |
| 188 expect(int64.MAX_VALUE % new int64.fromInts(0x00000000, 0x00040000), | 188 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00000000, 0x00040000), |
| 189 new int64.fromInts(0x0, 0x3ffff)); | 189 new Int64.fromInts(0x0, 0x3ffff)); |
| 190 expect(int64.MAX_VALUE % new int64.fromInts(0x00000000, 0x04000000), | 190 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00000000, 0x04000000), |
| 191 new int64.fromInts(0x0, 0x3ffffff)); | 191 new Int64.fromInts(0x0, 0x3ffffff)); |
| 192 expect(int64.MAX_VALUE % new int64.fromInts(0x00000004, 0x00000000), | 192 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00000004, 0x00000000), |
| 193 new int64.fromInts(0x3, 0xffffffff)); | 193 new Int64.fromInts(0x3, 0xffffffff)); |
| 194 expect(int64.MAX_VALUE % new int64.fromInts(0x00000400, 0x00000000), | 194 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00000400, 0x00000000), |
| 195 new int64.fromInts(0x3ff, 0xffffffff)); | 195 new Int64.fromInts(0x3ff, 0xffffffff)); |
| 196 expect(int64.MAX_VALUE % new int64.fromInts(0x00040000, 0x00000000), | 196 expect(Int64.MAX_VALUE % new Int64.fromInts(0x00040000, 0x00000000), |
| 197 new int64.fromInts(0x3ffff, 0xffffffff)); | 197 new Int64.fromInts(0x3ffff, 0xffffffff)); |
| 198 expect(int64.MAX_VALUE % new int64.fromInts(0x04000000, 0x00000000), | 198 expect(Int64.MAX_VALUE % new Int64.fromInts(0x04000000, 0x00000000), |
| 199 new int64.fromInts(0x3ffffff, 0xffffffff)); | 199 new Int64.fromInts(0x3ffffff, 0xffffffff)); |
| 200 expect(new int64.fromInt(0x12345678).remainder(new int64.fromInt(0x22)), | 200 expect(new Int64.fromInt(0x12345678).remainder(new Int64.fromInt(0x22)), |
| 201 new int64.fromInt(0x12345678.remainder(0x22))); | 201 new Int64.fromInt(0x12345678.remainder(0x22))); |
| 202 expect(new int64.fromInt(0x12345678).remainder(new int64.fromInt(-0x22)), | 202 expect(new Int64.fromInt(0x12345678).remainder(new Int64.fromInt(-0x22)), |
| 203 new int64.fromInt(0x12345678.remainder(-0x22))); | 203 new Int64.fromInt(0x12345678.remainder(-0x22))); |
| 204 expect(new int64.fromInt(-0x12345678).remainder(new int64.fromInt(-0x22)), | 204 expect(new Int64.fromInt(-0x12345678).remainder(new Int64.fromInt(-0x22)), |
| 205 new int64.fromInt(-0x12345678.remainder(-0x22))); | 205 new Int64.fromInt(-0x12345678.remainder(-0x22))); |
| 206 expect(new int64.fromInt(-0x12345678).remainder(new int64.fromInt(0x22)), | 206 expect(new Int64.fromInt(-0x12345678).remainder(new Int64.fromInt(0x22)), |
| 207 new int64.fromInt(-0x12345678.remainder(0x22))); | 207 new Int64.fromInt(-0x12345678.remainder(0x22))); |
| 208 expect(new int32.fromInt(0x12345678).remainder(new int64.fromInt(0x22)), | 208 expect(new Int32.fromInt(0x12345678).remainder(new Int64.fromInt(0x22)), |
| 209 new int64.fromInt(0x12345678.remainder(0x22))); | 209 new Int64.fromInt(0x12345678.remainder(0x22))); |
| 210 }); | 210 }); |
| 211 }); | 211 }); |
| 212 | 212 |
| 213 group("comparison operators", () { | 213 group("comparison operators", () { |
| 214 int64 largeNeg = new int64.fromInts(0x82341234, 0x0); | 214 Int64 largeNeg = new Int64.fromInts(0x82341234, 0x0); |
| 215 int64 largePos = new int64.fromInts(0x12341234, 0x0); | 215 Int64 largePos = new Int64.fromInts(0x12341234, 0x0); |
| 216 int64 largePosPlusOne = largePos + new int64.fromInt(1); | 216 Int64 largePosPlusOne = largePos + new Int64.fromInt(1); |
| 217 | 217 |
| 218 test("<", () { | 218 test("<", () { |
| 219 expect(new int64.fromInt(10) < new int64.fromInt(11), true); | 219 expect(new Int64.fromInt(10) < new Int64.fromInt(11), true); |
| 220 expect(new int64.fromInt(10) < new int64.fromInt(10), false); | 220 expect(new Int64.fromInt(10) < new Int64.fromInt(10), false); |
| 221 expect(new int64.fromInt(10) < new int64.fromInt(9), false); | 221 expect(new Int64.fromInt(10) < new Int64.fromInt(9), false); |
| 222 expect(new int64.fromInt(10) < new int32.fromInt(11), true); | 222 expect(new Int64.fromInt(10) < new Int32.fromInt(11), true); |
| 223 expect(new int64.fromInt(10) < new int32.fromInt(10), false); | 223 expect(new Int64.fromInt(10) < new Int32.fromInt(10), false); |
| 224 expect(new int64.fromInt(10) < new int32.fromInt(9), false); | 224 expect(new Int64.fromInt(10) < new Int32.fromInt(9), false); |
| 225 expect(new int64.fromInt(-10) < new int64.fromInt(-11), false); | 225 expect(new Int64.fromInt(-10) < new Int64.fromInt(-11), false); |
| 226 expect(int64.MIN_VALUE < new int64.fromInt(0), true); | 226 expect(Int64.MIN_VALUE < new Int64.fromInt(0), true); |
| 227 expect(largeNeg < largePos, true); | 227 expect(largeNeg < largePos, true); |
| 228 expect(largePos < largePosPlusOne, true); | 228 expect(largePos < largePosPlusOne, true); |
| 229 expect(largePos < largePos, false); | 229 expect(largePos < largePos, false); |
| 230 expect(largePosPlusOne < largePos, false); | 230 expect(largePosPlusOne < largePos, false); |
| 231 expect(int64.MIN_VALUE < int64.MAX_VALUE, true); | 231 expect(Int64.MIN_VALUE < Int64.MAX_VALUE, true); |
| 232 expect(int64.MAX_VALUE < int64.MIN_VALUE, false); | 232 expect(Int64.MAX_VALUE < Int64.MIN_VALUE, false); |
| 233 expect(() => new int64.fromInt(17) < null, throwsArgumentError); | 233 expect(() => new Int64.fromInt(17) < null, throwsArgumentError); |
| 234 }); | 234 }); |
| 235 | 235 |
| 236 test("<=", () { | 236 test("<=", () { |
| 237 expect(new int64.fromInt(10) <= new int64.fromInt(11), true); | 237 expect(new Int64.fromInt(10) <= new Int64.fromInt(11), true); |
| 238 expect(new int64.fromInt(10) <= new int64.fromInt(10), true); | 238 expect(new Int64.fromInt(10) <= new Int64.fromInt(10), true); |
| 239 expect(new int64.fromInt(10) <= new int64.fromInt(9), false); | 239 expect(new Int64.fromInt(10) <= new Int64.fromInt(9), false); |
| 240 expect(new int64.fromInt(10) <= new int32.fromInt(11), true); | 240 expect(new Int64.fromInt(10) <= new Int32.fromInt(11), true); |
| 241 expect(new int64.fromInt(10) <= new int32.fromInt(10), true); | 241 expect(new Int64.fromInt(10) <= new Int32.fromInt(10), true); |
| 242 expect(new int64.fromInt(10) <= new int64.fromInt(9), false); | 242 expect(new Int64.fromInt(10) <= new Int64.fromInt(9), false); |
| 243 expect(new int64.fromInt(-10) <= new int64.fromInt(-11), false); | 243 expect(new Int64.fromInt(-10) <= new Int64.fromInt(-11), false); |
| 244 expect(new int64.fromInt(-10) <= new int64.fromInt(-10), true); | 244 expect(new Int64.fromInt(-10) <= new Int64.fromInt(-10), true); |
| 245 expect(largeNeg <= largePos, true); | 245 expect(largeNeg <= largePos, true); |
| 246 expect(largePos <= largeNeg, false); | 246 expect(largePos <= largeNeg, false); |
| 247 expect(largePos <= largePosPlusOne, true); | 247 expect(largePos <= largePosPlusOne, true); |
| 248 expect(largePos <= largePos, true); | 248 expect(largePos <= largePos, true); |
| 249 expect(largePosPlusOne <= largePos, false); | 249 expect(largePosPlusOne <= largePos, false); |
| 250 expect(int64.MIN_VALUE <= int64.MAX_VALUE, true); | 250 expect(Int64.MIN_VALUE <= Int64.MAX_VALUE, true); |
| 251 expect(int64.MAX_VALUE <= int64.MIN_VALUE, false); | 251 expect(Int64.MAX_VALUE <= Int64.MIN_VALUE, false); |
| 252 expect(() => new int64.fromInt(17) <= null, throwsArgumentError); | 252 expect(() => new Int64.fromInt(17) <= null, throwsArgumentError); |
| 253 }); | 253 }); |
| 254 | 254 |
| 255 test("==", () { | 255 test("==", () { |
| 256 expect(new int64.fromInt(10) == new int64.fromInt(11), false); | 256 expect(new Int64.fromInt(10) == new Int64.fromInt(11), false); |
| 257 expect(new int64.fromInt(10) == new int64.fromInt(10), true); | 257 expect(new Int64.fromInt(10) == new Int64.fromInt(10), true); |
| 258 expect(new int64.fromInt(10) == new int64.fromInt(9), false); | 258 expect(new Int64.fromInt(10) == new Int64.fromInt(9), false); |
| 259 expect(new int64.fromInt(10) == new int32.fromInt(11), false); | 259 expect(new Int64.fromInt(10) == new Int32.fromInt(11), false); |
| 260 expect(new int64.fromInt(10) == new int32.fromInt(10), true); | 260 expect(new Int64.fromInt(10) == new Int32.fromInt(10), true); |
| 261 expect(new int64.fromInt(10) == new int32.fromInt(9), false); | 261 expect(new Int64.fromInt(10) == new Int32.fromInt(9), false); |
| 262 expect(new int64.fromInt(-10) == new int64.fromInt(-10), true); | 262 expect(new Int64.fromInt(-10) == new Int64.fromInt(-10), true); |
| 263 expect(new int64.fromInt(-10) != new int64.fromInt(-10), false); | 263 expect(new Int64.fromInt(-10) != new Int64.fromInt(-10), false); |
| 264 expect(largePos == largePos, true); | 264 expect(largePos == largePos, true); |
| 265 expect(largePos == largePosPlusOne, false); | 265 expect(largePos == largePosPlusOne, false); |
| 266 expect(largePosPlusOne == largePos, false); | 266 expect(largePosPlusOne == largePos, false); |
| 267 expect(int64.MIN_VALUE == int64.MAX_VALUE, false); | 267 expect(Int64.MIN_VALUE == Int64.MAX_VALUE, false); |
| 268 expect(new int64.fromInt(17) == new Object(), false); | 268 expect(new Int64.fromInt(17) == new Object(), false); |
| 269 expect(new int64.fromInt(17) == null, false); | 269 expect(new Int64.fromInt(17) == null, false); |
| 270 }); | 270 }); |
| 271 | 271 |
| 272 test(">=", () { | 272 test(">=", () { |
| 273 expect(new int64.fromInt(10) >= new int64.fromInt(11), false); | 273 expect(new Int64.fromInt(10) >= new Int64.fromInt(11), false); |
| 274 expect(new int64.fromInt(10) >= new int64.fromInt(10), true); | 274 expect(new Int64.fromInt(10) >= new Int64.fromInt(10), true); |
| 275 expect(new int64.fromInt(10) >= new int64.fromInt(9), true); | 275 expect(new Int64.fromInt(10) >= new Int64.fromInt(9), true); |
| 276 expect(new int64.fromInt(10) >= new int32.fromInt(11), false); | 276 expect(new Int64.fromInt(10) >= new Int32.fromInt(11), false); |
| 277 expect(new int64.fromInt(10) >= new int32.fromInt(10), true); | 277 expect(new Int64.fromInt(10) >= new Int32.fromInt(10), true); |
| 278 expect(new int64.fromInt(10) >= new int32.fromInt(9), true); | 278 expect(new Int64.fromInt(10) >= new Int32.fromInt(9), true); |
| 279 expect(new int64.fromInt(-10) >= new int64.fromInt(-11), true); | 279 expect(new Int64.fromInt(-10) >= new Int64.fromInt(-11), true); |
| 280 expect(new int64.fromInt(-10) >= new int64.fromInt(-10), true); | 280 expect(new Int64.fromInt(-10) >= new Int64.fromInt(-10), true); |
| 281 expect(largePos >= largeNeg, true); | 281 expect(largePos >= largeNeg, true); |
| 282 expect(largeNeg >= largePos, false); | 282 expect(largeNeg >= largePos, false); |
| 283 expect(largePos >= largePosPlusOne, false); | 283 expect(largePos >= largePosPlusOne, false); |
| 284 expect(largePos >= largePos, true); | 284 expect(largePos >= largePos, true); |
| 285 expect(largePosPlusOne >= largePos, true); | 285 expect(largePosPlusOne >= largePos, true); |
| 286 expect(int64.MIN_VALUE >= int64.MAX_VALUE, false); | 286 expect(Int64.MIN_VALUE >= Int64.MAX_VALUE, false); |
| 287 expect(int64.MAX_VALUE >= int64.MIN_VALUE, true); | 287 expect(Int64.MAX_VALUE >= Int64.MIN_VALUE, true); |
| 288 expect(() => new int64.fromInt(17) >= null, throwsArgumentError); | 288 expect(() => new Int64.fromInt(17) >= null, throwsArgumentError); |
| 289 }); | 289 }); |
| 290 | 290 |
| 291 test(">", () { | 291 test(">", () { |
| 292 expect(new int64.fromInt(10) > new int64.fromInt(11), false); | 292 expect(new Int64.fromInt(10) > new Int64.fromInt(11), false); |
| 293 expect(new int64.fromInt(10) > new int64.fromInt(10), false); | 293 expect(new Int64.fromInt(10) > new Int64.fromInt(10), false); |
| 294 expect(new int64.fromInt(10) > new int64.fromInt(9), true); | 294 expect(new Int64.fromInt(10) > new Int64.fromInt(9), true); |
| 295 expect(new int64.fromInt(10) > new int32.fromInt(11), false); | 295 expect(new Int64.fromInt(10) > new Int32.fromInt(11), false); |
| 296 expect(new int64.fromInt(10) > new int32.fromInt(10), false); | 296 expect(new Int64.fromInt(10) > new Int32.fromInt(10), false); |
| 297 expect(new int64.fromInt(10) > new int32.fromInt(9), true); | 297 expect(new Int64.fromInt(10) > new Int32.fromInt(9), true); |
| 298 expect(new int64.fromInt(-10) > new int64.fromInt(-11), true); | 298 expect(new Int64.fromInt(-10) > new Int64.fromInt(-11), true); |
| 299 expect(new int64.fromInt(10) > new int64.fromInt(-11), true); | 299 expect(new Int64.fromInt(10) > new Int64.fromInt(-11), true); |
| 300 expect(new int64.fromInt(-10) > new int64.fromInt(11), false); | 300 expect(new Int64.fromInt(-10) > new Int64.fromInt(11), false); |
| 301 expect(largePos > largeNeg, true); | 301 expect(largePos > largeNeg, true); |
| 302 expect(largeNeg > largePos, false); | 302 expect(largeNeg > largePos, false); |
| 303 expect(largePos > largePosPlusOne, false); | 303 expect(largePos > largePosPlusOne, false); |
| 304 expect(largePos > largePos, false); | 304 expect(largePos > largePos, false); |
| 305 expect(largePosPlusOne > largePos, true); | 305 expect(largePosPlusOne > largePos, true); |
| 306 expect(new int64.fromInt(0) > int64.MIN_VALUE, true); | 306 expect(new Int64.fromInt(0) > Int64.MIN_VALUE, true); |
| 307 expect(int64.MIN_VALUE > int64.MAX_VALUE, false); | 307 expect(Int64.MIN_VALUE > Int64.MAX_VALUE, false); |
| 308 expect(int64.MAX_VALUE > int64.MIN_VALUE, true); | 308 expect(Int64.MAX_VALUE > Int64.MIN_VALUE, true); |
| 309 expect(() => new int64.fromInt(17) > null, throwsArgumentError); | 309 expect(() => new Int64.fromInt(17) > null, throwsArgumentError); |
| 310 }); | 310 }); |
| 311 }); | 311 }); |
| 312 | 312 |
| 313 group("bitwise operators", () { | 313 group("bitwise operators", () { |
| 314 int64 n1 = new int64.fromInt(1234); | 314 Int64 n1 = new Int64.fromInt(1234); |
| 315 int64 n2 = new int64.fromInt(9876); | 315 Int64 n2 = new Int64.fromInt(9876); |
| 316 int64 n3 = new int64.fromInt(-1234); | 316 Int64 n3 = new Int64.fromInt(-1234); |
| 317 int64 n4 = new int64.fromInt(0x1234) << 32; | 317 Int64 n4 = new Int64.fromInt(0x1234) << 32; |
| 318 int64 n5 = new int64.fromInt(0x9876) << 32; | 318 Int64 n5 = new Int64.fromInt(0x9876) << 32; |
| 319 | 319 |
| 320 test("&", () { | 320 test("&", () { |
| 321 expect(n1 & n2, new int64.fromInt(1168)); | 321 expect(n1 & n2, new Int64.fromInt(1168)); |
| 322 expect(n3 & n2, new int64.fromInt(8708)); | 322 expect(n3 & n2, new Int64.fromInt(8708)); |
| 323 expect(n4 & n5, new int64.fromInt(0x1034) << 32); | 323 expect(n4 & n5, new Int64.fromInt(0x1034) << 32); |
| 324 expect(() => n1 & null, throwsArgumentError); | 324 expect(() => n1 & null, throwsArgumentError); |
| 325 }); | 325 }); |
| 326 | 326 |
| 327 test("|", () { | 327 test("|", () { |
| 328 expect(n1 | n2, new int64.fromInt(9942)); | 328 expect(n1 | n2, new Int64.fromInt(9942)); |
| 329 expect(n3 | n2, new int64.fromInt(-66)); | 329 expect(n3 | n2, new Int64.fromInt(-66)); |
| 330 expect(n4 | n5, new int64.fromInt(0x9a76) << 32); | 330 expect(n4 | n5, new Int64.fromInt(0x9a76) << 32); |
| 331 expect(() => n1 | null, throwsArgumentError); | 331 expect(() => n1 | null, throwsArgumentError); |
| 332 }); | 332 }); |
| 333 | 333 |
| 334 test("^", () { | 334 test("^", () { |
| 335 expect(n1 ^ n2, new int64.fromInt(8774)); | 335 expect(n1 ^ n2, new Int64.fromInt(8774)); |
| 336 expect(n3 ^ n2, new int64.fromInt(-8774)); | 336 expect(n3 ^ n2, new Int64.fromInt(-8774)); |
| 337 expect(n4 ^ n5, new int64.fromInt(0x8a42) << 32); | 337 expect(n4 ^ n5, new Int64.fromInt(0x8a42) << 32); |
| 338 expect(() => n1 ^ null, throwsArgumentError); | 338 expect(() => n1 ^ null, throwsArgumentError); |
| 339 }); | 339 }); |
| 340 | 340 |
| 341 test("~", () { | 341 test("~", () { |
| 342 expect(-new int64.fromInt(1), new int64.fromInt(-1)); | 342 expect(-new Int64.fromInt(1), new Int64.fromInt(-1)); |
| 343 expect(-new int64.fromInt(-1), new int64.fromInt(1)); | 343 expect(-new Int64.fromInt(-1), new Int64.fromInt(1)); |
| 344 expect(-int64.MIN_VALUE, int64.MIN_VALUE); | 344 expect(-Int64.MIN_VALUE, Int64.MIN_VALUE); |
| 345 | 345 |
| 346 expect(~n1, new int64.fromInt(-1235)); | 346 expect(~n1, new Int64.fromInt(-1235)); |
| 347 expect(~n2, new int64.fromInt(-9877)); | 347 expect(~n2, new Int64.fromInt(-9877)); |
| 348 expect(~n3, new int64.fromInt(1233)); | 348 expect(~n3, new Int64.fromInt(1233)); |
| 349 expect(~n4, new int64.fromInts(0xffffedcb, 0xffffffff)); | 349 expect(~n4, new Int64.fromInts(0xffffedcb, 0xffffffff)); |
| 350 expect(~n5, new int64.fromInts(0xffff6789, 0xffffffff)); | 350 expect(~n5, new Int64.fromInts(0xffff6789, 0xffffffff)); |
| 351 }); | 351 }); |
| 352 }); | 352 }); |
| 353 | 353 |
| 354 group("bitshift operators", () { | 354 group("bitshift operators", () { |
| 355 test("<<", () { | 355 test("<<", () { |
| 356 expect(new int64.fromInts(0x12341234, 0x45674567) << 10, | 356 expect(new Int64.fromInts(0x12341234, 0x45674567) << 10, |
| 357 new int64.fromInts(0xd048d115, 0x9d159c00)); | 357 new Int64.fromInts(0xd048d115, 0x9d159c00)); |
| 358 expect(new int64.fromInts(0x92341234, 0x45674567) << 10, | 358 expect(new Int64.fromInts(0x92341234, 0x45674567) << 10, |
| 359 new int64.fromInts(0xd048d115, 0x9d159c00)); | 359 new Int64.fromInts(0xd048d115, 0x9d159c00)); |
| 360 expect(new int64.fromInt(-1) << 5, new int64.fromInt(-32)); | 360 expect(new Int64.fromInt(-1) << 5, new Int64.fromInt(-32)); |
| 361 expect(new int64.fromInt(-1) << 0, new int64.fromInt(-1)); | 361 expect(new Int64.fromInt(-1) << 0, new Int64.fromInt(-1)); |
| 362 expect(() => new int64.fromInt(17) << -1, throwsArgumentError); | 362 expect(() => new Int64.fromInt(17) << -1, throwsArgumentError); |
| 363 expect(() => new int64.fromInt(17) << null, throws); | 363 expect(() => new Int64.fromInt(17) << null, throws); |
| 364 }); | 364 }); |
| 365 | 365 |
| 366 test(">>", () { | 366 test(">>", () { |
| 367 expect((int64.MIN_VALUE >> 13).toString(), "-1125899906842624"); | 367 expect((Int64.MIN_VALUE >> 13).toString(), "-1125899906842624"); |
| 368 expect(new int64.fromInts(0x12341234, 0x45674567) >> 10, | 368 expect(new Int64.fromInts(0x12341234, 0x45674567) >> 10, |
| 369 new int64.fromInts(0x48d04, 0x8d1159d1)); | 369 new Int64.fromInts(0x48d04, 0x8d1159d1)); |
| 370 expect(new int64.fromInts(0x92341234, 0x45674567) >> 10, | 370 expect(new Int64.fromInts(0x92341234, 0x45674567) >> 10, |
| 371 new int64.fromInts(0xffe48d04, 0x8d1159d1)); | 371 new Int64.fromInts(0xffe48d04, 0x8d1159d1)); |
| 372 expect(new int64.fromInts(0xFFFFFFF, 0xFFFFFFFF) >> 34, | 372 expect(new Int64.fromInts(0xFFFFFFF, 0xFFFFFFFF) >> 34, |
| 373 new int64.fromInt(67108863)); | 373 new Int64.fromInt(67108863)); |
| 374 for (int n = 0; n <= 66; n++) { | 374 for (int n = 0; n <= 66; n++) { |
| 375 expect(new int64.fromInt(-1) >> n, new int64.fromInt(-1)); | 375 expect(new Int64.fromInt(-1) >> n, new Int64.fromInt(-1)); |
| 376 } | 376 } |
| 377 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 8, | 377 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 8, |
| 378 new int64.fromInts(0x00723456, 0x789abcde)); | 378 new Int64.fromInts(0x00723456, 0x789abcde)); |
| 379 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 16, | 379 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 16, |
| 380 new int64.fromInts(0x00007234, 0x56789abc)); | 380 new Int64.fromInts(0x00007234, 0x56789abc)); |
| 381 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 24, | 381 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 24, |
| 382 new int64.fromInts(0x00000072, 0x3456789a)); | 382 new Int64.fromInts(0x00000072, 0x3456789a)); |
| 383 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 28, | 383 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 28, |
| 384 new int64.fromInts(0x00000007, 0x23456789)); | 384 new Int64.fromInts(0x00000007, 0x23456789)); |
| 385 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 32, | 385 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 32, |
| 386 new int64.fromInts(0x00000000, 0x72345678)); | 386 new Int64.fromInts(0x00000000, 0x72345678)); |
| 387 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 36, | 387 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 36, |
| 388 new int64.fromInts(0x00000000, 0x07234567)); | 388 new Int64.fromInts(0x00000000, 0x07234567)); |
| 389 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 40, | 389 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 40, |
| 390 new int64.fromInts(0x00000000, 0x00723456)); | 390 new Int64.fromInts(0x00000000, 0x00723456)); |
| 391 expect(new int64.fromInts(0x72345678, 0x9abcde00) >> 44, | 391 expect(new Int64.fromInts(0x72345678, 0x9abcde00) >> 44, |
| 392 new int64.fromInts(0x00000000, 0x00072345)); | 392 new Int64.fromInts(0x00000000, 0x00072345)); |
| 393 expect(new int64.fromInts(0x72345678, 0x9abcdef0) >> 48, | 393 expect(new Int64.fromInts(0x72345678, 0x9abcdef0) >> 48, |
| 394 new int64.fromInts(0x00000000, 0x00007234)); | 394 new Int64.fromInts(0x00000000, 0x00007234)); |
| 395 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 8, | 395 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 8, |
| 396 new int64.fromInts(0xff923456, 0x789abcde)); | 396 new Int64.fromInts(0xff923456, 0x789abcde)); |
| 397 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 16, | 397 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 16, |
| 398 new int64.fromInts(0xffff9234, 0x56789abc)); | 398 new Int64.fromInts(0xffff9234, 0x56789abc)); |
| 399 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 24, | 399 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 24, |
| 400 new int64.fromInts(0xffffff92, 0x3456789a)); | 400 new Int64.fromInts(0xffffff92, 0x3456789a)); |
| 401 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 28, | 401 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 28, |
| 402 new int64.fromInts(0xfffffff9, 0x23456789)); | 402 new Int64.fromInts(0xfffffff9, 0x23456789)); |
| 403 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 32, | 403 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 32, |
| 404 new int64.fromInts(0xffffffff, 0x92345678)); | 404 new Int64.fromInts(0xffffffff, 0x92345678)); |
| 405 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 36, | 405 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 36, |
| 406 new int64.fromInts(0xffffffff, 0xf9234567)); | 406 new Int64.fromInts(0xffffffff, 0xf9234567)); |
| 407 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 40, | 407 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 40, |
| 408 new int64.fromInts(0xffffffff, 0xff923456)); | 408 new Int64.fromInts(0xffffffff, 0xff923456)); |
| 409 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 44, | 409 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 44, |
| 410 new int64.fromInts(0xffffffff, 0xfff92345)); | 410 new Int64.fromInts(0xffffffff, 0xfff92345)); |
| 411 expect(new int64.fromInts(0x92345678, 0x9abcdef0) >> 48, | 411 expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 48, |
| 412 new int64.fromInts(0xffffffff, 0xffff9234)); | 412 new Int64.fromInts(0xffffffff, 0xffff9234)); |
| 413 expect(() => new int64.fromInt(17) >> -1, throwsArgumentError); | 413 expect(() => new Int64.fromInt(17) >> -1, throwsArgumentError); |
| 414 expect(() => new int64.fromInt(17) >> null, throws); | 414 expect(() => new Int64.fromInt(17) >> null, throws); |
| 415 }); | 415 }); |
| 416 | 416 |
| 417 test("shiftRightUnsigned", () { | 417 test("shiftRightUnsigned", () { |
| 418 expect(new int64.fromInts(0x12341234, 0x45674567).shiftRightUnsigned(10), | 418 expect(new Int64.fromInts(0x12341234, 0x45674567).shiftRightUnsigned(10), |
| 419 new int64.fromInts(0x48d04, 0x8d1159d1)); | 419 new Int64.fromInts(0x48d04, 0x8d1159d1)); |
| 420 expect(new int64.fromInts(0x92341234, 0x45674567).shiftRightUnsigned(10), | 420 expect(new Int64.fromInts(0x92341234, 0x45674567).shiftRightUnsigned(10), |
| 421 new int64.fromInts(0x248d04, 0x8d1159d1)); | 421 new Int64.fromInts(0x248d04, 0x8d1159d1)); |
| 422 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(8), | 422 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(8), |
| 423 new int64.fromInts(0x00723456, 0x789abcde)); | 423 new Int64.fromInts(0x00723456, 0x789abcde)); |
| 424 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(16), | 424 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(16), |
| 425 new int64.fromInts(0x00007234, 0x56789abc)); | 425 new Int64.fromInts(0x00007234, 0x56789abc)); |
| 426 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(24), | 426 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(24), |
| 427 new int64.fromInts(0x00000072, 0x3456789a)); | 427 new Int64.fromInts(0x00000072, 0x3456789a)); |
| 428 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(28), | 428 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(28), |
| 429 new int64.fromInts(0x00000007, 0x23456789)); | 429 new Int64.fromInts(0x00000007, 0x23456789)); |
| 430 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(32), | 430 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(32), |
| 431 new int64.fromInts(0x00000000, 0x72345678)); | 431 new Int64.fromInts(0x00000000, 0x72345678)); |
| 432 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(36), | 432 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(36), |
| 433 new int64.fromInts(0x00000000, 0x07234567)); | 433 new Int64.fromInts(0x00000000, 0x07234567)); |
| 434 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(40), | 434 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(40), |
| 435 new int64.fromInts(0x00000000, 0x00723456)); | 435 new Int64.fromInts(0x00000000, 0x00723456)); |
| 436 expect(new int64.fromInts(0x72345678, 0x9abcde00).shiftRightUnsigned(44), | 436 expect(new Int64.fromInts(0x72345678, 0x9abcde00).shiftRightUnsigned(44), |
| 437 new int64.fromInts(0x00000000, 0x00072345)); | 437 new Int64.fromInts(0x00000000, 0x00072345)); |
| 438 expect(new int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(48), | 438 expect(new Int64.fromInts(0x72345678, 0x9abcdef0).shiftRightUnsigned(48), |
| 439 new int64.fromInts(0x00000000, 0x00007234)); | 439 new Int64.fromInts(0x00000000, 0x00007234)); |
| 440 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(8), | 440 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(8), |
| 441 new int64.fromInts(0x00923456, 0x789abcde)); | 441 new Int64.fromInts(0x00923456, 0x789abcde)); |
| 442 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(16), | 442 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(16), |
| 443 new int64.fromInts(0x00009234, 0x56789abc)); | 443 new Int64.fromInts(0x00009234, 0x56789abc)); |
| 444 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(24), | 444 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(24), |
| 445 new int64.fromInts(0x00000092, 0x3456789a)); | 445 new Int64.fromInts(0x00000092, 0x3456789a)); |
| 446 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(28), | 446 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(28), |
| 447 new int64.fromInts(0x00000009, 0x23456789)); | 447 new Int64.fromInts(0x00000009, 0x23456789)); |
| 448 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(32), | 448 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(32), |
| 449 new int64.fromInts(0x00000000, 0x92345678)); | 449 new Int64.fromInts(0x00000000, 0x92345678)); |
| 450 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(36), | 450 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(36), |
| 451 new int64.fromInts(0x00000000, 0x09234567)); | 451 new Int64.fromInts(0x00000000, 0x09234567)); |
| 452 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(40), | 452 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(40), |
| 453 new int64.fromInts(0x00000000, 0x00923456)); | 453 new Int64.fromInts(0x00000000, 0x00923456)); |
| 454 expect(new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(44), | 454 expect(new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(44), |
| 455 new int64.fromInts(0x00000000, 0x00092345)); | 455 new Int64.fromInts(0x00000000, 0x00092345)); |
| 456 expect(new int64.fromInts(0x00000000, 0x00009234), | 456 expect(new Int64.fromInts(0x00000000, 0x00009234), |
| 457 new int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(48)); | 457 new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(48)); |
| 458 expect(() => new int64.fromInt(17).shiftRightUnsigned(-1), | 458 expect(() => new Int64.fromInt(17).shiftRightUnsigned(-1), |
| 459 throwsArgumentError); | 459 throwsArgumentError); |
| 460 expect(() => new int64.fromInt(17).shiftRightUnsigned(null), throws); | 460 expect(() => new Int64.fromInt(17).shiftRightUnsigned(null), throws); |
| 461 }); | 461 }); |
| 462 | 462 |
| 463 test("overflow", () { | 463 test("overflow", () { |
| 464 expect((new int64.fromInt(1) << 63) >> 1, | 464 expect((new Int64.fromInt(1) << 63) >> 1, |
| 465 -new int64.fromInts(0x40000000, 0x00000000)); | 465 -new Int64.fromInts(0x40000000, 0x00000000)); |
| 466 expect((new int64.fromInt(-1) << 32) << 32, new int64.fromInt(0)); | 466 expect((new Int64.fromInt(-1) << 32) << 32, new Int64.fromInt(0)); |
| 467 expect(int64.MIN_VALUE << 0, int64.MIN_VALUE); | 467 expect(Int64.MIN_VALUE << 0, Int64.MIN_VALUE); |
| 468 expect(int64.MIN_VALUE << 1, new int64.fromInt(0)); | 468 expect(Int64.MIN_VALUE << 1, new Int64.fromInt(0)); |
| 469 expect((-new int64.fromInts(8, 0)) >> 1, | 469 expect((-new Int64.fromInts(8, 0)) >> 1, |
| 470 new int64.fromInts(0xfffffffc, 0x00000000)); | 470 new Int64.fromInts(0xfffffffc, 0x00000000)); |
| 471 expect((-new int64.fromInts(8, 0)).shiftRightUnsigned(1), | 471 expect((-new Int64.fromInts(8, 0)).shiftRightUnsigned(1), |
| 472 new int64.fromInts(0x7ffffffc, 0x0)); | 472 new Int64.fromInts(0x7ffffffc, 0x0)); |
| 473 }); | 473 }); |
| 474 }); | 474 }); |
| 475 | 475 |
| 476 group("type conversions", () { | 476 group("type conversions", () { |
| 477 test("toInt", () { | 477 test("toInt", () { |
| 478 expect(new int64.fromInt(0).toInt(), 0); | 478 expect(new Int64.fromInt(0).toInt(), 0); |
| 479 expect(new int64.fromInt(100).toInt(), 100); | 479 expect(new Int64.fromInt(100).toInt(), 100); |
| 480 expect(new int64.fromInt(-100).toInt(), -100); | 480 expect(new Int64.fromInt(-100).toInt(), -100); |
| 481 expect(new int64.fromInt(2147483647).toInt(), 2147483647); | 481 expect(new Int64.fromInt(2147483647).toInt(), 2147483647); |
| 482 expect(new int64.fromInt(2147483648).toInt(), 2147483648); | 482 expect(new Int64.fromInt(2147483648).toInt(), 2147483648); |
| 483 expect(new int64.fromInt(-2147483647).toInt(), -2147483647); | 483 expect(new Int64.fromInt(-2147483647).toInt(), -2147483647); |
| 484 expect(new int64.fromInt(-2147483648).toInt(), -2147483648); | 484 expect(new Int64.fromInt(-2147483648).toInt(), -2147483648); |
| 485 expect(new int64.fromInt(4503599627370495).toInt(), 4503599627370495); | 485 expect(new Int64.fromInt(4503599627370495).toInt(), 4503599627370495); |
| 486 expect(new int64.fromInt(4503599627370496).toInt(), 4503599627370496); | 486 expect(new Int64.fromInt(4503599627370496).toInt(), 4503599627370496); |
| 487 expect(new int64.fromInt(-4503599627370495).toInt(), -4503599627370495); | 487 expect(new Int64.fromInt(-4503599627370495).toInt(), -4503599627370495); |
| 488 expect(new int64.fromInt(-4503599627370496).toInt(), -4503599627370496); | 488 expect(new Int64.fromInt(-4503599627370496).toInt(), -4503599627370496); |
| 489 }); | 489 }); |
| 490 | 490 |
| 491 test("toInt32", () { | 491 test("toInt32", () { |
| 492 expect(new int64.fromInt(0).toInt32(), new int32.fromInt(0)); | 492 expect(new Int64.fromInt(0).toInt32(), new Int32.fromInt(0)); |
| 493 expect(new int64.fromInt(1).toInt32(), new int32.fromInt(1)); | 493 expect(new Int64.fromInt(1).toInt32(), new Int32.fromInt(1)); |
| 494 expect(new int64.fromInt(-1).toInt32(), new int32.fromInt(-1)); | 494 expect(new Int64.fromInt(-1).toInt32(), new Int32.fromInt(-1)); |
| 495 expect(new int64.fromInt(2147483647).toInt32(), | 495 expect(new Int64.fromInt(2147483647).toInt32(), |
| 496 new int32.fromInt(2147483647)); | 496 new Int32.fromInt(2147483647)); |
| 497 expect(new int64.fromInt(2147483648).toInt32(), | 497 expect(new Int64.fromInt(2147483648).toInt32(), |
| 498 new int32.fromInt(-2147483648)); | 498 new Int32.fromInt(-2147483648)); |
| 499 expect(new int64.fromInt(2147483649).toInt32(), | 499 expect(new Int64.fromInt(2147483649).toInt32(), |
| 500 new int32.fromInt(-2147483647)); | 500 new Int32.fromInt(-2147483647)); |
| 501 expect(new int64.fromInt(2147483650).toInt32(), | 501 expect(new Int64.fromInt(2147483650).toInt32(), |
| 502 new int32.fromInt(-2147483646)); | 502 new Int32.fromInt(-2147483646)); |
| 503 expect(new int64.fromInt(-2147483648).toInt32(), | 503 expect(new Int64.fromInt(-2147483648).toInt32(), |
| 504 new int32.fromInt(-2147483648)); | 504 new Int32.fromInt(-2147483648)); |
| 505 expect(new int64.fromInt(-2147483649).toInt32(), | 505 expect(new Int64.fromInt(-2147483649).toInt32(), |
| 506 new int32.fromInt(2147483647)); | 506 new Int32.fromInt(2147483647)); |
| 507 expect(new int64.fromInt(-2147483650).toInt32(), | 507 expect(new Int64.fromInt(-2147483650).toInt32(), |
| 508 new int32.fromInt(2147483646)); | 508 new Int32.fromInt(2147483646)); |
| 509 expect(new int64.fromInt(-2147483651).toInt32(), | 509 expect(new Int64.fromInt(-2147483651).toInt32(), |
| 510 new int32.fromInt(2147483645)); | 510 new Int32.fromInt(2147483645)); |
| 511 }); | 511 }); |
| 512 }); | 512 }); |
| 513 | 513 |
| 514 test("JavaScript 53-bit integer boundary", () { | 514 test("JavaScript 53-bit integer boundary", () { |
| 515 int64 _factorial(int64 n) { | 515 Int64 _factorial(Int64 n) { |
| 516 if (n.isZero) { | 516 if (n.isZero) { |
| 517 return new int64.fromInt(1); | 517 return new Int64.fromInt(1); |
| 518 } else { | 518 } else { |
| 519 return n * _factorial(n - new int64.fromInt(1)); | 519 return n * _factorial(n - new Int64.fromInt(1)); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 int64 fact18 = _factorial(new int64.fromInt(18)); | 522 Int64 fact18 = _factorial(new Int64.fromInt(18)); |
| 523 int64 fact17 = _factorial(new int64.fromInt(17)); | 523 Int64 fact17 = _factorial(new Int64.fromInt(17)); |
| 524 expect(fact18 ~/ fact17, new int64.fromInt(18)); | 524 expect(fact18 ~/ fact17, new Int64.fromInt(18)); |
| 525 }); | 525 }); |
| 526 | 526 |
| 527 test("min, max values", () { | 527 test("min, max values", () { |
| 528 expect(new int64.fromInt(1) << 63, int64.MIN_VALUE); | 528 expect(new Int64.fromInt(1) << 63, Int64.MIN_VALUE); |
| 529 expect(-(int64.MIN_VALUE + new int64.fromInt(1)), int64.MAX_VALUE); | 529 expect(-(Int64.MIN_VALUE + new Int64.fromInt(1)), Int64.MAX_VALUE); |
| 530 }); | 530 }); |
| 531 | 531 |
| 532 group("string representation", () { | 532 group("string representation", () { |
| 533 test("toString", () { | 533 test("toString", () { |
| 534 expect(new int64.fromInt(0).toString(), "0"); | 534 expect(new Int64.fromInt(0).toString(), "0"); |
| 535 expect(new int64.fromInt(1).toString(), "1"); | 535 expect(new Int64.fromInt(1).toString(), "1"); |
| 536 expect(new int64.fromInt(-1).toString(), "-1"); | 536 expect(new Int64.fromInt(-1).toString(), "-1"); |
| 537 expect(new int64.fromInt(-10).toString(), "-10"); | 537 expect(new Int64.fromInt(-10).toString(), "-10"); |
| 538 expect(int64.MIN_VALUE.toString(), "-9223372036854775808"); | 538 expect(Int64.MIN_VALUE.toString(), "-9223372036854775808"); |
| 539 expect(int64.MAX_VALUE.toString(), "9223372036854775807"); | 539 expect(Int64.MAX_VALUE.toString(), "9223372036854775807"); |
| 540 | 540 |
| 541 int top = 922337201; | 541 int top = 922337201; |
| 542 int bottom = 967490662; | 542 int bottom = 967490662; |
| 543 int64 fullnum = (new int64.fromInt(1000000000) * new int64.fromInt(top)) + | 543 Int64 fullnum = (new Int64.fromInt(1000000000) * new Int64.fromInt(top)) + |
| 544 new int64.fromInt(bottom); | 544 new Int64.fromInt(bottom); |
| 545 expect(fullnum.toString(), "922337201967490662"); | 545 expect(fullnum.toString(), "922337201967490662"); |
| 546 expect((-fullnum).toString(), "-922337201967490662"); | 546 expect((-fullnum).toString(), "-922337201967490662"); |
| 547 expect(new int64.fromInt(123456789).toString(), "123456789"); | 547 expect(new Int64.fromInt(123456789).toString(), "123456789"); |
| 548 }); | 548 }); |
| 549 | 549 |
| 550 test("toHexString", () { | 550 test("toHexString", () { |
| 551 int64 deadbeef12341234 = new int64.fromInts(0xDEADBEEF, 0x12341234); | 551 Int64 deadbeef12341234 = new Int64.fromInts(0xDEADBEEF, 0x12341234); |
| 552 expect(int64.ZERO.toHexString(), "0"); | 552 expect(Int64.ZERO.toHexString(), "0"); |
| 553 expect(deadbeef12341234.toHexString(), "DEADBEEF12341234"); | 553 expect(deadbeef12341234.toHexString(), "DEADBEEF12341234"); |
| 554 expect(new int64.fromInts(0x17678A7, 0xDEF01234).toHexString(), | 554 expect(new Int64.fromInts(0x17678A7, 0xDEF01234).toHexString(), |
| 555 "17678A7DEF01234"); | 555 "17678A7DEF01234"); |
| 556 expect(new int64.fromInt(123456789).toHexString(), "75BCD15"); | 556 expect(new Int64.fromInt(123456789).toHexString(), "75BCD15"); |
| 557 }); | 557 }); |
| 558 | 558 |
| 559 test("toRadixString", () { | 559 test("toRadixString", () { |
| 560 expect(new int64.fromInt(123456789).toRadixString(5), "223101104124"); | 560 expect(new Int64.fromInt(123456789).toRadixString(5), "223101104124"); |
| 561 expect(int64.MIN_VALUE.toRadixString(2), | 561 expect(Int64.MIN_VALUE.toRadixString(2), |
| 562 "-1000000000000000000000000000000000000000000000000000000000000000"); | 562 "-1000000000000000000000000000000000000000000000000000000000000000"); |
| 563 expect(int64.MIN_VALUE.toRadixString(3), | 563 expect(Int64.MIN_VALUE.toRadixString(3), |
| 564 "-2021110011022210012102010021220101220222"); | 564 "-2021110011022210012102010021220101220222"); |
| 565 expect(int64.MIN_VALUE.toRadixString(4), | 565 expect(Int64.MIN_VALUE.toRadixString(4), |
| 566 "-20000000000000000000000000000000"); | 566 "-20000000000000000000000000000000"); |
| 567 expect(int64.MIN_VALUE.toRadixString(5), "-1104332401304422434310311213"); | 567 expect(Int64.MIN_VALUE.toRadixString(5), "-1104332401304422434310311213"); |
| 568 expect(int64.MIN_VALUE.toRadixString(6), "-1540241003031030222122212"); | 568 expect(Int64.MIN_VALUE.toRadixString(6), "-1540241003031030222122212"); |
| 569 expect(int64.MIN_VALUE.toRadixString(7), "-22341010611245052052301"); | 569 expect(Int64.MIN_VALUE.toRadixString(7), "-22341010611245052052301"); |
| 570 expect(int64.MIN_VALUE.toRadixString(8), "-1000000000000000000000"); | 570 expect(Int64.MIN_VALUE.toRadixString(8), "-1000000000000000000000"); |
| 571 expect(int64.MIN_VALUE.toRadixString(9), "-67404283172107811828"); | 571 expect(Int64.MIN_VALUE.toRadixString(9), "-67404283172107811828"); |
| 572 expect(int64.MIN_VALUE.toRadixString(10), "-9223372036854775808"); | 572 expect(Int64.MIN_VALUE.toRadixString(10), "-9223372036854775808"); |
| 573 expect(int64.MIN_VALUE.toRadixString(11), "-1728002635214590698"); | 573 expect(Int64.MIN_VALUE.toRadixString(11), "-1728002635214590698"); |
| 574 expect(int64.MIN_VALUE.toRadixString(12), "-41A792678515120368"); | 574 expect(Int64.MIN_VALUE.toRadixString(12), "-41A792678515120368"); |
| 575 expect(int64.MIN_VALUE.toRadixString(13), "-10B269549075433C38"); | 575 expect(Int64.MIN_VALUE.toRadixString(13), "-10B269549075433C38"); |
| 576 expect(int64.MIN_VALUE.toRadixString(14), "-4340724C6C71DC7A8"); | 576 expect(Int64.MIN_VALUE.toRadixString(14), "-4340724C6C71DC7A8"); |
| 577 expect(int64.MIN_VALUE.toRadixString(15), "-160E2AD3246366808"); | 577 expect(Int64.MIN_VALUE.toRadixString(15), "-160E2AD3246366808"); |
| 578 expect(int64.MIN_VALUE.toRadixString(16), "-8000000000000000"); | 578 expect(Int64.MIN_VALUE.toRadixString(16), "-8000000000000000"); |
| 579 expect(int64.MAX_VALUE.toRadixString(2), | 579 expect(Int64.MAX_VALUE.toRadixString(2), |
| 580 "111111111111111111111111111111111111111111111111111111111111111"); | 580 "111111111111111111111111111111111111111111111111111111111111111"); |
| 581 expect(int64.MAX_VALUE.toRadixString(3), | 581 expect(Int64.MAX_VALUE.toRadixString(3), |
| 582 "2021110011022210012102010021220101220221"); | 582 "2021110011022210012102010021220101220221"); |
| 583 expect(int64.MAX_VALUE.toRadixString(4), | 583 expect(Int64.MAX_VALUE.toRadixString(4), |
| 584 "13333333333333333333333333333333"); | 584 "13333333333333333333333333333333"); |
| 585 expect(int64.MAX_VALUE.toRadixString(5), "1104332401304422434310311212"); | 585 expect(Int64.MAX_VALUE.toRadixString(5), "1104332401304422434310311212"); |
| 586 expect(int64.MAX_VALUE.toRadixString(6), "1540241003031030222122211"); | 586 expect(Int64.MAX_VALUE.toRadixString(6), "1540241003031030222122211"); |
| 587 expect(int64.MAX_VALUE.toRadixString(7), "22341010611245052052300"); | 587 expect(Int64.MAX_VALUE.toRadixString(7), "22341010611245052052300"); |
| 588 expect(int64.MAX_VALUE.toRadixString(8), "777777777777777777777"); | 588 expect(Int64.MAX_VALUE.toRadixString(8), "777777777777777777777"); |
| 589 expect(int64.MAX_VALUE.toRadixString(9), "67404283172107811827"); | 589 expect(Int64.MAX_VALUE.toRadixString(9), "67404283172107811827"); |
| 590 expect(int64.MAX_VALUE.toRadixString(10), "9223372036854775807"); | 590 expect(Int64.MAX_VALUE.toRadixString(10), "9223372036854775807"); |
| 591 expect(int64.MAX_VALUE.toRadixString(11), "1728002635214590697"); | 591 expect(Int64.MAX_VALUE.toRadixString(11), "1728002635214590697"); |
| 592 expect(int64.MAX_VALUE.toRadixString(12), "41A792678515120367"); | 592 expect(Int64.MAX_VALUE.toRadixString(12), "41A792678515120367"); |
| 593 expect(int64.MAX_VALUE.toRadixString(13), "10B269549075433C37"); | 593 expect(Int64.MAX_VALUE.toRadixString(13), "10B269549075433C37"); |
| 594 expect(int64.MAX_VALUE.toRadixString(14), "4340724C6C71DC7A7"); | 594 expect(Int64.MAX_VALUE.toRadixString(14), "4340724C6C71DC7A7"); |
| 595 expect(int64.MAX_VALUE.toRadixString(15), "160E2AD3246366807"); | 595 expect(Int64.MAX_VALUE.toRadixString(15), "160E2AD3246366807"); |
| 596 expect(int64.MAX_VALUE.toRadixString(16), "7FFFFFFFFFFFFFFF"); | 596 expect(Int64.MAX_VALUE.toRadixString(16), "7FFFFFFFFFFFFFFF"); |
| 597 }); | 597 }); |
| 598 }); | 598 }); |
| 599 } | 599 } |
| OLD | NEW |