Merge pull request #24 from dart-lang/cleanup
Cleanup
diff --git a/.analysis_options b/analysis_options.yaml
similarity index 100%
rename from .analysis_options
rename to analysis_options.yaml
diff --git a/lib/src/int32.dart b/lib/src/int32.dart
index 786f2bb..562ff0c 100644
--- a/lib/src/int32.dart
+++ b/lib/src/int32.dart
@@ -9,7 +9,6 @@
* Arithmetic operations may overflow in order to maintain this range.
*/
class Int32 implements IntX {
-
/**
* The maximum positive value attainable by an [Int32], namely
* 2147483647.
diff --git a/lib/src/int64.dart b/lib/src/int64.dart
index b7127ee..cc78ab6 100644
--- a/lib/src/int64.dart
+++ b/lib/src/int64.dart
@@ -9,7 +9,6 @@
* Arithmetic operations may overflow in order to maintain this range.
*/
class Int64 implements IntX {
-
// A 64-bit integer is represented internally as three non-negative
// integers, storing the 22 low, 22 middle, and 20 high bits of the
// 64-bit value. _l (low) and _m (middle) are in the range
@@ -63,7 +62,7 @@
* Constructs an [Int64] with a given bitwise representation. No validation
* is performed.
*/
- const Int64._bits(int this._l, int this._m, int this._h);
+ const Int64._bits(this._l, this._m, this._h);
/**
* Parses a [String] in a given [radix] between 2 and 36 and returns an
@@ -80,7 +79,7 @@
negative = true;
i++;
}
- int d0 = 0, d1 = 0, d2 = 0; // low, middle, high components.
+ int d0 = 0, d1 = 0, d2 = 0; // low, middle, high components.
for (; i < s.length; i++) {
int c = s.codeUnitAt(i);
int digit = Int32._decodeDigit(c);
@@ -124,7 +123,7 @@
/**
* Constructs an [Int64] with a given [int] value; zero by default.
*/
- factory Int64([int value=0]) {
+ factory Int64([int value = 0]) {
int v0 = 0, v1 = 0, v2 = 0;
bool negative = false;
if (value < 0) {
@@ -185,7 +184,7 @@
bottom |= bytes[7] & 0xff;
return new Int64.fromInts(top, bottom);
- }
+ }
/**
* Constructs an [Int64] from a pair of 32-bit integers having the value
@@ -197,7 +196,7 @@
int d0 = _MASK & bottom;
int d1 = ((0xfff & top) << 10) | (0x3ff & (bottom >> _BITS));
int d2 = _MASK2 & (top >> 12);
- return Int64._masked(d0, d1, d2);
+ return Int64._masked(d0, d1, d2);
}
// Returns the [Int64] representation of the specified value. Throws
@@ -582,12 +581,12 @@
int m = _m.toSigned(width - _BITS);
return m.isNegative
? Int64._masked(_l, m, _MASK2)
- : Int64._masked(_l, m, 0); // Masking for type inferrer.
+ : Int64._masked(_l, m, 0); // Masking for type inferrer.
} else {
int l = _l.toSigned(width);
return l.isNegative
? Int64._masked(l, _MASK, _MASK2)
- : Int64._masked(l, 0, 0); // Masking for type inferrer.
+ : Int64._masked(l, 0, 0); // Masking for type inferrer.
}
}
@@ -771,8 +770,26 @@
static const _fatRadixTable = const <int>[
0,
0,
- 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2
- * 2,
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2 *
+ 2,
3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3,
4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4,
5 * 5 * 5 * 5 * 5 * 5 * 5 * 5,
@@ -870,13 +887,19 @@
static const _RETURN_REM = 2;
static const _RETURN_MOD = 3;
- static _divideHelper(
+ static Int64 _divideHelper(
// up to 64 bits unsigned in a2/a1/a0 and b2/b1/b0
- int a0, int a1, int a2, bool aNeg, // input A.
- int b0, int b1, int b2, bool bNeg, // input B.
+ int a0,
+ int a1,
+ int a2,
+ bool aNeg, // input A.
+ int b0,
+ int b1,
+ int b2,
+ bool bNeg, // input B.
int what) {
- int q0 = 0, q1 = 0, q2 = 0; // result Q.
- int r0 = 0, r1 = 0, r2 = 0; // result R.
+ int q0 = 0, q1 = 0, q2 = 0; // result Q.
+ int r0 = 0, r1 = 0, r2 = 0; // result R.
if (b2 == 0 && b1 == 0 && b0 < (1 << (30 - _BITS))) {
// Small divisor can be handled by single-digit division within Smi range.
@@ -924,7 +947,7 @@
q0 = q0d.toInt();
assert(q0 + K1 * q1 + K2 * q2 == (ad / bd).floorToDouble());
- assert(q2 == 0 || b2 == 0); // Q and B can't both be big since Q*B <= A.
+ assert(q2 == 0 || b2 == 0); // Q and B can't both be big since Q*B <= A.
// P = Q * B, using doubles to hold intermediates.
// We don't need all partial sums since Q*B <= A.
@@ -935,7 +958,7 @@
double p1carry = (p1d / K1).floorToDouble();
p1d = p1d - p1carry * K1;
double p2d = q2d * b0 + q1d * b1 + q0d * b2 + p1carry;
- assert(p2d <= _MASK2); // No partial sum overflow.
+ assert(p2d <= _MASK2); // No partial sum overflow.
// R = A - P
int diff0 = a0 - p0d.toInt();
@@ -947,8 +970,7 @@
// while (R < 0 || R >= B)
// adjust R towards [0, B)
- while (
- r2 >= _SIGN_BIT_MASK ||
+ while (r2 >= _SIGN_BIT_MASK ||
r2 > b2 ||
(r2 == b2 && (r1 > b1 || (r1 == b1 && r0 >= b0)))) {
// Direction multiplier for adjustment.
@@ -973,17 +995,17 @@
// 0 <= R < B
assert(Int64.ZERO <= new Int64._bits(r0, r1, r2));
- assert(r2 < b2 || // Handles case where B = -(MIN_VALUE)
+ assert(r2 < b2 || // Handles case where B = -(MIN_VALUE)
new Int64._bits(r0, r1, r2) < new Int64._bits(b0, b1, b2));
assert(what == _RETURN_DIV || what == _RETURN_MOD || what == _RETURN_REM);
if (what == _RETURN_DIV) {
if (aNeg != bNeg) return _negate(q0, q1, q2);
- return Int64._masked(q0, q1, q2); // Masking for type inferrer.
+ return Int64._masked(q0, q1, q2); // Masking for type inferrer.
}
if (!aNeg) {
- return Int64._masked(r0, r1, r2); // Masking for type inferrer.
+ return Int64._masked(r0, r1, r2); // Masking for type inferrer.
}
if (what == _RETURN_MOD) {
diff --git a/lib/src/intx.dart b/lib/src/intx.dart
index 6b4a454..3c2207d 100644
--- a/lib/src/intx.dart
+++ b/lib/src/intx.dart
@@ -8,7 +8,6 @@
* A fixed-precision integer.
*/
abstract class IntX implements Comparable<dynamic> {
-
/** Addition operator. */
IntX operator +(other);
diff --git a/test/int32_test.dart b/test/int32_test.dart
index d237a03..63149cf 100644
--- a/test/int32_test.dart
+++ b/test/int32_test.dart
@@ -64,7 +64,7 @@
expect(n3 + n4, new Int32(-11110));
expect(n3 + new Int64(1), new Int64(-1233));
expect(Int32.MAX_VALUE + 1, Int32.MIN_VALUE);
- expect(() => new Int32(17) + null, throws);
+ expect(() => new Int32(17) + null, throwsArgumentError);
});
test("-", () {
@@ -73,7 +73,7 @@
expect(n3 - n4, new Int32(8642));
expect(n3 - new Int64(1), new Int64(-1235));
expect(Int32.MIN_VALUE - 1, Int32.MAX_VALUE);
- expect(() => new Int32(17) - null, throws);
+ expect(() => new Int32(17) - null, throwsArgumentError);
});
test("unary -", () {
@@ -93,7 +93,7 @@
expect(new Int32(0x12345678) * new Int64(0x22222222),
new Int64.fromInts(0x026D60DC, 0xCA5F6BF0));
expect((new Int32(123456789) * 987654321), new Int32(-67153019));
- expect(() => new Int32(17) * null, throws);
+ expect(() => new Int32(17) * null, throwsArgumentError);
});
test("~/", () {
@@ -104,8 +104,13 @@
expect(new Int32(0x12345678) ~/ new Int64(0x22),
new Int32(0x12345678 ~/ 0x22));
expect(new Int32(829893893) ~/ 1919, new Int32(432461));
- expect(() => new Int32(17) ~/ Int32.ZERO, throws);
- expect(() => new Int32(17) ~/ null, throws);
+ expect(
+ () => new Int32(17) ~/ Int32.ZERO,
+ // with dart2js, `UnsupportedError` is thrown
+ // on the VM: IntegerDivisionByZeroException
+ throwsA(anyOf(new isInstanceOf<IntegerDivisionByZeroException>(),
+ isUnsupportedError)));
+ expect(() => new Int32(17) ~/ null, throwsArgumentError);
});
test("%", () {
@@ -113,7 +118,7 @@
new Int32(0x12345678 % 0x22));
expect(new Int32(0x12345678) % new Int64(0x22),
new Int32(0x12345678 % 0x22));
- expect(() => new Int32(17) % null, throws);
+ expect(() => new Int32(17) % null, throwsArgumentError);
});
test("remainder", () {
@@ -127,7 +132,7 @@
new Int32(-0x12345678.remainder(0x22)));
expect(new Int32(0x12345678).remainder(new Int64(0x22)),
new Int32(0x12345678.remainder(0x22)));
- expect(() => new Int32(17).remainder(null), throws);
+ expect(() => new Int32(17).remainder(null), throwsArgumentError);
});
test("abs", () {
@@ -200,7 +205,7 @@
expect(new Int32(17) < new Int64(16), false);
expect(Int32.MIN_VALUE < Int32.MAX_VALUE, true);
expect(Int32.MAX_VALUE < Int32.MIN_VALUE, false);
- expect(() => new Int32(17) < null, throws);
+ expect(() => new Int32(17) < null, throwsArgumentError);
});
test("<=", () {
@@ -212,7 +217,7 @@
expect(new Int32(17) <= new Int64(16), false);
expect(Int32.MIN_VALUE <= Int32.MAX_VALUE, true);
expect(Int32.MAX_VALUE <= Int32.MIN_VALUE, false);
- expect(() => new Int32(17) <= null, throws);
+ expect(() => new Int32(17) <= null, throwsArgumentError);
});
test("==", () {
@@ -239,7 +244,7 @@
expect(new Int32(17) >= new Int64(16), true);
expect(Int32.MIN_VALUE >= Int32.MAX_VALUE, false);
expect(Int32.MAX_VALUE >= Int32.MIN_VALUE, true);
- expect(() => new Int32(17) >= null, throws);
+ expect(() => new Int32(17) >= null, throwsArgumentError);
});
test(">", () {
@@ -251,7 +256,7 @@
expect(new Int32(17) > new Int64(16), true);
expect(Int32.MIN_VALUE > Int32.MAX_VALUE, false);
expect(Int32.MAX_VALUE > Int32.MIN_VALUE, true);
- expect(() => new Int32(17) > null, throws);
+ expect(() => new Int32(17) > null, throwsArgumentError);
});
});
@@ -269,7 +274,7 @@
new Int32(0x12345678 | 0x22222222));
expect(new Int32(0x12345678) | new Int64(0x22222222),
new Int64(0x12345678 | 0x22222222));
- expect(() => new Int32(17) | null, throws);
+ expect(() => new Int32(17) | null, throwsArgumentError);
});
test("^", () {
@@ -277,7 +282,7 @@
new Int32(0x12345678 ^ 0x22222222));
expect(new Int32(0x12345678) ^ new Int64(0x22222222),
new Int64(0x12345678 ^ 0x22222222));
- expect(() => new Int32(17) ^ null, throws);
+ expect(() => new Int32(17) ^ null, throwsArgumentError);
});
test("~", () {
@@ -290,20 +295,21 @@
test("<<", () {
expect(new Int32(0x12345678) << 7, new Int32(0x12345678 << 7));
expect(() => new Int32(17) << -1, throwsArgumentError);
- expect(() => new Int32(17) << null, throws);
+ expect(() => new Int32(17) << null, throwsNoSuchMethodError);
});
test(">>", () {
expect(new Int32(0x12345678) >> 7, new Int32(0x12345678 >> 7));
expect(() => new Int32(17) >> -1, throwsArgumentError);
- expect(() => new Int32(17) >> null, throws);
+ expect(() => new Int32(17) >> null, throwsNoSuchMethodError);
});
test("shiftRightUnsigned", () {
expect(new Int32(0x12345678).shiftRightUnsigned(7),
new Int32(0x12345678 >> 7));
expect(() => (new Int32(17).shiftRightUnsigned(-1)), throwsArgumentError);
- expect(() => (new Int32(17).shiftRightUnsigned(null)), throws);
+ expect(() => (new Int32(17).shiftRightUnsigned(null)),
+ throwsNoSuchMethodError);
});
});
@@ -345,10 +351,10 @@
expect(new Int32(-17).toInt64(), new Int64(-17));
});
test("toBytes", () {
- expect(new Int32(0).toBytes(), [ 0, 0, 0, 0 ]);
- expect(new Int32(0x01020304).toBytes(), [ 4, 3, 2, 1 ]);
- expect(new Int32(0x04030201).toBytes(), [ 1, 2, 3, 4 ]);
- expect(new Int32(-1).toBytes(), [ 0xff, 0xff, 0xff, 0xff ]);
+ expect(new Int32(0).toBytes(), [0, 0, 0, 0]);
+ expect(new Int32(0x01020304).toBytes(), [4, 3, 2, 1]);
+ expect(new Int32(0x04030201).toBytes(), [1, 2, 3, 4]);
+ expect(new Int32(-1).toBytes(), [0xff, 0xff, 0xff, 0xff]);
});
});
@@ -357,6 +363,7 @@
checkInt(int x) {
expect(Int32.parseRadix('$x', 10), new Int32(x));
}
+
checkInt(0);
checkInt(1);
checkInt(1000);
@@ -374,6 +381,7 @@
check(String s, int r, String x) {
expect(Int32.parseRadix(s, r).toString(), x);
}
+
check('deadbeef', 16, '-559038737');
check('95', 12, '113');
});
diff --git a/test/int64_test.dart b/test/int64_test.dart
index 1ea7e75..4ae7aea 100644
--- a/test/int64_test.dart
+++ b/test/int64_test.dart
@@ -13,30 +13,32 @@
checkBytes(List<int> bytes, int h, int l) {
expect(new Int64.fromBytes(bytes), new Int64.fromInts(h, l));
}
- checkBytes([ 0, 0, 0, 0, 0, 0, 0, 0 ], 0, 0);
- checkBytes([ 1, 0, 0, 0, 0, 0, 0, 0 ], 0, 1);
- checkBytes([ 1, 2, 3, 4, 5, 6, 7, 8 ], 0x08070605, 0x04030201);
- checkBytes([ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ],
- 0xffffffff, 0xfffffffe);
- checkBytes([ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ],
- 0xffffffff, 0xffffffff);
+
+ checkBytes([0, 0, 0, 0, 0, 0, 0, 0], 0, 0);
+ checkBytes([1, 0, 0, 0, 0, 0, 0, 0], 0, 1);
+ checkBytes([1, 2, 3, 4, 5, 6, 7, 8], 0x08070605, 0x04030201);
+ checkBytes([0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], 0xffffffff,
+ 0xfffffffe);
+ checkBytes([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], 0xffffffff,
+ 0xffffffff);
});
test("fromBytesBigEndian", () {
checkBytes(List<int> bytes, int h, int l) {
expect(new Int64.fromBytesBigEndian(bytes), new Int64.fromInts(h, l));
}
- checkBytes([ 0, 0, 0, 0, 0, 0, 0, 0 ], 0, 0);
- checkBytes([ 0, 0, 0, 0, 0, 0, 0, 1 ], 0, 1);
- checkBytes([ 8, 7, 6, 5, 4, 3, 2, 1 ], 0x08070605, 0x04030201);
- checkBytes([ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe ],
- 0xffffffff, 0xfffffffe);
- checkBytes([ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ],
- 0xffffffff, 0xffffffff);
+
+ checkBytes([0, 0, 0, 0, 0, 0, 0, 0], 0, 0);
+ checkBytes([0, 0, 0, 0, 0, 0, 0, 1], 0, 1);
+ checkBytes([8, 7, 6, 5, 4, 3, 2, 1], 0x08070605, 0x04030201);
+ checkBytes([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe], 0xffffffff,
+ 0xfffffffe);
+ checkBytes([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff], 0xffffffff,
+ 0xffffffff);
});
});
argumentErrorTest(name, op, [receiver = Int64.ONE]) {
- throwsArgumentErrorMentioning(substring) =>
+ throwsArgumentErrorMentioning(String substring) =>
throwsA((e) => e is ArgumentError && '$e'.contains(substring));
expect(() => op(receiver, null), throwsArgumentErrorMentioning('null'));
@@ -128,14 +130,17 @@
expect(new Int64(-1111) * new Int64(-3), new Int64(3333));
expect(new Int64(100) * Int64.ZERO, Int64.ZERO);
- expect(new Int64.fromInts(0x12345678, 0x12345678) *
- new Int64.fromInts(0x1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0x12345678, 0x12345678) *
+ new Int64.fromInts(0x1234, 0x12345678),
new Int64.fromInts(0x7ff63f7c, 0x1df4d840));
- expect(new Int64.fromInts(0xf2345678, 0x12345678) *
- new Int64.fromInts(0x1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0xf2345678, 0x12345678) *
+ new Int64.fromInts(0x1234, 0x12345678),
new Int64.fromInts(0x7ff63f7c, 0x1df4d840));
- expect(new Int64.fromInts(0xf2345678, 0x12345678) *
- new Int64.fromInts(0xffff1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0xf2345678, 0x12345678) *
+ new Int64.fromInts(0xffff1234, 0x12345678),
new Int64.fromInts(0x297e3f7c, 0x1df4d840));
// RHS Int32
@@ -202,17 +207,21 @@
expect(new Int64(-1000) ~/ new Int64(3), new Int64(-333));
expect(new Int64(-1000) ~/ new Int64(-3), new Int64(333));
expect(new Int64(3) ~/ new Int64(1000), Int64.ZERO);
- expect(new Int64.fromInts(0x12345678, 0x12345678) ~/
- new Int64.fromInts(0x0, 0x123),
+ expect(
+ new Int64.fromInts(0x12345678, 0x12345678) ~/
+ new Int64.fromInts(0x0, 0x123),
new Int64.fromInts(0x1003d0, 0xe84f5ae8));
- expect(new Int64.fromInts(0x12345678, 0x12345678) ~/
- new Int64.fromInts(0x1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0x12345678, 0x12345678) ~/
+ new Int64.fromInts(0x1234, 0x12345678),
new Int64.fromInts(0x0, 0x10003));
- expect(new Int64.fromInts(0xf2345678, 0x12345678) ~/
- new Int64.fromInts(0x1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0xf2345678, 0x12345678) ~/
+ new Int64.fromInts(0x1234, 0x12345678),
new Int64.fromInts(0xffffffff, 0xffff3dfe));
- expect(new Int64.fromInts(0xf2345678, 0x12345678) ~/
- new Int64.fromInts(0xffff1234, 0x12345678),
+ expect(
+ new Int64.fromInts(0xf2345678, 0x12345678) ~/
+ new Int64.fromInts(0xffff1234, 0x12345678),
new Int64.fromInts(0x0, 0xeda));
expect(new Int64(829893893) ~/ new Int32(1919), new Int32(432461));
expect(new Int64(829893893) ~/ new Int64(1919), new Int32(432461));
@@ -223,7 +232,8 @@
new Int64.fromInts(0xc0000000, 0x00000000));
expect(Int64.MIN_VALUE ~/ new Int64(1), Int64.MIN_VALUE);
expect(Int64.MIN_VALUE ~/ new Int64(-1), Int64.MIN_VALUE);
- expect(() => new Int64(17) ~/ Int64.ZERO, throws);
+ expect(() => new Int64(17) ~/ Int64.ZERO,
+ throwsA(new isInstanceOf<IntegerDivisionByZeroException>()));
argumentErrorTest("~/", (a, b) => a ~/ b);
});
@@ -293,6 +303,7 @@
checkZeros(Int64 value, int zeros) {
expect(value.numberOfLeadingZeros(), zeros);
}
+
checkZeros(new Int64(0), 64);
checkZeros(new Int64(1), 63);
checkZeros(new Int64.fromInts(0x00000000, 0x003fffff), 42);
@@ -307,6 +318,7 @@
checkZeros(Int64 value, int zeros) {
expect(value.numberOfTrailingZeros(), zeros);
}
+
checkZeros(new Int64(-1), 0);
checkZeros(new Int64(1), 0);
checkZeros(new Int64(2), 1);
@@ -483,7 +495,7 @@
expect(new Int64(-1) << 5, new Int64(-32));
expect(new Int64(-1) << 0, new Int64(-1));
expect(() => new Int64(17) << -1, throwsArgumentError);
- expect(() => new Int64(17) << null, throws);
+ expect(() => new Int64(17) << null, throwsNoSuchMethodError);
});
test(">>", () {
@@ -534,7 +546,7 @@
expect(new Int64.fromInts(0x92345678, 0x9abcdef0) >> 48,
new Int64.fromInts(0xffffffff, 0xffff9234));
expect(() => new Int64(17) >> -1, throwsArgumentError);
- expect(() => new Int64(17) >> null, throws);
+ expect(() => new Int64(17) >> null, throwsNoSuchMethodError);
});
test("shiftRightUnsigned", () {
@@ -579,7 +591,8 @@
expect(new Int64.fromInts(0x00000000, 0x00009234),
new Int64.fromInts(0x92345678, 0x9abcdef0).shiftRightUnsigned(48));
expect(() => new Int64(17).shiftRightUnsigned(-1), throwsArgumentError);
- expect(() => new Int64(17).shiftRightUnsigned(null), throws);
+ expect(() => new Int64(17).shiftRightUnsigned(null),
+ throwsNoSuchMethodError);
});
test("overflow", () {
@@ -634,10 +647,10 @@
expect(new Int64(-2147483648).toDouble(), same(-2147483648.0));
expect(new Int64(4503599627370495).toDouble(), same(4503599627370495.0));
expect(new Int64(4503599627370496).toDouble(), same(4503599627370496.0));
- expect(new Int64(-4503599627370495).toDouble(),
- same(-4503599627370495.0));
- expect(new Int64(-4503599627370496).toDouble(),
- same(-4503599627370496.0));
+ expect(
+ new Int64(-4503599627370495).toDouble(), same(-4503599627370495.0));
+ expect(
+ new Int64(-4503599627370496).toDouble(), same(-4503599627370496.0));
expect(Int64.parseInt("-10000000000000000").toDouble().toStringAsFixed(1),
"-10000000000000000.0");
expect(Int64.parseInt("-10000000000000001").toDouble().toStringAsFixed(1),
@@ -705,13 +718,13 @@
});
test("toBytes", () {
- expect(new Int64(0).toBytes(), [ 0, 0, 0, 0, 0, 0, 0, 0 ]);
+ expect(new Int64(0).toBytes(), [0, 0, 0, 0, 0, 0, 0, 0]);
expect(new Int64.fromInts(0x08070605, 0x04030201).toBytes(),
- [ 1, 2, 3, 4, 5, 6, 7, 8 ]);
+ [1, 2, 3, 4, 5, 6, 7, 8]);
expect(new Int64.fromInts(0x01020304, 0x05060708).toBytes(),
- [ 8, 7, 6, 5, 4, 3, 2, 1 ]);
+ [8, 7, 6, 5, 4, 3, 2, 1]);
expect(new Int64(-1).toBytes(),
- [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ]);
+ [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]);
});
});
@@ -723,6 +736,7 @@
return n * _factorial(n - new Int64(1));
}
}
+
Int64 fact18 = _factorial(new Int64(18));
Int64 fact17 = _factorial(new Int64(17));
expect(fact18 ~/ fact17, new Int64(18));
@@ -738,6 +752,7 @@
checkInt(int x) {
expect(Int64.parseRadix('$x', 10), new Int64(x));
}
+
checkInt(0);
checkInt(1);
checkInt(-1);
@@ -761,6 +776,7 @@
checkHex(String hexStr, int h, int l) {
expect(Int64.parseHex(hexStr), new Int64.fromInts(h, l));
}
+
checkHex('0', 0, 0);
checkHex('-0', 0, 0);
checkHex('00', 0, 0);
@@ -780,6 +796,7 @@
check(String s, int r, String x) {
expect(Int64.parseRadix(s, r).toString(), x);
}
+
check('ghoul', 36, '27699213');
check('ghoul', 35, '24769346');
// Min and max value.
@@ -798,7 +815,8 @@
check(String s, int r) {
expect(Int64.parseRadix(s, r).toRadixString(r), s);
}
- check("2ppp111222333", 33); // This value & radix requires three chunks.
+
+ check("2ppp111222333", 33); // This value & radix requires three chunks.
});
});
@@ -853,8 +871,8 @@
"111111111111111111111111111111111111111111111111111111111111111");
expect(Int64.MAX_VALUE.toRadixString(3),
"2021110011022210012102010021220101220221");
- expect(Int64.MAX_VALUE.toRadixString(4),
- "13333333333333333333333333333333");
+ expect(
+ Int64.MAX_VALUE.toRadixString(4), "13333333333333333333333333333333");
expect(Int64.MAX_VALUE.toRadixString(5), "1104332401304422434310311212");
expect(Int64.MAX_VALUE.toRadixString(6), "1540241003031030222122211");
expect(Int64.MAX_VALUE.toRadixString(7), "22341010611245052052300");