Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Side by Side Diff: pkg/fixnum/test/int_32_test.dart

Issue 24372002: Int32, Int64 default constructor now takes an optional int parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/fixnum/pubspec.yaml ('k') | pkg/fixnum/test/int_64_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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", () {
11 Int32 n1 = new Int32.fromInt(1234); 11 Int32 n1 = new Int32(1234);
12 Int32 n2 = new Int32.fromInt(9876); 12 Int32 n2 = new Int32(9876);
13 Int32 n3 = new Int32.fromInt(-1234); 13 Int32 n3 = new Int32(-1234);
14 Int32 n4 = new Int32.fromInt(-9876); 14 Int32 n4 = new Int32(-9876);
15 Int32 n5 = new Int32.fromInt(0x12345678); 15 Int32 n5 = new Int32(0x12345678);
16 Int32 n6 = new Int32.fromInt(0x22222222); 16 Int32 n6 = new Int32(0x22222222);
17 17
18 test("+", () { 18 test("+", () {
19 expect(n1 + n2, new Int32.fromInt(11110)); 19 expect(n1 + n2, new Int32(11110));
20 expect(n3 + n2, new Int32.fromInt(8642)); 20 expect(n3 + n2, new Int32(8642));
21 expect(n3 + n4, new Int32.fromInt(-11110)); 21 expect(n3 + n4, new Int32(-11110));
22 expect(Int32.MAX_VALUE + 1, Int32.MIN_VALUE); 22 expect(Int32.MAX_VALUE + 1, Int32.MIN_VALUE);
23 expect(() => new Int32.fromInt(17) + null, throws); 23 expect(() => new Int32(17) + null, throws);
24 }); 24 });
25 25
26 test("-", () { 26 test("-", () {
27 expect(n1 - n2, new Int32.fromInt(-8642)); 27 expect(n1 - n2, new Int32(-8642));
28 expect(n3 - n2, new Int32.fromInt(-11110)); 28 expect(n3 - n2, new Int32(-11110));
29 expect(n3 - n4, new Int32.fromInt(8642)); 29 expect(n3 - n4, new Int32(8642));
30 expect(Int32.MIN_VALUE - 1, Int32.MAX_VALUE); 30 expect(Int32.MIN_VALUE - 1, Int32.MAX_VALUE);
31 expect(() => new Int32.fromInt(17) - null, throws); 31 expect(() => new Int32(17) - null, throws);
32 }); 32 });
33 33
34 test("unary -", () { 34 test("unary -", () {
35 expect(-n1, new Int32.fromInt(-1234)); 35 expect(-n1, new Int32(-1234));
36 expect(-Int32.ZERO, Int32.ZERO); 36 expect(-Int32.ZERO, Int32.ZERO);
37 }); 37 });
38 38
39 test("*", () { 39 test("*", () {
40 expect(n1 * n2, new Int32.fromInt(12186984)); 40 expect(n1 * n2, new Int32(12186984));
41 expect(n2 * n3, new Int32.fromInt(-12186984)); 41 expect(n2 * n3, new Int32(-12186984));
42 expect(n3 * n3, new Int32.fromInt(1522756)); 42 expect(n3 * n3, new Int32(1522756));
43 expect(n3 * n2, new Int32.fromInt(-12186984)); 43 expect(n3 * n2, new Int32(-12186984));
44 expect(new Int32.fromInt(0x12345678) * new Int32.fromInt(0x22222222), 44 expect(new Int32(0x12345678) * new Int32(0x22222222),
45 new Int32.fromInt(-899716112)); 45 new Int32(-899716112));
46 expect((new Int32.fromInt(123456789) * new Int32.fromInt(987654321)), 46 expect((new Int32(123456789) * new Int32(987654321)),
47 new Int32.fromInt(-67153019)); 47 new Int32(-67153019));
48 expect(new Int32.fromInt(0x12345678) * new Int64.fromInt(0x22222222), 48 expect(new Int32(0x12345678) * new Int64(0x22222222),
49 new Int64.fromInts(0x026D60DC, 0xCA5F6BF0)); 49 new Int64.fromInts(0x026D60DC, 0xCA5F6BF0));
50 expect((new Int32.fromInt(123456789) * 987654321), 50 expect((new Int32(123456789) * 987654321),
51 new Int32.fromInt(-67153019)); 51 new Int32(-67153019));
52 expect(() => new Int32.fromInt(17) * null, throws); 52 expect(() => new Int32(17) * null, throws);
53 }); 53 });
54 54
55 test("~/", () { 55 test("~/", () {
56 expect(new Int32.fromInt(829893893) ~/ new Int32.fromInt(1919), 56 expect(new Int32(829893893) ~/ new Int32(1919), new Int32(432461));
57 new Int32.fromInt(432461)); 57 expect(new Int32(0x12345678) ~/ new Int32(0x22),
58 expect(new Int32.fromInt(0x12345678) ~/ new Int32.fromInt(0x22), 58 new Int32(0x12345678 ~/ 0x22));
59 new Int32.fromInt(0x12345678 ~/ 0x22)); 59 expect(new Int32(829893893) ~/ new Int64(1919), new Int32(432461));
60 expect(new Int32.fromInt(829893893) ~/ new Int64.fromInt(1919), 60 expect(new Int32(0x12345678) ~/ new Int64(0x22),
61 new Int32.fromInt(432461)); 61 new Int32(0x12345678 ~/ 0x22));
62 expect(new Int32.fromInt(0x12345678) ~/ new Int64.fromInt(0x22), 62 expect(new Int32(829893893) ~/ 1919, new Int32(432461));
63 new Int32.fromInt(0x12345678 ~/ 0x22)); 63 expect(() => new Int32(17) ~/ Int32.ZERO, throws);
64 expect(new Int32.fromInt(829893893) ~/ 1919, new Int32.fromInt(432461)); 64 expect(() => new Int32(17) ~/ null, throws);
65 expect(() => new Int32.fromInt(17) ~/ Int32.ZERO, throws);
66 expect(() => new Int32.fromInt(17) ~/ null, throws);
67 }); 65 });
68 66
69 test("%", () { 67 test("%", () {
70 expect(new Int32.fromInt(0x12345678) % new Int32.fromInt(0x22), 68 expect(new Int32(0x12345678) % new Int32(0x22),
71 new Int32.fromInt(0x12345678 % 0x22)); 69 new Int32(0x12345678 % 0x22));
72 expect(new Int32.fromInt(0x12345678) % new Int64.fromInt(0x22), 70 expect(new Int32(0x12345678) % new Int64(0x22),
73 new Int32.fromInt(0x12345678 % 0x22)); 71 new Int32(0x12345678 % 0x22));
74 expect(() => new Int32.fromInt(17) % null, throws); 72 expect(() => new Int32(17) % null, throws);
75 }); 73 });
76 74
77 test("remainder", () { 75 test("remainder", () {
78 expect(new Int32.fromInt(0x12345678).remainder(new Int32.fromInt(0x22)), 76 expect(new Int32(0x12345678).remainder(new Int32(0x22)),
79 new Int32.fromInt(0x12345678.remainder(0x22))); 77 new Int32(0x12345678.remainder(0x22)));
80 expect(new Int32.fromInt(0x12345678).remainder(new Int32.fromInt(-0x22)), 78 expect(new Int32(0x12345678).remainder(new Int32(-0x22)),
81 new Int32.fromInt(0x12345678.remainder(-0x22))); 79 new Int32(0x12345678.remainder(-0x22)));
82 expect(new Int32.fromInt(-0x12345678).remainder(new Int32.fromInt(-0x22)), 80 expect(new Int32(-0x12345678).remainder(new Int32(-0x22)),
83 new Int32.fromInt(-0x12345678.remainder(-0x22))); 81 new Int32(-0x12345678.remainder(-0x22)));
84 expect(new Int32.fromInt(-0x12345678).remainder(new Int32.fromInt(0x22)), 82 expect(new Int32(-0x12345678).remainder(new Int32(0x22)),
85 new Int32.fromInt(-0x12345678.remainder(0x22))); 83 new Int32(-0x12345678.remainder(0x22)));
86 expect(new Int32.fromInt(0x12345678).remainder(new Int64.fromInt(0x22)), 84 expect(new Int32(0x12345678).remainder(new Int64(0x22)),
87 new Int32.fromInt(0x12345678.remainder(0x22))); 85 new Int32(0x12345678.remainder(0x22)));
88 expect(() => new Int32.fromInt(17).remainder(null), throws); 86 expect(() => new Int32(17).remainder(null), throws);
89 }); 87 });
90 }); 88 });
91 89
92 group("comparison operators", () { 90 group("comparison operators", () {
93 test("<", () { 91 test("<", () {
94 expect(new Int32.fromInt(17) < new Int32.fromInt(18), true); 92 expect(new Int32(17) < new Int32(18), true);
95 expect(new Int32.fromInt(17) < new Int32.fromInt(17), false); 93 expect(new Int32(17) < new Int32(17), false);
96 expect(new Int32.fromInt(17) < new Int32.fromInt(16), false); 94 expect(new Int32(17) < new Int32(16), false);
97 expect(new Int32.fromInt(17) < new Int64.fromInt(18), true); 95 expect(new Int32(17) < new Int64(18), true);
98 expect(new Int32.fromInt(17) < new Int64.fromInt(17), false); 96 expect(new Int32(17) < new Int64(17), false);
99 expect(new Int32.fromInt(17) < new Int64.fromInt(16), false); 97 expect(new Int32(17) < new Int64(16), false);
100 expect(Int32.MIN_VALUE < Int32.MAX_VALUE, true); 98 expect(Int32.MIN_VALUE < Int32.MAX_VALUE, true);
101 expect(Int32.MAX_VALUE < Int32.MIN_VALUE, false); 99 expect(Int32.MAX_VALUE < Int32.MIN_VALUE, false);
102 expect(() => new Int32.fromInt(17) < null, throws); 100 expect(() => new Int32(17) < null, throws);
103 }); 101 });
104 102
105 test("<=", () { 103 test("<=", () {
106 expect(new Int32.fromInt(17) <= new Int32.fromInt(18), true); 104 expect(new Int32(17) <= new Int32(18), true);
107 expect(new Int32.fromInt(17) <= new Int32.fromInt(17), true); 105 expect(new Int32(17) <= new Int32(17), true);
108 expect(new Int32.fromInt(17) <= new Int32.fromInt(16), false); 106 expect(new Int32(17) <= new Int32(16), false);
109 expect(new Int32.fromInt(17) <= new Int64.fromInt(18), true); 107 expect(new Int32(17) <= new Int64(18), true);
110 expect(new Int32.fromInt(17) <= new Int64.fromInt(17), true); 108 expect(new Int32(17) <= new Int64(17), true);
111 expect(new Int32.fromInt(17) <= new Int64.fromInt(16), false); 109 expect(new Int32(17) <= new Int64(16), false);
112 expect(Int32.MIN_VALUE <= Int32.MAX_VALUE, true); 110 expect(Int32.MIN_VALUE <= Int32.MAX_VALUE, true);
113 expect(Int32.MAX_VALUE <= Int32.MIN_VALUE, false); 111 expect(Int32.MAX_VALUE <= Int32.MIN_VALUE, false);
114 expect(() => new Int32.fromInt(17) <= null, throws); 112 expect(() => new Int32(17) <= null, throws);
115 }); 113 });
116 114
117 test("==", () { 115 test("==", () {
118 expect(new Int32.fromInt(17) == new Int32.fromInt(18), false); 116 expect(new Int32(17) == new Int32(18), false);
119 expect(new Int32.fromInt(17) == new Int32.fromInt(17), true); 117 expect(new Int32(17) == new Int32(17), true);
120 expect(new Int32.fromInt(17) == new Int32.fromInt(16), false); 118 expect(new Int32(17) == new Int32(16), false);
121 expect(new Int32.fromInt(17) == new Int64.fromInt(18), false); 119 expect(new Int32(17) == new Int64(18), false);
122 expect(new Int32.fromInt(17) == new Int64.fromInt(17), true); 120 expect(new Int32(17) == new Int64(17), true);
123 expect(new Int32.fromInt(17) == new Int64.fromInt(16), false); 121 expect(new Int32(17) == new Int64(16), false);
124 expect(Int32.MIN_VALUE == Int32.MAX_VALUE, false); 122 expect(Int32.MIN_VALUE == Int32.MAX_VALUE, false);
125 expect(new Int32.fromInt(17) == new Object(), false); 123 expect(new Int32(17) == new Object(), false);
126 expect(new Int32.fromInt(17) == null, false); 124 expect(new Int32(17) == null, false);
127 }); 125 });
128 126
129 test(">=", () { 127 test(">=", () {
130 expect(new Int32.fromInt(17) >= new Int32.fromInt(18), false); 128 expect(new Int32(17) >= new Int32(18), false);
131 expect(new Int32.fromInt(17) >= new Int32.fromInt(17), true); 129 expect(new Int32(17) >= new Int32(17), true);
132 expect(new Int32.fromInt(17) >= new Int32.fromInt(16), true); 130 expect(new Int32(17) >= new Int32(16), true);
133 expect(new Int32.fromInt(17) >= new Int64.fromInt(18), false); 131 expect(new Int32(17) >= new Int64(18), false);
134 expect(new Int32.fromInt(17) >= new Int64.fromInt(17), true); 132 expect(new Int32(17) >= new Int64(17), true);
135 expect(new Int32.fromInt(17) >= new Int64.fromInt(16), true); 133 expect(new Int32(17) >= new Int64(16), true);
136 expect(Int32.MIN_VALUE >= Int32.MAX_VALUE, false); 134 expect(Int32.MIN_VALUE >= Int32.MAX_VALUE, false);
137 expect(Int32.MAX_VALUE >= Int32.MIN_VALUE, true); 135 expect(Int32.MAX_VALUE >= Int32.MIN_VALUE, true);
138 expect(() => new Int32.fromInt(17) >= null, throws); 136 expect(() => new Int32(17) >= null, throws);
139 }); 137 });
140 138
141 test(">", () { 139 test(">", () {
142 expect(new Int32.fromInt(17) > new Int32.fromInt(18), false); 140 expect(new Int32(17) > new Int32(18), false);
143 expect(new Int32.fromInt(17) > new Int32.fromInt(17), false); 141 expect(new Int32(17) > new Int32(17), false);
144 expect(new Int32.fromInt(17) > new Int32.fromInt(16), true); 142 expect(new Int32(17) > new Int32(16), true);
145 expect(new Int32.fromInt(17) > new Int64.fromInt(18), false); 143 expect(new Int32(17) > new Int64(18), false);
146 expect(new Int32.fromInt(17) > new Int64.fromInt(17), false); 144 expect(new Int32(17) > new Int64(17), false);
147 expect(new Int32.fromInt(17) > new Int64.fromInt(16), true); 145 expect(new Int32(17) > new Int64(16), true);
148 expect(Int32.MIN_VALUE > Int32.MAX_VALUE, false); 146 expect(Int32.MIN_VALUE > Int32.MAX_VALUE, false);
149 expect(Int32.MAX_VALUE > Int32.MIN_VALUE, true); 147 expect(Int32.MAX_VALUE > Int32.MIN_VALUE, true);
150 expect(() => new Int32.fromInt(17) > null, throws); 148 expect(() => new Int32(17) > null, throws);
151 }); 149 });
152 }); 150 });
153 151
154 group("bitwise operators", () { 152 group("bitwise operators", () {
155 test("&", () { 153 test("&", () {
156 expect(new Int32.fromInt(0x12345678) & new Int32.fromInt(0x22222222), 154 expect(new Int32(0x12345678) & new Int32(0x22222222),
157 new Int32.fromInt(0x12345678 & 0x22222222)); 155 new Int32(0x12345678 & 0x22222222));
158 expect(new Int32.fromInt(0x12345678) & new Int64.fromInt(0x22222222), 156 expect(new Int32(0x12345678) & new Int64(0x22222222),
159 new Int64.fromInt(0x12345678 & 0x22222222)); 157 new Int64(0x12345678 & 0x22222222));
160 expect(() => new Int32.fromInt(17) & null, throwsArgumentError); 158 expect(() => new Int32(17) & null, throwsArgumentError);
161 }); 159 });
162 160
163 test("|", () { 161 test("|", () {
164 expect(new Int32.fromInt(0x12345678) | new Int32.fromInt(0x22222222), 162 expect(new Int32(0x12345678) | new Int32(0x22222222),
165 new Int32.fromInt(0x12345678 | 0x22222222)); 163 new Int32(0x12345678 | 0x22222222));
166 expect(new Int32.fromInt(0x12345678) | new Int64.fromInt(0x22222222), 164 expect(new Int32(0x12345678) | new Int64(0x22222222),
167 new Int64.fromInt(0x12345678 | 0x22222222)); 165 new Int64(0x12345678 | 0x22222222));
168 expect(() => new Int32.fromInt(17) | null, throws); 166 expect(() => new Int32(17) | null, throws);
169 }); 167 });
170 168
171 test("^", () { 169 test("^", () {
172 expect(new Int32.fromInt(0x12345678) ^ new Int32.fromInt(0x22222222), 170 expect(new Int32(0x12345678) ^ new Int32(0x22222222),
173 new Int32.fromInt(0x12345678 ^ 0x22222222)); 171 new Int32(0x12345678 ^ 0x22222222));
174 expect(new Int32.fromInt(0x12345678) ^ new Int64.fromInt(0x22222222), 172 expect(new Int32(0x12345678) ^ new Int64(0x22222222),
175 new Int64.fromInt(0x12345678 ^ 0x22222222)); 173 new Int64(0x12345678 ^ 0x22222222));
176 expect(() => new Int32.fromInt(17) ^ null, throws); 174 expect(() => new Int32(17) ^ null, throws);
177 }); 175 });
178 176
179 test("~", () { 177 test("~", () {
180 expect(~(new Int32.fromInt(0x12345678)), new Int32.fromInt(~0x12345678)); 178 expect(~(new Int32(0x12345678)), new Int32(~0x12345678));
181 expect(-(new Int32.fromInt(0x12345678)), new Int64.fromInt(-0x12345678)); 179 expect(-(new Int32(0x12345678)), new Int64(-0x12345678));
182 }); 180 });
183 }); 181 });
184 182
185 group("bitshift operators", () { 183 group("bitshift operators", () {
186 test("<<", () { 184 test("<<", () {
187 expect(new Int32.fromInt(0x12345678) << 7, 185 expect(new Int32(0x12345678) << 7, new Int32(0x12345678 << 7));
188 new Int32.fromInt(0x12345678 << 7)); 186 expect(() => new Int32(17) << -1, throwsArgumentError);
189 expect(() => new Int32.fromInt(17) << -1, throwsArgumentError); 187 expect(() => new Int32(17) << null, throws);
190 expect(() => new Int32.fromInt(17) << null, throws);
191 }); 188 });
192 189
193 test(">>", () { 190 test(">>", () {
194 expect(new Int32.fromInt(0x12345678) >> 7, 191 expect(new Int32(0x12345678) >> 7, new Int32(0x12345678 >> 7));
195 new Int32.fromInt(0x12345678 >> 7)); 192 expect(() => new Int32(17) >> -1, throwsArgumentError);
196 expect(() => new Int32.fromInt(17) >> -1, throwsArgumentError); 193 expect(() => new Int32(17) >> null, throws);
197 expect(() => new Int32.fromInt(17) >> null, throws);
198 }); 194 });
199 195
200 test("shiftRightUnsigned", () { 196 test("shiftRightUnsigned", () {
201 expect(new Int32.fromInt(0x12345678).shiftRightUnsigned(7), 197 expect(new Int32(0x12345678).shiftRightUnsigned(7),
202 new Int32.fromInt(0x12345678 >> 7)); 198 new Int32(0x12345678 >> 7));
203 expect(() => (new Int32.fromInt(17).shiftRightUnsigned(-1)), 199 expect(() => (new Int32(17).shiftRightUnsigned(-1)), throwsArgumentError);
204 throwsArgumentError); 200 expect(() => (new Int32(17).shiftRightUnsigned(null)), throws);
205 expect(() => (new Int32.fromInt(17).shiftRightUnsigned(null)), throws);
206 }); 201 });
207 }); 202 });
208 203
209 group("type conversions", () { 204 group("type conversions", () {
210 expect(new Int32.fromInt(17).toInt(), 17); 205 expect(new Int32(17).toInt(), 17);
211 expect(new Int32.fromInt(-17).toInt(), -17); 206 expect(new Int32(-17).toInt(), -17);
212 expect(new Int32.fromInt(17).toInt32(), new Int32.fromInt(17)); 207 expect(new Int32(17).toInt32(), new Int32(17));
213 expect(new Int32.fromInt(-17).toInt32(), new Int32.fromInt(-17)); 208 expect(new Int32(-17).toInt32(), new Int32(-17));
214 expect(new Int32.fromInt(17).toInt64(), new Int64.fromInt(17)); 209 expect(new Int32(17).toInt64(), new Int64(17));
215 expect(new Int32.fromInt(-17).toInt64(), new Int64.fromInt(-17)); 210 expect(new Int32(-17).toInt64(), new Int64(-17));
216 }); 211 });
217 212
218 group("string representation", () { 213 group("string representation", () {
219 test("toString", () { 214 test("toString", () {
220 expect(new Int32.fromInt(0).toString(), "0"); 215 expect(new Int32(0).toString(), "0");
221 expect(new Int32.fromInt(1).toString(), "1"); 216 expect(new Int32(1).toString(), "1");
222 expect(new Int32.fromInt(-1).toString(), "-1"); 217 expect(new Int32(-1).toString(), "-1");
223 expect(new Int32.fromInt(1000).toString(), "1000"); 218 expect(new Int32(1000).toString(), "1000");
224 expect(new Int32.fromInt(-1000).toString(), "-1000"); 219 expect(new Int32(-1000).toString(), "-1000");
225 expect(new Int32.fromInt(123456789).toString(), "123456789"); 220 expect(new Int32(123456789).toString(), "123456789");
226 expect(new Int32.fromInt(2147483647).toString(), "2147483647"); 221 expect(new Int32(2147483647).toString(), "2147483647");
227 expect(new Int32.fromInt(2147483648).toString(), "-2147483648"); 222 expect(new Int32(2147483648).toString(), "-2147483648");
228 expect(new Int32.fromInt(2147483649).toString(), "-2147483647"); 223 expect(new Int32(2147483649).toString(), "-2147483647");
229 expect(new Int32.fromInt(2147483650).toString(), "-2147483646"); 224 expect(new Int32(2147483650).toString(), "-2147483646");
230 expect(new Int32.fromInt(-2147483648).toString(), "-2147483648"); 225 expect(new Int32(-2147483648).toString(), "-2147483648");
231 expect(new Int32.fromInt(-2147483649).toString(), "2147483647"); 226 expect(new Int32(-2147483649).toString(), "2147483647");
232 expect(new Int32.fromInt(-2147483650).toString(), "2147483646"); 227 expect(new Int32(-2147483650).toString(), "2147483646");
233 }); 228 });
234 }); 229 });
235 230
236 group("toHexString", () { 231 group("toHexString", () {
237 test("returns hexadecimal string representation", () { 232 test("returns hexadecimal string representation", () {
238 expect(new Int32.fromInt(-1).toHexString(), "-1"); 233 expect(new Int32(-1).toHexString(), "-1");
239 expect((new Int32.fromInt(-1) >> 8).toHexString(), "-1"); 234 expect((new Int32(-1) >> 8).toHexString(), "-1");
240 expect((new Int32.fromInt(-1) << 8).toHexString(), "-100"); 235 expect((new Int32(-1) << 8).toHexString(), "-100");
241 expect(new Int32.fromInt(123456789).toHexString(), "75bcd15"); 236 expect(new Int32(123456789).toHexString(), "75bcd15");
242 expect(new Int32.fromInt(-1).shiftRightUnsigned(8).toHexString(), 237 expect(new Int32(-1).shiftRightUnsigned(8).toHexString(), "ffffff");
243 "ffffff");
244 }); 238 });
245 }); 239 });
246 240
247 group("toRadixString", () { 241 group("toRadixString", () {
248 test("returns base n string representation", () { 242 test("returns base n string representation", () {
249 expect(new Int32.fromInt(123456789).toRadixString(5), "223101104124"); 243 expect(new Int32(123456789).toRadixString(5), "223101104124");
250 }); 244 });
251 }); 245 });
252 } 246 }
OLDNEW
« no previous file with comments | « pkg/fixnum/pubspec.yaml ('k') | pkg/fixnum/test/int_64_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698