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

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

Issue 21085005: Rename int{x,32,64} to Int{X,32,64} in line with naming guidelines. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Intx -> IntX Created 7 years, 4 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/lib/src/intx.dart ('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.fromInt(1234);
12 int32 n2 = new int32.fromInt(9876); 12 Int32 n2 = new Int32.fromInt(9876);
13 int32 n3 = new int32.fromInt(-1234); 13 Int32 n3 = new Int32.fromInt(-1234);
14 int32 n4 = new int32.fromInt(-9876); 14 Int32 n4 = new Int32.fromInt(-9876);
15 int32 n5 = new int32.fromInt(0x12345678); 15 Int32 n5 = new Int32.fromInt(0x12345678);
16 int32 n6 = new int32.fromInt(0x22222222); 16 Int32 n6 = new Int32.fromInt(0x22222222);
17 17
18 test("+", () { 18 test("+", () {
19 expect(n1 + n2, new int32.fromInt(11110)); 19 expect(n1 + n2, new Int32.fromInt(11110));
20 expect(n3 + n2, new int32.fromInt(8642)); 20 expect(n3 + n2, new Int32.fromInt(8642));
21 expect(n3 + n4, new int32.fromInt(-11110)); 21 expect(n3 + n4, new Int32.fromInt(-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.fromInt(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.fromInt(-8642));
28 expect(n3 - n2, new int32.fromInt(-11110)); 28 expect(n3 - n2, new Int32.fromInt(-11110));
29 expect(n3 - n4, new int32.fromInt(8642)); 29 expect(n3 - n4, new Int32.fromInt(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.fromInt(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.fromInt(-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.fromInt(12186984));
41 expect(n2 * n3, new int32.fromInt(-12186984)); 41 expect(n2 * n3, new Int32.fromInt(-12186984));
42 expect(n3 * n3, new int32.fromInt(1522756)); 42 expect(n3 * n3, new Int32.fromInt(1522756));
43 expect(n3 * n2, new int32.fromInt(-12186984)); 43 expect(n3 * n2, new Int32.fromInt(-12186984));
44 expect(new int32.fromInt(0x12345678) * new int32.fromInt(0x22222222), 44 expect(new Int32.fromInt(0x12345678) * new Int32.fromInt(0x22222222),
45 new int32.fromInt(-899716112)); 45 new Int32.fromInt(-899716112));
46 expect((new int32.fromInt(123456789) * new int32.fromInt(987654321)), 46 expect((new Int32.fromInt(123456789) * new Int32.fromInt(987654321)),
47 new int32.fromInt(-67153019)); 47 new Int32.fromInt(-67153019));
48 expect(new int32.fromInt(0x12345678) * new int64.fromInt(0x22222222), 48 expect(new Int32.fromInt(0x12345678) * new Int64.fromInt(0x22222222),
49 new int64.fromInts(0x026D60DC, 0xCA5F6BF0)); 49 new Int64.fromInts(0x026D60DC, 0xCA5F6BF0));
50 expect((new int32.fromInt(123456789) * 987654321), 50 expect((new Int32.fromInt(123456789) * 987654321),
51 new int32.fromInt(-67153019)); 51 new Int32.fromInt(-67153019));
52 expect(() => new int32.fromInt(17) * null, throws); 52 expect(() => new Int32.fromInt(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.fromInt(829893893) ~/ new Int32.fromInt(1919),
57 new int32.fromInt(432461)); 57 new Int32.fromInt(432461));
58 expect(new int32.fromInt(0x12345678) ~/ new int32.fromInt(0x22), 58 expect(new Int32.fromInt(0x12345678) ~/ new Int32.fromInt(0x22),
59 new int32.fromInt(0x12345678 ~/ 0x22)); 59 new Int32.fromInt(0x12345678 ~/ 0x22));
60 expect(new int32.fromInt(829893893) ~/ new int64.fromInt(1919), 60 expect(new Int32.fromInt(829893893) ~/ new Int64.fromInt(1919),
61 new int32.fromInt(432461)); 61 new Int32.fromInt(432461));
62 expect(new int32.fromInt(0x12345678) ~/ new int64.fromInt(0x22), 62 expect(new Int32.fromInt(0x12345678) ~/ new Int64.fromInt(0x22),
63 new int32.fromInt(0x12345678 ~/ 0x22)); 63 new Int32.fromInt(0x12345678 ~/ 0x22));
64 expect(new int32.fromInt(829893893) ~/ 1919, new int32.fromInt(432461)); 64 expect(new Int32.fromInt(829893893) ~/ 1919, new Int32.fromInt(432461));
65 expect(() => new int32.fromInt(17) ~/ int32.ZERO, throws); 65 expect(() => new Int32.fromInt(17) ~/ Int32.ZERO, throws);
66 expect(() => new int32.fromInt(17) ~/ null, throws); 66 expect(() => new Int32.fromInt(17) ~/ null, throws);
67 }); 67 });
68 68
69 test("%", () { 69 test("%", () {
70 expect(new int32.fromInt(0x12345678) % new int32.fromInt(0x22), 70 expect(new Int32.fromInt(0x12345678) % new Int32.fromInt(0x22),
71 new int32.fromInt(0x12345678 % 0x22)); 71 new Int32.fromInt(0x12345678 % 0x22));
72 expect(new int32.fromInt(0x12345678) % new int64.fromInt(0x22), 72 expect(new Int32.fromInt(0x12345678) % new Int64.fromInt(0x22),
73 new int32.fromInt(0x12345678 % 0x22)); 73 new Int32.fromInt(0x12345678 % 0x22));
74 expect(() => new int32.fromInt(17) % null, throws); 74 expect(() => new Int32.fromInt(17) % null, throws);
75 }); 75 });
76 76
77 test("remainder", () { 77 test("remainder", () {
78 expect(new int32.fromInt(0x12345678).remainder(new int32.fromInt(0x22)), 78 expect(new Int32.fromInt(0x12345678).remainder(new Int32.fromInt(0x22)),
79 new int32.fromInt(0x12345678.remainder(0x22))); 79 new Int32.fromInt(0x12345678.remainder(0x22)));
80 expect(new int32.fromInt(0x12345678).remainder(new int32.fromInt(-0x22)), 80 expect(new Int32.fromInt(0x12345678).remainder(new Int32.fromInt(-0x22)),
81 new int32.fromInt(0x12345678.remainder(-0x22))); 81 new Int32.fromInt(0x12345678.remainder(-0x22)));
82 expect(new int32.fromInt(-0x12345678).remainder(new int32.fromInt(-0x22)), 82 expect(new Int32.fromInt(-0x12345678).remainder(new Int32.fromInt(-0x22)),
83 new int32.fromInt(-0x12345678.remainder(-0x22))); 83 new Int32.fromInt(-0x12345678.remainder(-0x22)));
84 expect(new int32.fromInt(-0x12345678).remainder(new int32.fromInt(0x22)), 84 expect(new Int32.fromInt(-0x12345678).remainder(new Int32.fromInt(0x22)),
85 new int32.fromInt(-0x12345678.remainder(0x22))); 85 new Int32.fromInt(-0x12345678.remainder(0x22)));
86 expect(new int32.fromInt(0x12345678).remainder(new int64.fromInt(0x22)), 86 expect(new Int32.fromInt(0x12345678).remainder(new Int64.fromInt(0x22)),
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); 97 expect(new Int32.fromInt(17) < new Int64.fromInt(18), true);
98 expect(new int32.fromInt(17) < new int64.fromInt(17), false); 98 expect(new Int32.fromInt(17) < new Int64.fromInt(17), false);
99 expect(new int32.fromInt(17) < new int64.fromInt(16), false); 99 expect(new Int32.fromInt(17) < new Int64.fromInt(16), false);
100 expect(int32.MIN_VALUE < int32.MAX_VALUE, true); 100 expect(Int32.MIN_VALUE < Int32.MAX_VALUE, true);
101 expect(int32.MAX_VALUE < int32.MIN_VALUE, false); 101 expect(Int32.MAX_VALUE < Int32.MIN_VALUE, false);
102 expect(() => new int32.fromInt(17) < null, throws); 102 expect(() => new Int32.fromInt(17) < null, throws);
103 }); 103 });
104 104
105 test("<=", () { 105 test("<=", () {
106 expect(new int32.fromInt(17) <= new int32.fromInt(18), true); 106 expect(new Int32.fromInt(17) <= new Int32.fromInt(18), true);
107 expect(new int32.fromInt(17) <= new int32.fromInt(17), true); 107 expect(new Int32.fromInt(17) <= new Int32.fromInt(17), true);
108 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); 109 expect(new Int32.fromInt(17) <= new Int64.fromInt(18), true);
110 expect(new int32.fromInt(17) <= new int64.fromInt(17), true); 110 expect(new Int32.fromInt(17) <= new Int64.fromInt(17), true);
111 expect(new int32.fromInt(17) <= new int64.fromInt(16), false); 111 expect(new Int32.fromInt(17) <= new Int64.fromInt(16), false);
112 expect(int32.MIN_VALUE <= int32.MAX_VALUE, true); 112 expect(Int32.MIN_VALUE <= Int32.MAX_VALUE, true);
113 expect(int32.MAX_VALUE <= int32.MIN_VALUE, false); 113 expect(Int32.MAX_VALUE <= Int32.MIN_VALUE, false);
114 expect(() => new int32.fromInt(17) <= null, throws); 114 expect(() => new Int32.fromInt(17) <= null, throws);
115 }); 115 });
116 116
117 test("==", () { 117 test("==", () {
118 expect(new int32.fromInt(17) == new int32.fromInt(18), false); 118 expect(new Int32.fromInt(17) == new Int32.fromInt(18), false);
119 expect(new int32.fromInt(17) == new int32.fromInt(17), true); 119 expect(new Int32.fromInt(17) == new Int32.fromInt(17), true);
120 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); 121 expect(new Int32.fromInt(17) == new Int64.fromInt(18), false);
122 expect(new int32.fromInt(17) == new int64.fromInt(17), true); 122 expect(new Int32.fromInt(17) == new Int64.fromInt(17), true);
123 expect(new int32.fromInt(17) == new int64.fromInt(16), false); 123 expect(new Int32.fromInt(17) == new Int64.fromInt(16), false);
124 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); 125 expect(new Int32.fromInt(17) == new Object(), false);
126 expect(new int32.fromInt(17) == null, false); 126 expect(new Int32.fromInt(17) == null, false);
127 }); 127 });
128 128
129 test(">=", () { 129 test(">=", () {
130 expect(new int32.fromInt(17) >= new int32.fromInt(18), false); 130 expect(new Int32.fromInt(17) >= new Int32.fromInt(18), false);
131 expect(new int32.fromInt(17) >= new int32.fromInt(17), true); 131 expect(new Int32.fromInt(17) >= new Int32.fromInt(17), true);
132 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); 133 expect(new Int32.fromInt(17) >= new Int64.fromInt(18), false);
134 expect(new int32.fromInt(17) >= new int64.fromInt(17), true); 134 expect(new Int32.fromInt(17) >= new Int64.fromInt(17), true);
135 expect(new int32.fromInt(17) >= new int64.fromInt(16), true); 135 expect(new Int32.fromInt(17) >= new Int64.fromInt(16), true);
136 expect(int32.MIN_VALUE >= int32.MAX_VALUE, false); 136 expect(Int32.MIN_VALUE >= Int32.MAX_VALUE, false);
137 expect(int32.MAX_VALUE >= int32.MIN_VALUE, true); 137 expect(Int32.MAX_VALUE >= Int32.MIN_VALUE, true);
138 expect(() => new int32.fromInt(17) >= null, throws); 138 expect(() => new Int32.fromInt(17) >= null, throws);
139 }); 139 });
140 140
141 test(">", () { 141 test(">", () {
142 expect(new int32.fromInt(17) > new int32.fromInt(18), false); 142 expect(new Int32.fromInt(17) > new Int32.fromInt(18), false);
143 expect(new int32.fromInt(17) > new int32.fromInt(17), false); 143 expect(new Int32.fromInt(17) > new Int32.fromInt(17), false);
144 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); 145 expect(new Int32.fromInt(17) > new Int64.fromInt(18), false);
146 expect(new int32.fromInt(17) > new int64.fromInt(17), false); 146 expect(new Int32.fromInt(17) > new Int64.fromInt(17), false);
147 expect(new int32.fromInt(17) > new int64.fromInt(16), true); 147 expect(new Int32.fromInt(17) > new Int64.fromInt(16), true);
148 expect(int32.MIN_VALUE > int32.MAX_VALUE, false); 148 expect(Int32.MIN_VALUE > Int32.MAX_VALUE, false);
149 expect(int32.MAX_VALUE > int32.MIN_VALUE, true); 149 expect(Int32.MAX_VALUE > Int32.MIN_VALUE, true);
150 expect(() => new int32.fromInt(17) > null, throws); 150 expect(() => new Int32.fromInt(17) > null, throws);
151 }); 151 });
152 }); 152 });
153 153
154 group("bitwise operators", () { 154 group("bitwise operators", () {
155 test("&", () { 155 test("&", () {
156 expect(new int32.fromInt(0x12345678) & new int32.fromInt(0x22222222), 156 expect(new Int32.fromInt(0x12345678) & new Int32.fromInt(0x22222222),
157 new int32.fromInt(0x12345678 & 0x22222222)); 157 new Int32.fromInt(0x12345678 & 0x22222222));
158 expect(new int32.fromInt(0x12345678) & new int64.fromInt(0x22222222), 158 expect(new Int32.fromInt(0x12345678) & new Int64.fromInt(0x22222222),
159 new int64.fromInt(0x12345678 & 0x22222222)); 159 new Int64.fromInt(0x12345678 & 0x22222222));
160 expect(() => new int32.fromInt(17) & null, throwsArgumentError); 160 expect(() => new Int32.fromInt(17) & null, throwsArgumentError);
161 }); 161 });
162 162
163 test("|", () { 163 test("|", () {
164 expect(new int32.fromInt(0x12345678) | new int32.fromInt(0x22222222), 164 expect(new Int32.fromInt(0x12345678) | new Int32.fromInt(0x22222222),
165 new int32.fromInt(0x12345678 | 0x22222222)); 165 new Int32.fromInt(0x12345678 | 0x22222222));
166 expect(new int32.fromInt(0x12345678) | new int64.fromInt(0x22222222), 166 expect(new Int32.fromInt(0x12345678) | new Int64.fromInt(0x22222222),
167 new int64.fromInt(0x12345678 | 0x22222222)); 167 new Int64.fromInt(0x12345678 | 0x22222222));
168 expect(() => new int32.fromInt(17) | null, throws); 168 expect(() => new Int32.fromInt(17) | null, throws);
169 }); 169 });
170 170
171 test("^", () { 171 test("^", () {
172 expect(new int32.fromInt(0x12345678) ^ new int32.fromInt(0x22222222), 172 expect(new Int32.fromInt(0x12345678) ^ new Int32.fromInt(0x22222222),
173 new int32.fromInt(0x12345678 ^ 0x22222222)); 173 new Int32.fromInt(0x12345678 ^ 0x22222222));
174 expect(new int32.fromInt(0x12345678) ^ new int64.fromInt(0x22222222), 174 expect(new Int32.fromInt(0x12345678) ^ new Int64.fromInt(0x22222222),
175 new int64.fromInt(0x12345678 ^ 0x22222222)); 175 new Int64.fromInt(0x12345678 ^ 0x22222222));
176 expect(() => new int32.fromInt(17) ^ null, throws); 176 expect(() => new Int32.fromInt(17) ^ null, throws);
177 }); 177 });
178 178
179 test("~", () { 179 test("~", () {
180 expect(~(new int32.fromInt(0x12345678)), new int32.fromInt(~0x12345678)); 180 expect(~(new Int32.fromInt(0x12345678)), new Int32.fromInt(~0x12345678));
181 expect(-(new int32.fromInt(0x12345678)), new int64.fromInt(-0x12345678)); 181 expect(-(new Int32.fromInt(0x12345678)), new Int64.fromInt(-0x12345678));
182 }); 182 });
183 }); 183 });
184 184
185 group("bitshift operators", () { 185 group("bitshift operators", () {
186 test("<<", () { 186 test("<<", () {
187 expect(new int32.fromInt(0x12345678) << 7, 187 expect(new Int32.fromInt(0x12345678) << 7,
188 new int32.fromInt(0x12345678 << 7)); 188 new Int32.fromInt(0x12345678 << 7));
189 expect(() => new int32.fromInt(17) << -1, throwsArgumentError); 189 expect(() => new Int32.fromInt(17) << -1, throwsArgumentError);
190 expect(() => new int32.fromInt(17) << null, throws); 190 expect(() => new Int32.fromInt(17) << null, throws);
191 }); 191 });
192 192
193 test(">>", () { 193 test(">>", () {
194 expect(new int32.fromInt(0x12345678) >> 7, 194 expect(new Int32.fromInt(0x12345678) >> 7,
195 new int32.fromInt(0x12345678 >> 7)); 195 new Int32.fromInt(0x12345678 >> 7));
196 expect(() => new int32.fromInt(17) >> -1, throwsArgumentError); 196 expect(() => new Int32.fromInt(17) >> -1, throwsArgumentError);
197 expect(() => new int32.fromInt(17) >> null, throws); 197 expect(() => new Int32.fromInt(17) >> null, throws);
198 }); 198 });
199 199
200 test("shiftRightUnsigned", () { 200 test("shiftRightUnsigned", () {
201 expect(new int32.fromInt(0x12345678).shiftRightUnsigned(7), 201 expect(new Int32.fromInt(0x12345678).shiftRightUnsigned(7),
202 new int32.fromInt(0x12345678 >> 7)); 202 new Int32.fromInt(0x12345678 >> 7));
203 expect(() => (new int32.fromInt(17).shiftRightUnsigned(-1)), 203 expect(() => (new Int32.fromInt(17).shiftRightUnsigned(-1)),
204 throwsArgumentError); 204 throwsArgumentError);
205 expect(() => (new int32.fromInt(17).shiftRightUnsigned(null)), throws); 205 expect(() => (new Int32.fromInt(17).shiftRightUnsigned(null)), throws);
206 }); 206 });
207 }); 207 });
208 208
209 group("type conversions", () { 209 group("type conversions", () {
210 expect(new int32.fromInt(17).toInt(), 17); 210 expect(new Int32.fromInt(17).toInt(), 17);
211 expect(new int32.fromInt(-17).toInt(), -17); 211 expect(new Int32.fromInt(-17).toInt(), -17);
212 expect(new int32.fromInt(17).toInt32(), new int32.fromInt(17)); 212 expect(new Int32.fromInt(17).toInt32(), new Int32.fromInt(17));
213 expect(new int32.fromInt(-17).toInt32(), new int32.fromInt(-17)); 213 expect(new Int32.fromInt(-17).toInt32(), new Int32.fromInt(-17));
214 expect(new int32.fromInt(17).toInt64(), new int64.fromInt(17)); 214 expect(new Int32.fromInt(17).toInt64(), new Int64.fromInt(17));
215 expect(new int32.fromInt(-17).toInt64(), new int64.fromInt(-17)); 215 expect(new Int32.fromInt(-17).toInt64(), new Int64.fromInt(-17));
216 }); 216 });
217 217
218 group("string representation", () { 218 group("string representation", () {
219 test("toString", () { 219 test("toString", () {
220 expect(new int32.fromInt(0).toString(), "0"); 220 expect(new Int32.fromInt(0).toString(), "0");
221 expect(new int32.fromInt(1).toString(), "1"); 221 expect(new Int32.fromInt(1).toString(), "1");
222 expect(new int32.fromInt(-1).toString(), "-1"); 222 expect(new Int32.fromInt(-1).toString(), "-1");
223 expect(new int32.fromInt(1000).toString(), "1000"); 223 expect(new Int32.fromInt(1000).toString(), "1000");
224 expect(new int32.fromInt(-1000).toString(), "-1000"); 224 expect(new Int32.fromInt(-1000).toString(), "-1000");
225 expect(new int32.fromInt(123456789).toString(), "123456789"); 225 expect(new Int32.fromInt(123456789).toString(), "123456789");
226 expect(new int32.fromInt(2147483647).toString(), "2147483647"); 226 expect(new Int32.fromInt(2147483647).toString(), "2147483647");
227 expect(new int32.fromInt(2147483648).toString(), "-2147483648"); 227 expect(new Int32.fromInt(2147483648).toString(), "-2147483648");
228 expect(new int32.fromInt(2147483649).toString(), "-2147483647"); 228 expect(new Int32.fromInt(2147483649).toString(), "-2147483647");
229 expect(new int32.fromInt(2147483650).toString(), "-2147483646"); 229 expect(new Int32.fromInt(2147483650).toString(), "-2147483646");
230 expect(new int32.fromInt(-2147483648).toString(), "-2147483648"); 230 expect(new Int32.fromInt(-2147483648).toString(), "-2147483648");
231 expect(new int32.fromInt(-2147483649).toString(), "2147483647"); 231 expect(new Int32.fromInt(-2147483649).toString(), "2147483647");
232 expect(new int32.fromInt(-2147483650).toString(), "2147483646"); 232 expect(new Int32.fromInt(-2147483650).toString(), "2147483646");
233 }); 233 });
234 }); 234 });
235 235
236 group("toHexString", () { 236 group("toHexString", () {
237 test("returns hexadecimal string representation", () { 237 test("returns hexadecimal string representation", () {
238 expect(new int32.fromInt(-1).toHexString(), "-1"); 238 expect(new Int32.fromInt(-1).toHexString(), "-1");
239 expect((new int32.fromInt(-1) >> 8).toHexString(), "-1"); 239 expect((new Int32.fromInt(-1) >> 8).toHexString(), "-1");
240 expect((new int32.fromInt(-1) << 8).toHexString(), "-100"); 240 expect((new Int32.fromInt(-1) << 8).toHexString(), "-100");
241 expect(new int32.fromInt(123456789).toHexString(), "75bcd15"); 241 expect(new Int32.fromInt(123456789).toHexString(), "75bcd15");
242 expect(new int32.fromInt(-1).shiftRightUnsigned(8).toHexString(), 242 expect(new Int32.fromInt(-1).shiftRightUnsigned(8).toHexString(),
243 "ffffff"); 243 "ffffff");
244 }); 244 });
245 }); 245 });
246 246
247 group("toRadixString", () { 247 group("toRadixString", () {
248 test("returns base n string representation", () { 248 test("returns base n string representation", () {
249 expect(new int32.fromInt(123456789).toRadixString(5), "223101104124"); 249 expect(new Int32.fromInt(123456789).toRadixString(5), "223101104124");
250 }); 250 });
251 }); 251 });
252 } 252 }
OLDNEW
« no previous file with comments | « pkg/fixnum/lib/src/intx.dart ('k') | pkg/fixnum/test/int_64_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698