Bring back the deleted 1.0 corelib tests.

What is dead may never die.

Change-Id: I80ef766b8ce2b6e1416df8e1f9b91fb74169dc79
Reviewed-on: https://dart-review.googlesource.com/7483
Reviewed-by: William Hesse <whesse@google.com>
This commit is contained in:
Bob Nystrom 2017-09-21 18:29:40 +00:00
parent 8762998d96
commit edee53f93d
340 changed files with 41929 additions and 0 deletions

View file

@ -102,6 +102,7 @@ def _CheckNewTests(input_api, output_api):
# Dart 1 tests DDC tests
# ================= ==========================
("tests/language/", "tests/language_2/"),
("tests/corelib/", "tests/corelib_2/"),
("tests/lib/", "tests/lib_2/"),
("tests/html/", "tests/lib_2/html/"),
]

View file

@ -0,0 +1,96 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
apply(Function function, List positional, Map<Symbol, dynamic> named) {
return Function.apply(function, positional, named);
}
void throwsNSME(function, positional, named) {
Expect.throws(
() => apply(function, positional, named), (e) => e is NoSuchMethodError);
}
main() {
var c1 = () => 'c1';
var c2 = (a) => 'c2 $a';
var c3 = ([a = 1]) => 'c3 $a';
var c4 = ({a: 1}) => 'c4 $a';
var c5 = ({a: 1, b: 2}) => 'c5 $a $b';
var c6 = ({b: 1, a: 2}) => 'c6 $a $b';
var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b';
var c8 = (x, y, [a = 2, b = 3]) => 'c8 $x $y $a $b';
Expect.equals('c1', apply(c1, null, null));
Expect.equals('c1', apply(c1, [], null));
Expect.equals('c1', apply(c1, [], {}));
Expect.equals('c1', apply(c1, null, {}));
throwsNSME(c1, [1], null);
throwsNSME(c1, [1], {#a: 2});
throwsNSME(c1, null, {#a: 2});
Expect.equals('c2 1', apply(c2, [1], null));
Expect.equals('c2 1', apply(c2, [1], {}));
throwsNSME(c2, null, null);
throwsNSME(c2, [], null);
throwsNSME(c2, null, {});
throwsNSME(c2, null, {#a: 1});
throwsNSME(c2, [2], {#a: 1});
Expect.equals('c3 1', apply(c3, null, null));
Expect.equals('c3 1', apply(c3, [], null));
Expect.equals('c3 2', apply(c3, [2], {}));
throwsNSME(c3, [1, 2], null);
throwsNSME(c3, null, {#a: 1});
Expect.equals('c4 1', apply(c4, [], null));
Expect.equals('c4 2', apply(c4, [], {#a: 2}));
Expect.equals('c4 1', apply(c4, null, null));
Expect.equals('c4 1', apply(c4, [], {}));
throwsNSME(c4, [1], {#a: 1});
throwsNSME(c4, [1], {});
throwsNSME(c4, [], {#a: 1, #b: 2});
Expect.equals('c5 1 2', apply(c5, [], null));
Expect.equals('c5 3 2', apply(c5, [], {#a: 3}));
Expect.equals('c5 1 2', apply(c5, null, null));
Expect.equals('c5 1 2', apply(c5, [], {}));
Expect.equals('c5 3 4', apply(c5, [], {#a: 3, #b: 4}));
Expect.equals('c5 4 3', apply(c5, [], {#b: 3, #a: 4}));
Expect.equals('c5 1 3', apply(c5, [], {#b: 3}));
throwsNSME(c5, [1], {#a: 1});
throwsNSME(c5, [1], {});
throwsNSME(c5, [], {#a: 1, #b: 2, #c: 3});
Expect.equals('c6 2 1', apply(c6, [], null));
Expect.equals('c6 3 1', apply(c6, [], {#a: 3}));
Expect.equals('c6 2 1', apply(c6, null, null));
Expect.equals('c6 2 1', apply(c6, [], {}));
Expect.equals('c6 3 4', apply(c6, [], {#a: 3, #b: 4}));
Expect.equals('c6 4 3', apply(c6, [], {#b: 3, #a: 4}));
Expect.equals('c6 2 3', apply(c6, [], {#b: 3}));
throwsNSME(c6, [1], {#a: 1});
throwsNSME(c6, [1], {});
throwsNSME(c6, [], {#a: 1, #b: 2, #c: 3});
Expect.equals('c7 7 2 1', apply(c7, [7], null));
Expect.equals('c7 7 3 1', apply(c7, [7], {#a: 3}));
Expect.equals('c7 7 2 1', apply(c7, [7], {}));
Expect.equals('c7 7 3 4', apply(c7, [7], {#a: 3, #b: 4}));
Expect.equals('c7 7 4 3', apply(c7, [7], {#b: 3, #a: 4}));
Expect.equals('c7 7 2 3', apply(c7, [7], {#b: 3}));
throwsNSME(c7, [], {#a: 1});
throwsNSME(c7, [], {});
throwsNSME(c7, [7], {#a: 1, #b: 2, #c: 3});
Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], null));
Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], {}));
Expect.equals('c8 7 8 3 3', apply(c8, [7, 8, 3], null));
Expect.equals('c8 7 8 3 4', apply(c8, [7, 8, 3, 4], null));
throwsNSME(c8, [], null);
throwsNSME(c8, [], {});
throwsNSME(c8, [1], null);
throwsNSME(c8, [7, 8, 9, 10, 11], null);
}

View file

@ -0,0 +1,69 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Test [Function.apply] on user-defined classes that implement [noSuchMethod].
import "package:expect/expect.dart";
import 'dart:mirrors';
class F {
call([p1]) => "call";
noSuchMethod(Invocation invocation) => "NSM";
}
class G {
call() => '42';
noSuchMethod(Invocation invocation) => invocation;
}
class H {
call(required, {a}) => required + a;
}
main() {
Expect.equals('call', Function.apply(new F(), []));
Expect.equals('call', Function.apply(new F(), [1]));
Expect.equals('NSM', Function.apply(new F(), [1, 2]));
Expect.equals('NSM', Function.apply(new F(), [1, 2, 3]));
var symbol = const Symbol('a');
var requiredParameters = [1];
var optionalParameters = new Map()..[symbol] = 42;
Invocation i =
Function.apply(new G(), requiredParameters, optionalParameters);
Expect.equals(const Symbol('call'), i.memberName);
Expect.listEquals(requiredParameters, i.positionalArguments);
Expect.mapEquals(optionalParameters, i.namedArguments);
Expect.isTrue(i.isMethod);
Expect.isFalse(i.isGetter);
Expect.isFalse(i.isSetter);
Expect.isFalse(i.isAccessor);
// Check that changing the passed list and map for parameters does
// not affect [i].
requiredParameters[0] = 42;
optionalParameters[symbol] = 12;
Expect.listEquals([1], i.positionalArguments);
Expect.mapEquals(new Map()..[symbol] = 42, i.namedArguments);
// Check that using [i] for invocation yields the same [Invocation]
// object.
var mirror = reflect(new G());
Invocation other = mirror.delegate(i);
Expect.equals(i.memberName, other.memberName);
Expect.listEquals(i.positionalArguments, other.positionalArguments);
Expect.mapEquals(i.namedArguments, other.namedArguments);
Expect.equals(i.isMethod, other.isMethod);
Expect.equals(i.isGetter, other.isGetter);
Expect.equals(i.isSetter, other.isSetter);
Expect.equals(i.isAccessor, other.isAccessor);
// Test that [i] can be used to hit an existing method.
Expect.equals(43, new H().call(1, a: 42));
Expect.equals(43, Function.apply(new H(), [1], new Map()..[symbol] = 42));
mirror = reflect(new H());
Expect.equals(43, mirror.delegate(i));
Expect.equals(43, mirror.delegate(other));
}

View file

@ -0,0 +1,20 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Testing Function.apply calls work correctly for arities that are not
// otherwise present in the program (and thus might not have stubs
// generated).
class A {
foo(x, [y, z, a, b, c, d = 99, e, f, g, h, i, j]) => "$x $d";
}
main() {
var a = new A();
var clos = a.foo;
Expect.equals(Function.apply(clos, ["well"]), "well 99");
Expect.equals(Function.apply(clos, ["well", 0, 2, 4, 3, 6, 9, 10]), "well 9");
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Testing that, when compiled to JS, Function.apply works correctly for
// functions with that will be invoked directly vs using .apply().
class A {
foo([a = 10, b = 20, c = 30, d = 40, e = 50]) => "$a $b $c $d $e";
}
main() {
var a = new A();
var clos = a.foo;
Expect.equals(Function.apply(clos, []), "10 20 30 40 50");
Expect.equals(Function.apply(clos, [11]), "11 20 30 40 50");
Expect.equals(Function.apply(clos, [11, 21]), "11 21 30 40 50");
Expect.equals(Function.apply(clos, [11, 21, 31]), "11 21 31 40 50");
Expect.equals(Function.apply(clos, [11, 21, 31, 41]), "11 21 31 41 50");
Expect.equals(Function.apply(clos, [11, 21, 31, 41, 51]), "11 21 31 41 51");
}

View file

@ -0,0 +1,76 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import "symbol_map_helper.dart";
// Testing Function.apply calls correctly.
// This test is not testing error handling, only that correct parameters
// cause a correct call.
int test0() => 42;
int test0a({int a}) => 37 + a;
int test1(int i) => i + 1;
int test1a(int i, {int a}) => i + a;
int test2(int i, int j) => i + j;
int test2a(int i, int j, {int a}) => i + j + a;
class C {
int x = 10;
int foo(y) => this.x + y;
}
class Callable {
int call(int x, int y) => x + y;
}
@NoInline()
@AssumeDynamic()
confuse(x) => x;
main() {
testMap(res, func, map) {
map = symbolMapToStringMap(map);
Expect.equals(res, Function.apply(func, null, map));
Expect.equals(res, Function.apply(func, [], map));
}
testList(res, func, list) {
Expect.equals(res, Function.apply(func, list));
Expect.equals(res, Function.apply(func, list, null));
Expect.equals(res, Function.apply(func, list, new Map<Symbol, dynamic>()));
}
test(res, func, list, map) {
map = symbolMapToStringMap(map);
Expect.equals(res, Function.apply(func, list, map));
}
testList(42, test0, null);
testList(42, test0, []);
testMap(42, test0a, {"a": 5});
testList(42, test1, [41]);
test(42, test1a, [20], {"a": 22});
testList(42, test2, [20, 22]);
test(42, test2a, [10, 15], {"a": 17});
// Test that "this" is correct when calling closurized functions.
var cfoo = new C().foo;
testList(42, cfoo, [32]);
// Test that apply works even with a different name.
var app = confuse(Function.apply);
Expect.equals(42, app(test2, [22, 20]));
// Test that apply can itself be applied.
Expect.equals(
42,
Function.apply(Function.apply, [
test2,
[17, 25]
]));
// Test that apply works on callable objects.
testList(42, new Callable(), [13, 29]);
}

View file

@ -0,0 +1,447 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints with and without intrinsics.
// VMOptions=
// VMOptions=--no_intrinsify
// VMOptions=--no-background-compilation
// VMOptions=--optimization_counter_threshold=10 --no-background_compilation
library big_integer_test;
import "package:expect/expect.dart";
foo() => 1234567890123456789;
bar() => 12345678901234567890;
testSmiOverflow() {
var a = 1073741823;
var b = 1073741822;
Expect.equals(2147483645, a + b);
a = -1000000000;
b = 1000000001;
Expect.equals(-2000000001, a - b);
Expect.equals(-1000000001000000000, a * b);
}
testBigintAdd() {
// Bigint and Smi.
var a = 12345678901234567890;
var b = 2;
Expect.equals(12345678901234567892, a + b);
Expect.equals(12345678901234567892, b + a);
// Bigint and Bigint.
a = 10000000000000000001;
Expect.equals(20000000000000000002, a + a);
// Bigint and double.
a = 100000000000000000000.0;
b = 200000000000000000000;
Expect.isTrue((a + b) is double);
Expect.equals(300000000000000000000.0, a + b);
Expect.isTrue((b + a) is double);
Expect.equals(300000000000000000000.0, b + a);
}
testBigintSub() {
// Bigint and Smi.
var a = 12345678901234567890;
var b = 2;
Expect.equals(12345678901234567888, a - b);
Expect.equals(-12345678901234567888, b - a);
// Bigint and Bigint.
a = 10000000000000000001;
Expect.equals(20000000000000000002, a + a);
// Bigint and double.
a = 100000000000000000000.0;
b = 200000000000000000000;
Expect.isTrue((a + b) is double);
Expect.equals(-100000000000000000000.0, a - b);
Expect.isTrue((b + a) is double);
Expect.equals(100000000000000000000.0, b - a);
Expect.equals(-1, 0xF00000000 - 0xF00000001);
}
testBigintMul() {
// Bigint and Smi.
var a = 12345678901234567890;
var b = 10;
Expect.equals(123456789012345678900, a * b);
Expect.equals(123456789012345678900, b * a);
// Bigint and Bigint.
a = 12345678901234567890;
b = 10000000000000000;
Expect.equals(123456789012345678900000000000000000, a * b);
// Bigint and double.
a = 2.0;
b = 200000000000000000000;
Expect.isTrue((a * b) is double);
Expect.equals(400000000000000000000.0, a * b);
Expect.isTrue((b * a) is double);
Expect.equals(400000000000000000000.0, b * a);
}
testBigintTruncDiv() {
var a = 12345678901234567890;
var b = 10;
// Bigint and Smi.
Expect.equals(1234567890123456789, a ~/ b);
Expect.equals(0, b ~/ a);
Expect.equals(123456789, 123456789012345678 ~/ 1000000000);
// Bigint and Bigint.
a = 12345678901234567890;
b = 10000000000000000;
Expect.equals(1234, a ~/ b);
// Bigint and double.
a = 100000000000000000000.0;
b = 200000000000000000000;
Expect.equals(0, a ~/ b);
Expect.equals(2, b ~/ a);
}
testBigintDiv() {
// Bigint and Smi.
Expect.equals(1234567890123456789.1, 12345678901234567891 / 10);
Expect.equals(0.000000001234, 1234 / 1000000000000);
Expect.equals(12345678901234000000.0, 123456789012340000000 / 10);
// Bigint and Bigint.
var a = 12345670000000000000;
var b = 10000000000000000;
Expect.equals(1234.567, a / b);
// Bigint and double.
a = 400000000000000000000.0;
b = 200000000000000000000;
Expect.equals(2.0, a / b);
Expect.equals(0.5, b / a);
}
testBigintModulo() {
// Bigint and Smi.
var a = 1000000000005;
var b = 10;
Expect.equals(5, a % b);
Expect.equals(10, b % a);
// Bigint & Bigint
a = 10000000000000000001;
b = 10000000000000000000;
Expect.equals(1, a % b);
Expect.equals(10000000000000000000, b % a);
// Bigint & double.
a = 10000000100000000.0;
b = 10000000000000000;
Expect.equals(100000000.0, a % b);
Expect.equals(10000000000000000.0, b % a);
// Transitioning from Mint to Bigint.
var iStart = 4611686018427387900;
var prevX = -23 % iStart;
for (int i = iStart + 1; i < iStart + 10; i++) {
var x = -23 % i;
Expect.equals(1, x - prevX);
Expect.isTrue(x > 0);
prevX = x;
}
}
testBigintModPow() {
var x, e, m;
x = 1234567890;
e = 1000000001;
m = 19;
Expect.equals(11, x.modPow(e, m));
x = 1234567890;
e = 19;
m = 1000000001;
Expect.equals(122998977, x.modPow(e, m));
x = 19;
e = 1234567890;
m = 1000000001;
Expect.equals(619059596, x.modPow(e, m));
x = 19;
e = 1000000001;
m = 1234567890;
Expect.equals(84910879, x.modPow(e, m));
x = 1000000001;
e = 19;
m = 1234567890;
Expect.equals(872984351, x.modPow(e, m));
x = 1000000001;
e = 1234567890;
m = 19;
Expect.equals(0, x.modPow(e, m));
x = 12345678901234567890;
e = 10000000000000000001;
m = 19;
Expect.equals(2, x.modPow(e, m));
x = 12345678901234567890;
e = 19;
m = 10000000000000000001;
Expect.equals(3239137215315834625, x.modPow(e, m));
x = 19;
e = 12345678901234567890;
m = 10000000000000000001;
Expect.equals(4544207837373941034, x.modPow(e, m));
x = 19;
e = 10000000000000000001;
m = 12345678901234567890;
Expect.equals(11135411705397624859, x.modPow(e, m));
x = 10000000000000000001;
e = 19;
m = 12345678901234567890;
Expect.equals(2034013733189773841, x.modPow(e, m));
x = 10000000000000000001;
e = 12345678901234567890;
m = 19;
Expect.equals(1, x.modPow(e, m));
x = 12345678901234567890;
e = 19;
m = 10000000000000000001;
Expect.equals(3239137215315834625, x.modPow(e, m));
x = 12345678901234567890;
e = 10000000000000000001;
m = 19;
Expect.equals(2, x.modPow(e, m));
x = 123456789012345678901234567890;
e = 123456789012345678901234567891;
m = 123456789012345678901234567899;
Expect.equals(116401406051033429924651549616, x.modPow(e, m));
x = 123456789012345678901234567890;
e = 123456789012345678901234567899;
m = 123456789012345678901234567891;
Expect.equals(123456789012345678901234567890, x.modPow(e, m));
x = 123456789012345678901234567899;
e = 123456789012345678901234567890;
m = 123456789012345678901234567891;
Expect.equals(35088523091000351053091545070, x.modPow(e, m));
x = 123456789012345678901234567899;
e = 123456789012345678901234567891;
m = 123456789012345678901234567890;
Expect.equals(18310047270234132455316941949, x.modPow(e, m));
x = 123456789012345678901234567891;
e = 123456789012345678901234567899;
m = 123456789012345678901234567890;
Expect.equals(1, x.modPow(e, m));
x = 123456789012345678901234567891;
e = 123456789012345678901234567890;
m = 123456789012345678901234567899;
Expect.equals(40128068573873018143207285483, x.modPow(e, m));
}
testBigintModInverse() {
var x, m;
x = 1;
m = 1;
Expect.equals(0, x.modInverse(m));
x = 0;
m = 1000000001;
Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
x = 1234567890;
m = 19;
Expect.equals(11, x.modInverse(m));
x = 1234567890;
m = 1000000001;
Expect.equals(189108911, x.modInverse(m));
x = 19;
m = 1000000001;
Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
x = 19;
m = 1234567890;
Expect.equals(519818059, x.modInverse(m));
x = 1000000001;
m = 1234567890;
Expect.equals(1001100101, x.modInverse(m));
x = 1000000001;
m = 19;
Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
x = 12345678901234567890;
m = 19;
Expect.equals(3, x.modInverse(m));
x = 12345678901234567890;
m = 10000000000000000001;
Expect.equals(9736746307686209582, x.modInverse(m));
x = 19;
m = 10000000000000000001;
Expect.equals(6315789473684210527, x.modInverse(m));
x = 19;
m = 12345678901234567890;
Expect.equals(10396361179987004539, x.modInverse(m));
x = 10000000000000000001;
m = 12345678901234567890;
Expect.equals(325004555487045911, x.modInverse(m));
x = 10000000000000000001;
m = 19;
Expect.equals(7, x.modInverse(m));
x = 12345678901234567890;
m = 10000000000000000001;
Expect.equals(9736746307686209582, x.modInverse(m));
x = 12345678901234567890;
m = 19;
Expect.equals(3, x.modInverse(m));
x = 123456789012345678901234567890;
m = 123456789012345678901234567899;
Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
x = 123456789012345678901234567890;
m = 123456789012345678901234567891;
Expect.equals(123456789012345678901234567890, x.modInverse(m));
x = 123456789012345678901234567899;
m = 123456789012345678901234567891;
Expect.equals(77160493132716049313271604932, x.modInverse(m));
x = 123456789012345678901234567899;
m = 123456789012345678901234567890;
Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
x = 123456789012345678901234567891;
m = 123456789012345678901234567890;
Expect.equals(1, x.modInverse(m));
x = 123456789012345678901234567891;
m = 123456789012345678901234567899;
Expect.equals(46296295879629629587962962962, x.modInverse(m));
}
testBigintGcd() {
var x, m;
x = 1;
m = 1;
Expect.equals(1, x.gcd(m));
x = 693;
m = 609;
Expect.equals(21, x.gcd(m));
x = 693 << 40;
m = 609 << 40;
Expect.equals(21 << 40, x.gcd(m));
x = 609 << 40;
;
m = 693 << 40;
;
Expect.equals(21 << 40, x.gcd(m));
x = 0;
m = 1000000001;
Expect.equals(m, x.gcd(m));
x = 1000000001;
m = 0;
Expect.equals(x, x.gcd(m));
x = 0;
m = -1000000001;
Expect.equals(-m, x.gcd(m));
x = -1000000001;
m = 0;
Expect.equals(-x, x.gcd(m));
x = 0;
m = 0;
Expect.equals(0, x.gcd(m));
x = 0;
m = 123456789012345678901234567890;
Expect.equals(m, x.gcd(m));
x = 123456789012345678901234567890;
m = 0;
Expect.equals(x, x.gcd(m));
x = 0;
m = -123456789012345678901234567890;
Expect.equals(-m, x.gcd(m));
x = -123456789012345678901234567890;
m = 0;
Expect.equals(-x, x.gcd(m));
x = 1234567890;
m = 19;
Expect.equals(1, x.gcd(m));
x = 1234567890;
m = 1000000001;
Expect.equals(1, x.gcd(m));
x = 19;
m = 1000000001;
Expect.equals(19, x.gcd(m));
x = 19;
m = 1234567890;
Expect.equals(1, x.gcd(m));
x = 1000000001;
m = 1234567890;
Expect.equals(1, x.gcd(m));
x = 1000000001;
m = 19;
Expect.equals(19, x.gcd(m));
x = 12345678901234567890;
m = 19;
Expect.equals(1, x.gcd(m));
x = 12345678901234567890;
m = 10000000000000000001;
Expect.equals(1, x.gcd(m));
x = 19;
m = 10000000000000000001;
Expect.equals(1, x.gcd(m));
x = 19;
m = 12345678901234567890;
Expect.equals(1, x.gcd(m));
x = 10000000000000000001;
m = 12345678901234567890;
Expect.equals(1, x.gcd(m));
x = 10000000000000000001;
m = 19;
Expect.equals(1, x.gcd(m));
x = 12345678901234567890;
m = 10000000000000000001;
Expect.equals(1, x.gcd(m));
x = 12345678901234567890;
m = 19;
Expect.equals(1, x.gcd(m));
x = 123456789012345678901234567890;
m = 123456789012345678901234567899;
Expect.equals(9, x.gcd(m));
x = 123456789012345678901234567890;
m = 123456789012345678901234567891;
Expect.equals(1, x.gcd(m));
x = 123456789012345678901234567899;
m = 123456789012345678901234567891;
Expect.equals(1, x.gcd(m));
x = 123456789012345678901234567899;
m = 123456789012345678901234567890;
Expect.equals(9, x.gcd(m));
x = 123456789012345678901234567891;
m = 123456789012345678901234567890;
Expect.equals(1, x.gcd(m));
x = 123456789012345678901234567891;
m = 123456789012345678901234567899;
Expect.equals(1, x.gcd(m));
}
testBigintNegate() {
var a = 0xF000000000000000F;
var b = ~a; // negate.
Expect.equals(-0xF0000000000000010, b);
Expect.equals(0, a & b);
Expect.equals(-1, a | b);
}
testShiftAmount() {
Expect.equals(0, 12 >> 111111111111111111111111111111);
Expect.equals(-1, -12 >> 111111111111111111111111111111);
bool exceptionCaught = false;
try {
var a = 1 << 1111111111111111111111111111;
} on OutOfMemoryError catch (e) {
exceptionCaught = true;
}
Expect.equals(true, exceptionCaught);
}
main() {
for (int i = 0; i < 10; i++) {
Expect.equals(1234567890123456789, foo());
Expect.equals(12345678901234567890, bar());
testSmiOverflow(); // //# overflow: ok
testBigintAdd(); // //# add: ok
testBigintSub(); // //# sub: ok
testBigintMul(); // //# mul: ok
testBigintTruncDiv(); // //# trunDiv: ok
testBigintDiv(); // //# div: ok
testBigintModulo(); // //# mod: ok
testBigintModPow(); // //# modPow: ok
testBigintModInverse(); // //# modInv: ok
testBigintGcd(); // //# gcd: ok
testBigintNegate(); // //# negate: ok
testShiftAmount(); // //# shift: ok
Expect.equals(12345678901234567890, (12345678901234567890).abs());
Expect.equals(12345678901234567890, (-12345678901234567890).abs());
var a = 10000000000000000000;
var b = 10000000000000000001;
Expect.equals(false, a.hashCode == b.hashCode);
Expect.equals(true, a.hashCode == (b - 1).hashCode);
}
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints with and without intrinsics.
// VMOptions=
// VMOptions=--no_intrinsify
library big_integer_test;
import "package:expect/expect.dart";
testBigintHugeMul() {
var bits = 65536;
var a = 1 << bits;
var a1 = a - 1; // all 1's
var p1 = a1 * a1;
var p2 = a * a - a - a + 1;
// Use isTrue instead of equals to avoid trying to print such big numbers.
Expect.isTrue(p1 == p2, 'products do not match');
}
main() {
testBigintHugeMul();
}

View file

@ -0,0 +1,601 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints with and without intrinsics.
// VMOptions=
// VMOptions=--no_intrinsify
library big_integer_test;
import "package:expect/expect.dart";
addSubParsed(String a, String b, String sum) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_sum = int.parse(sum);
int computed_sum = int_a + int_b;
Expect.equals(int_sum, computed_sum);
String str_sum = computed_sum >= 0
? "0x${computed_sum.toRadixString(16)}"
: "-0x${(-computed_sum).toRadixString(16)}";
Expect.equals(sum.toLowerCase(), str_sum);
int computed_difference1 = int_sum - int_a;
Expect.equals(int_b, computed_difference1);
String str_difference1 = computed_difference1 >= 0
? "0x${computed_difference1.toRadixString(16)}"
: "-0x${(-computed_difference1).toRadixString(16)}";
Expect.equals(b.toLowerCase(), str_difference1);
int computed_difference2 = int_sum - int_b;
Expect.equals(int_a, computed_difference2);
String str_difference2 = computed_difference2 >= 0
? "0x${computed_difference2.toRadixString(16)}"
: "-0x${(-computed_difference2).toRadixString(16)}";
Expect.equals(a.toLowerCase(), str_difference2);
}
testBigintAddSub() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
addSubParsed(zero, zero, zero);
addSubParsed(zero, one, one);
addSubParsed(one, zero, one);
addSubParsed(one, one, "0x2");
addSubParsed(minus_one, minus_one, "-0x2");
addSubParsed("0x123", zero, "0x123");
addSubParsed(zero, "0x123", "0x123");
addSubParsed("0x123", one, "0x124");
addSubParsed(one, "0x123", "0x124");
addSubParsed(
"0xFFFFFFF",
one, // 28 bit overflow.
"0x10000000");
addSubParsed(
"0xFFFFFFFF",
one, // 32 bit overflow.
"0x100000000");
addSubParsed(
"0xFFFFFFFFFFFFFF",
one, // 56 bit overflow.
"0x100000000000000");
addSubParsed(
"0xFFFFFFFFFFFFFFFF",
one, // 64 bit overflow.
"0x10000000000000000");
addSubParsed(
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", // 128 bit.
one,
"0x100000000000000000000000000000000");
addSubParsed("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", one,
"0x10000000000000000000000000000000000000000000");
addSubParsed(
"0x8000000", // 28 bit overflow.
"0x8000000",
"0x10000000");
addSubParsed(
"0x80000000", // 32 bit overflow.
"0x80000000",
"0x100000000");
addSubParsed(
"0x80000000000000", // 56 bit overflow.
"0x80000000000000",
"0x100000000000000");
addSubParsed(
"0x8000000000000000", // 64 bit overflow.
"0x8000000000000000",
"0x10000000000000000");
addSubParsed(
"0x80000000000000000000000000000000", // 128 bit.
"0x80000000000000000000000000000000",
"0x100000000000000000000000000000000");
addSubParsed(
"0x8000000000000000000000000000000000000000000",
"0x8000000000000000000000000000000000000000000",
"0x10000000000000000000000000000000000000000000");
{
String a = "0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF0";
String sum1 = "0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF1";
String times2 = "0x2468ACF13579BDE02468ACF121579BDE02468ACF13579BDE0";
addSubParsed(a, zero, a);
addSubParsed(a, one, sum1);
addSubParsed(a, a, times2);
}
addSubParsed("-0x123", minus_one, "-0x124");
addSubParsed(minus_one, "-0x123", "-0x124");
addSubParsed(
"-0xFFFFFFF",
minus_one, // 28 bit overflow.
"-0x10000000");
addSubParsed(
"-0xFFFFFFFF",
minus_one, // 32 bit overflow.
"-0x100000000");
addSubParsed(
"-0xFFFFFFFFFFFFFF",
minus_one, // 56 bit overflow.
"-0x100000000000000");
addSubParsed(
"-0xFFFFFFFFFFFFFFFF",
minus_one, // 64 bit overflow.
"-0x10000000000000000");
addSubParsed(
"-0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", // 128 bit.
minus_one,
"-0x100000000000000000000000000000000");
addSubParsed("-0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", minus_one,
"-0x10000000000000000000000000000000000000000000");
addSubParsed(
"-0x8000000", // 28 bit overflow.
"-0x8000000",
"-0x10000000");
addSubParsed(
"-0x80000000", // 32 bit overflow.
"-0x80000000",
"-0x100000000");
addSubParsed(
"-0x80000000000000", // 56 bit overflow.
"-0x80000000000000",
"-0x100000000000000");
addSubParsed(
"-0x8000000000000000", // 64 bit overflow.
"-0x8000000000000000",
"-0x10000000000000000");
addSubParsed(
"-0x80000000000000000000000000000000", // 128 bit.
"-0x80000000000000000000000000000000",
"-0x100000000000000000000000000000000");
addSubParsed(
"-0x8000000000000000000000000000000000000000000",
"-0x8000000000000000000000000000000000000000000",
"-0x10000000000000000000000000000000000000000000");
{
String a = "-0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF0";
String sum1 = "-0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF1";
String times2 = "-0x2468ACF13579BDE02468ACF121579BDE02468ACF13579BDE0";
addSubParsed(a, zero, a);
addSubParsed(a, minus_one, sum1);
addSubParsed(a, a, times2);
}
addSubParsed("0x10000000000000000000000000000000000000000000", "0xFFFF",
"0x1000000000000000000000000000000000000000FFFF");
addSubParsed("0x10000000000000000000000000000000000000000000",
"0xFFFF00000000", "0x10000000000000000000000000000000FFFF00000000");
addSubParsed("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "0x100000000",
"0x1000000000000000000000000000000000000FFFFFFFF");
addSubParsed(
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"0x10000000000000000000",
"0x10000000000000000000000000FFFFFFFFFFFFFFFFFFF");
addSubParsed("0xB", "-0x7", "0x4");
addSubParsed("-0xB", "-0x7", "-0x12");
addSubParsed("0xB", "0x7", "0x12");
addSubParsed("-0xB", "0x7", "-0x4");
addSubParsed("-0x7", "0xB", "0x4");
addSubParsed("-0x7", "-0xB", "-0x12");
addSubParsed("0x7", "0xB", "0x12");
addSubParsed("0x7", "-0xB", "-0x4");
}
shiftLeftParsed(String a, int amount, String result) {
int int_a = int.parse(a);
int int_result = int.parse(result);
int shifted = int_a << amount;
Expect.equals(int_result, shifted);
String str_shifted = shifted >= 0
? "0x${shifted.toRadixString(16)}"
: "-0x${(-shifted).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_shifted);
int back_shifted = shifted >> amount;
Expect.equals(int_a, back_shifted);
String str_back_shifted = back_shifted >= 0
? "0x${back_shifted.toRadixString(16)}"
: "-0x${(-back_shifted).toRadixString(16)}";
Expect.equals(a.toLowerCase(), str_back_shifted);
}
testBigintLeftShift() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
shiftLeftParsed(zero, 0, zero);
shiftLeftParsed(one, 0, one);
shiftLeftParsed("0x1234", 0, "0x1234");
shiftLeftParsed(zero, 100000, zero);
shiftLeftParsed(one, 1, "0x2");
shiftLeftParsed(one, 28, "0x10000000");
shiftLeftParsed(one, 32, "0x100000000");
shiftLeftParsed(one, 64, "0x10000000000000000");
shiftLeftParsed("0x5", 28, "0x50000000");
shiftLeftParsed("0x5", 32, "0x500000000");
shiftLeftParsed("0x5", 56, "0x500000000000000");
shiftLeftParsed("0x5", 64, "0x50000000000000000");
shiftLeftParsed("0x5", 128, "0x500000000000000000000000000000000");
shiftLeftParsed("0x5", 27, "0x28000000");
shiftLeftParsed("0x5", 31, "0x280000000");
shiftLeftParsed("0x5", 55, "0x280000000000000");
shiftLeftParsed("0x5", 63, "0x28000000000000000");
shiftLeftParsed("0x5", 127, "0x280000000000000000000000000000000");
shiftLeftParsed("0x8000001", 1, "0x10000002");
shiftLeftParsed("0x80000001", 1, "0x100000002");
shiftLeftParsed("0x8000000000000001", 1, "0x10000000000000002");
shiftLeftParsed("0x8000001", 29, "0x100000020000000");
shiftLeftParsed("0x80000001", 33, "0x10000000200000000");
shiftLeftParsed(
"0x8000000000000001", 65, "0x100000000000000020000000000000000");
shiftLeftParsed(minus_one, 0, minus_one);
shiftLeftParsed("-0x1234", 0, "-0x1234");
shiftLeftParsed(minus_one, 1, "-0x2");
shiftLeftParsed(minus_one, 28, "-0x10000000");
shiftLeftParsed(minus_one, 32, "-0x100000000");
shiftLeftParsed(minus_one, 64, "-0x10000000000000000");
shiftLeftParsed("-0x5", 28, "-0x50000000");
shiftLeftParsed("-0x5", 32, "-0x500000000");
shiftLeftParsed("-0x5", 64, "-0x50000000000000000");
shiftLeftParsed("-0x5", 27, "-0x28000000");
shiftLeftParsed("-0x5", 31, "-0x280000000");
shiftLeftParsed("-0x5", 63, "-0x28000000000000000");
shiftLeftParsed("-0x8000001", 1, "-0x10000002");
shiftLeftParsed("-0x80000001", 1, "-0x100000002");
shiftLeftParsed("-0x8000000000000001", 1, "-0x10000000000000002");
shiftLeftParsed("-0x8000001", 29, "-0x100000020000000");
shiftLeftParsed("-0x80000001", 33, "-0x10000000200000000");
shiftLeftParsed(
"-0x8000000000000001", 65, "-0x100000000000000020000000000000000");
}
shiftRightParsed(String a, int amount, String result) {
int int_a = int.parse(a);
int int_result = int.parse(result);
int shifted = int_a >> amount;
Expect.equals(int_result, shifted);
String str_shifted = shifted >= 0
? "0x${shifted.toRadixString(16)}"
: "-0x${(-shifted).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_shifted);
}
testBigintRightShift() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
shiftRightParsed(one, 1, zero);
shiftRightParsed(minus_one, 1, minus_one);
shiftRightParsed("-0x2", 1, minus_one);
shiftRightParsed("0x12345678", 29, zero);
shiftRightParsed("-0x12345678", 29, minus_one);
shiftRightParsed("-0x12345678", 100, minus_one);
shiftRightParsed("0x5", 1, "0x2");
shiftRightParsed("0x5", 2, "0x1");
shiftRightParsed("-0x5", 1, "-0x3");
shiftRightParsed("-0x5", 2, "-0x2");
shiftRightParsed("0x10000001", 28, one);
shiftRightParsed("0x100000001", 32, one);
shiftRightParsed("0x10000000000000001", 64, one);
shiftRightParsed("-0x10000001", 28, "-0x2");
shiftRightParsed("-0x100000001", 32, "-0x2");
shiftRightParsed("-0x10000000000000001", 64, "-0x2");
shiftRightParsed("0x30000000", 29, one);
shiftRightParsed("0x300000000", 33, one);
shiftRightParsed("0x30000000000000000", 65, one);
shiftRightParsed("-0x30000000", 29, "-0x2");
shiftRightParsed("-0x300000000", 33, "-0x2");
shiftRightParsed("-0x30000000000000000", 65, "-0x2");
}
bitAndParsed(String a, String b, String result) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_result = int.parse(result);
int anded = int_a & int_b;
Expect.equals(int_result, anded);
String str_anded = anded >= 0
? "0x${anded.toRadixString(16)}"
: "-0x${(-anded).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_anded);
int anded2 = int_b & int_a;
Expect.equals(int_result, anded2);
String str_anded2 = anded2 >= 0
? "0x${anded2.toRadixString(16)}"
: "-0x${(-anded2).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_anded2);
}
testBigintBitAnd() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
bitAndParsed(one, zero, zero);
bitAndParsed(one, one, one);
bitAndParsed(minus_one, zero, zero);
bitAndParsed(minus_one, one, one);
bitAndParsed(minus_one, minus_one, minus_one);
bitAndParsed("0x5", "0x3", one);
bitAndParsed("0x5", minus_one, "0x5");
bitAndParsed("0x50000000", one, zero);
bitAndParsed("0x50000000", minus_one, "0x50000000");
bitAndParsed("0x500000000", one, zero);
bitAndParsed("0x500000000", minus_one, "0x500000000");
bitAndParsed("0x50000000000000000", one, zero);
bitAndParsed("0x50000000000000000", minus_one, "0x50000000000000000");
bitAndParsed("-0x50000000", "-0x50000000", "-0x50000000");
bitAndParsed("-0x500000000", "-0x500000000", "-0x500000000");
bitAndParsed(
"-0x50000000000000000", "-0x50000000000000000", "-0x50000000000000000");
bitAndParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321",
"0x224422000A9C9A0002244220");
bitAndParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"-0x977557799FEFCFEF997755778");
bitAndParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"0x101014589002044F010101458");
bitAndParsed(
"0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF",
"-0x876543210FEDCBA0987654321",
"0x1234567890ABCDEF012345678789ABCDEF012345F6789ABCDF");
bitAndParsed("0x12345678", "0xFFFFFFF", "0x2345678");
bitAndParsed("0x123456789", "0xFFFFFFFF", "0x23456789");
bitAndParsed("-0x10000000", "0xFFFFFFF", "0x0");
bitAndParsed("-0x100000000", "0xFFFFFFFF", "0x0");
bitAndParsed("-0x10000001", "0xFFFFFFF", "0xFFFFFFF");
bitAndParsed("-0x100000001", "0xFFFFFFFF", "0xFFFFFFFF");
bitAndParsed("-0x10000001", "0x3FFFFFFF", "0x2FFFFFFF");
bitAndParsed("-0x100000001", "0x3FFFFFFFF", "0x2FFFFFFFF");
bitAndParsed(
"-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "0x2FFFFFFFFFFFFFFFF");
bitAndParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "0x0");
bitAndParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "0x0");
bitAndParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "0xD00000000000000");
bitAndParsed(
"-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "0xD0000000000000000");
bitAndParsed("-0x10000000", "-0x10000000", "-0x10000000");
bitAndParsed("-0x100000000", "-0x100000000", "-0x100000000");
bitAndParsed(
"-0x100000000000000", "-0x100000000000000", "-0x100000000000000");
bitAndParsed(
"-0x10000000000000000", "-0x10000000000000000", "-0x10000000000000000");
bitAndParsed("-0x3", "-0x2", "-0x4");
bitAndParsed("-0x10000000", "-0x10000001", "-0x20000000");
bitAndParsed("-0x100000000", "-0x100000001", "-0x200000000");
bitAndParsed(
"-0x100000000000000", "-0x100000000000001", "-0x200000000000000");
bitAndParsed(
"-0x10000000000000000", "-0x10000000000000001", "-0x20000000000000000");
bitAndParsed(
"0x123456789ABCDEF01234567890",
"0x3FFFFFFF", // Max Smi for 32 bits.
"0x34567890");
bitAndParsed(
"0x123456789ABCDEF01274567890",
"0x3FFFFFFF", // Max Smi for 32 bits.
"0x34567890");
bitAndParsed(
"0x123456789ABCDEF01234567890",
"0x40000000", // Max Smi for 32 bits + 1.
"0x0");
bitAndParsed(
"0x123456789ABCDEF01274567890",
"0x40000000", // Max Smi for 32 bits + 1.
"0x40000000");
bitAndParsed(
"0x123456789ABCDEF01234567890",
"0x3FFFFFFFFFFFFFFF", // Max Smi for 64 bits.
"0x3CDEF01234567890");
bitAndParsed(
"0x123456789ACCDEF01234567890",
"0x4000000000000000", // Max Smi for 64 bits + 1.
"0x4000000000000000");
bitAndParsed(
"0x123456789ABCDEF01234567890",
"0x4000000000000000", // Max Smi for 64 bits + 1.
"0x0");
}
bitOrParsed(String a, String b, String result) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_result = int.parse(result);
int ored = int_a | int_b;
Expect.equals(int_result, ored);
String str_ored = ored >= 0
? "0x${ored.toRadixString(16)}"
: "-0x${(-ored).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_ored);
int ored2 = int_b | int_a;
Expect.equals(int_result, ored2);
String str_ored2 = ored2 >= 0
? "0x${ored2.toRadixString(16)}"
: "-0x${(-ored2).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_ored2);
}
testBigintBitOr() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
bitOrParsed(one, zero, one);
bitOrParsed(one, one, one);
bitOrParsed(minus_one, zero, minus_one);
bitOrParsed(minus_one, one, minus_one);
bitOrParsed(minus_one, minus_one, minus_one);
bitOrParsed("-0x3", one, "-0x3");
bitOrParsed("0x5", "0x3", "0x7");
bitOrParsed("0x5", minus_one, minus_one);
bitOrParsed("0x5", zero, "0x5");
bitOrParsed("0x50000000", one, "0x50000001");
bitOrParsed("0x50000000", minus_one, minus_one);
bitOrParsed("0x500000000", one, "0x500000001");
bitOrParsed("0x500000000", minus_one, minus_one);
bitOrParsed("0x50000000000000000", one, "0x50000000000000001");
bitOrParsed("0x50000000000000000", minus_one, minus_one);
bitOrParsed("-0x50000000", "-0x50000000", "-0x50000000");
bitOrParsed("-0x500000000", "-0x500000000", "-0x500000000");
bitOrParsed(
"-0x50000000000000000", "-0x50000000000000000", "-0x50000000000000000");
bitOrParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321",
"0x977557799FEFCFEF997755779");
bitOrParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"-0x224422000A9C9A0002244221");
bitOrParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"-0x854101010F440200985410101");
bitOrParsed("0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF",
"-0x876543210FEDCBA0987654321", "-0x1");
bitOrParsed("0x12345678", "0xFFFFFFF", "0x1FFFFFFF");
bitOrParsed("0x123456789", "0xFFFFFFFF", "0x1FFFFFFFF");
bitOrParsed("-0x10000000", "0xFFFFFFF", "-0x1");
bitOrParsed("-0x100000000", "0xFFFFFFFF", "-0x1");
bitOrParsed("-0x10000001", "0xFFFFFFF", "-0x10000001");
bitOrParsed("-0x100000001", "0xFFFFFFFF", "-0x100000001");
bitOrParsed("-0x10000001", "0x3FFFFFFF", "-0x1");
bitOrParsed("-0x100000001", "0x3FFFFFFFF", "-0x1");
bitOrParsed("-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "-0x1");
bitOrParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1");
bitOrParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1");
bitOrParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0x1");
bitOrParsed("-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "-0x1");
bitOrParsed("-0x10000000", "-0x10000000", "-0x10000000");
bitOrParsed("-0x100000000", "-0x100000000", "-0x100000000");
bitOrParsed("-0x100000000000000", "-0x100000000000000", "-0x100000000000000");
bitOrParsed(
"-0x10000000000000000", "-0x10000000000000000", "-0x10000000000000000");
bitOrParsed("-0x10000000", "-0x10000001", "-0x1");
bitOrParsed("-0x100000000", "-0x100000001", "-0x1");
bitOrParsed("-0x100000000000000", "-0x100000000000001", "-0x1");
bitOrParsed("-0x10000000000000000", "-0x10000000000000001", "-0x1");
bitOrParsed("-0x10000000000000000", "-0x1", "-0x1");
}
bitXorParsed(String a, String b, String result) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_result = int.parse(result);
int xored = int_a ^ int_b;
Expect.equals(int_result, xored);
String str_xored = xored >= 0
? "0x${xored.toRadixString(16)}"
: "-0x${(-xored).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_xored);
int xored2 = int_b ^ int_a;
Expect.equals(int_result, xored2);
String str_xored2 = xored2 >= 0
? "0x${xored2.toRadixString(16)}"
: "-0x${(-xored2).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_xored2);
int xored3 = int_a ^ xored2;
Expect.equals(int_b, xored3);
String str_xored3 = xored3 >= 0
? "0x${xored3.toRadixString(16)}"
: "-0x${(-xored3).toRadixString(16)}";
Expect.equals(b.toLowerCase(), str_xored3);
}
testBigintBitXor() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
bitXorParsed(one, zero, one);
bitXorParsed(one, one, zero);
bitXorParsed(minus_one, zero, minus_one);
bitXorParsed(minus_one, one, "-0x2");
bitXorParsed(minus_one, minus_one, zero);
bitXorParsed("0x5", "0x3", "0x6");
bitXorParsed("0x5", minus_one, "-0x6");
bitXorParsed("0x5", zero, "0x5");
bitXorParsed(minus_one, "-0x8", "0x7");
bitXorParsed("0x50000000", one, "0x50000001");
bitXorParsed("0x50000000", minus_one, "-0x50000001");
bitXorParsed("0x500000000", one, "0x500000001");
bitXorParsed("0x500000000", minus_one, "-0x500000001");
bitXorParsed("0x50000000000000000", one, "0x50000000000000001");
bitXorParsed("0x50000000000000000", minus_one, "-0x50000000000000001");
bitXorParsed("-0x50000000", "-0x50000000", zero);
bitXorParsed("-0x500000000", "-0x500000000", zero);
bitXorParsed("-0x50000000000000000", "-0x50000000000000000", zero);
bitXorParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321",
"0x955115599F46064F995511559");
bitXorParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"0x955115599F46064F995511557");
bitXorParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321",
"-0x955115599F46064F995511559");
bitXorParsed(
"0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF",
"-0x876543210FEDCBA0987654321",
"-0x1234567890ABCDEF012345678789ABCDEF012345F6789ABCE0");
bitXorParsed("0x12345678", "0xFFFFFFF", "0x1DCBA987");
bitXorParsed("0x123456789", "0xFFFFFFFF", "0x1DCBA9876");
bitXorParsed("-0x10000000", "0xFFFFFFF", "-0x1");
bitXorParsed("-0x100000000", "0xFFFFFFFF", "-0x1");
bitXorParsed("-0x10000001", "0xFFFFFFF", "-0x20000000");
bitXorParsed("-0x100000001", "0xFFFFFFFF", "-0x200000000");
bitXorParsed("-0x10000001", "0x3FFFFFFF", "-0x30000000");
bitXorParsed("-0x100000001", "0x3FFFFFFFF", "-0x300000000");
bitXorParsed(
"-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "-0x30000000000000000");
bitXorParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1");
bitXorParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1");
bitXorParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0xD00000000000001");
bitXorParsed(
"-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "-0xD0000000000000001");
bitXorParsed("-0x10000000", "-0x10000000", zero);
bitXorParsed("-0x100000000", "-0x100000000", zero);
bitXorParsed("-0x100000000000000", "-0x100000000000000", zero);
bitXorParsed("-0x10000000000000000", "-0x10000000000000000", zero);
bitXorParsed("-0x10000000", "-0x10000001", "0x1FFFFFFF");
bitXorParsed("-0x100000000", "-0x100000001", "0x1FFFFFFFF");
bitXorParsed("-0x100000000000000", "-0x100000000000001", "0x1FFFFFFFFFFFFFF");
bitXorParsed(
"-0x10000000000000000", "-0x10000000000000001", "0x1FFFFFFFFFFFFFFFF");
}
bitNotParsed(String a, String result) {
int int_a = int.parse(a);
int int_result = int.parse(result);
int inverted = ~int_a;
Expect.equals(int_result, inverted);
String str_inverted = inverted >= 0
? "0x${inverted.toRadixString(16)}"
: "-0x${(-inverted).toRadixString(16)}";
Expect.equals(result.toLowerCase(), str_inverted);
int back = ~inverted;
Expect.equals(int_a, back);
String str_back = back >= 0
? "0x${back.toRadixString(16)}"
: "-0x${(-back).toRadixString(16)}";
Expect.equals(a.toLowerCase(), str_back);
}
testBigintBitNot() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
bitNotParsed(zero, minus_one);
bitNotParsed(one, "-0x2");
bitNotParsed("0x5", "-0x6");
bitNotParsed("0x50000000", "-0x50000001");
bitNotParsed("0xFFFFFFF", "-0x10000000");
bitNotParsed("0xFFFFFFFF", "-0x100000000");
bitNotParsed("0xFFFFFFFFFFFFFF", "-0x100000000000000");
bitNotParsed("0xFFFFFFFFFFFFFFFF", "-0x10000000000000000");
bitNotParsed("0x1234567890ABCDEF012345678", "-0x1234567890ABCDEF012345679");
}
main() {
testBigintAddSub();
testBigintLeftShift();
testBigintRightShift();
testBigintBitAnd();
testBigintBitOr();
testBigintBitXor();
testBigintBitNot();
}

View file

@ -0,0 +1,111 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints with and without intrinsics.
// VMOptions=
// VMOptions=--no_intrinsify
library big_integer_test;
import "package:expect/expect.dart";
divRemParsed(String a, String b, String quotient, String remainder) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_quotient = int.parse(quotient);
int int_remainder = int.parse(remainder);
int computed_quotient = int_a ~/ int_b;
Expect.equals(int_quotient, computed_quotient);
String str_quotient = computed_quotient >= 0
? "0x${computed_quotient.toRadixString(16)}"
: "-0x${(-computed_quotient).toRadixString(16)}";
Expect.equals(quotient.toLowerCase(), str_quotient);
int computed_remainder = int_a.remainder(int_b);
Expect.equals(int_remainder, computed_remainder);
String str_remainder = computed_remainder >= 0
? "0x${computed_remainder.toRadixString(16)}"
: "-0x${(-computed_remainder).toRadixString(16)}";
Expect.equals(remainder.toLowerCase(), str_remainder);
}
testBigintDivideRemainder() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
divRemParsed(one, one, one, zero);
divRemParsed(zero, one, zero, zero);
divRemParsed(minus_one, one, minus_one, zero);
divRemParsed(one, "0x2", zero, one);
divRemParsed(minus_one, "0x7", zero, minus_one);
divRemParsed("0xB", "0x7", one, "0x4");
divRemParsed("0x12345678", "0x7", "0x299C335", "0x5");
divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5");
divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5");
divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5");
divRemParsed("0x7", "0x12345678", zero, "0x7");
divRemParsed("-0x7", "0x12345678", zero, "-0x7");
divRemParsed("-0x7", "-0x12345678", zero, "-0x7");
divRemParsed("0x7", "-0x12345678", zero, "0x7");
divRemParsed("0x12345678", "0x7", "0x299C335", "0x5");
divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5");
divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5");
divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5");
divRemParsed(
"0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2"
"516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A"
"8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F"
"0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B"
"570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57"
"0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027"
"5CDFD41E07A15D0F5AD5256BED5F1CF91FBA375DE70",
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF",
"0x1234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012"
"345678901234567890123456789012345678901234567890123456789012345678901234"
"567890123456789012345678901234567890123456789012345678901234567890123456"
"789012345678901234567890123456789012345678901234567890123456789012345678"
"90123456789012345678901234567890",
zero);
divRemParsed(
"0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2"
"516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A"
"8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F"
"0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B"
"570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57"
"0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027"
"5CDFD41E07A15D0F5AD5256BED5F1CF91FBA375DE71",
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF",
"0x1234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012"
"345678901234567890123456789012345678901234567890123456789012345678901234"
"567890123456789012345678901234567890123456789012345678901234567890123456"
"789012345678901234567890123456789012345678901234567890123456789012345678"
"90123456789012345678901234567890",
one);
divRemParsed(
"0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2"
"516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A"
"8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F"
"0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B"
"570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57"
"0F4A8F0B570F4A8F0B570F4A8F0B5710591E051CF233A56DEA99087BDC08417F08B6758E"
"E5EA90FCF7B39165D365D139DC60403E8743421AC5E",
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF",
"0x1234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012"
"345678901234567890123456789012345678901234567890123456789012345678901234"
"567890123456789012345678901234567890123456789012345678901234567890123456"
"789012345678901234567890123456789012345678901234567890123456789012345678"
"90123456789012345678901234567890",
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEE");
}
main() {
testBigintDivideRemainder();
}

View file

@ -0,0 +1,804 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints with and without intrinsics.
// VMOptions=
// VMOptions=--no_intrinsify
library big_integer_test;
import "package:expect/expect.dart";
mulDivParsed(String a, String b, String product) {
int int_a = int.parse(a);
int int_b = int.parse(b);
int int_product = int.parse(product);
int computed_product = int_a * int_b;
Expect.equals(int_product, computed_product);
String str_product = computed_product >= 0
? "0x${computed_product.toRadixString(16)}"
: "-0x${(-computed_product).toRadixString(16)}";
Expect.equals(product.toLowerCase(), str_product);
int computed_product2 = int_b * int_a;
Expect.equals(int_product, computed_product2);
String str_product2 = computed_product2 >= 0
? "0x${computed_product2.toRadixString(16)}"
: "-0x${(-computed_product2).toRadixString(16)}";
Expect.equals(product.toLowerCase(), str_product2);
if (int_a != 0) {
int computed_quotient1 = int_product ~/ int_a;
Expect.equals(int_b, computed_quotient1);
String str_quotient1 = computed_quotient1 >= 0
? "0x${computed_quotient1.toRadixString(16)}"
: "-0x${(-computed_quotient1).toRadixString(16)}";
Expect.equals(b.toLowerCase(), str_quotient1);
}
if (int_b != 0) {
int computed_quotient2 = int_product ~/ int_b;
Expect.equals(int_a, computed_quotient2);
String str_quotient2 = computed_quotient2 >= 0
? "0x${computed_quotient2.toRadixString(16)}"
: "-0x${(-computed_quotient2).toRadixString(16)}";
Expect.equals(a.toLowerCase(), str_quotient2);
}
}
testBigintMultiplyDivide() {
String zero = "0x0";
String one = "0x1";
String minus_one = "-0x1";
mulDivParsed(zero, zero, zero);
mulDivParsed(one, one, one);
mulDivParsed(one, zero, zero);
mulDivParsed(zero, one, zero);
mulDivParsed(one, minus_one, minus_one);
mulDivParsed(minus_one, minus_one, one);
mulDivParsed("0x42", one, "0x42");
mulDivParsed("0x42", "0x2", "0x84");
mulDivParsed("0xFFFF", "0x2", "0x1FFFE");
mulDivParsed("0x3", "0x5", "0xF");
mulDivParsed("0xFFFFF", "0x5", "0x4FFFFB");
mulDivParsed("0xFFFFFFF", "0x5", "0x4FFFFFFB");
mulDivParsed("0xFFFFFFFF", "0x5", "0x4FFFFFFFB");
mulDivParsed("0xFFFFFFFFFFFFFFFF", "0x5", "0x4FFFFFFFFFFFFFFFB");
mulDivParsed("0xFFFFFFFFFFFFFFFF", "0x3039", "0x3038FFFFFFFFFFFFCFC7");
mulDivParsed("0xFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFFFFFFFFFFFF",
"0xFFFFFFFFFFFFFFFEFFFFFFFFFF0000000000000001");
mulDivParsed(
"0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000",
"0xFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000",
"0xFFFFFFFFFFFFFFFEFFFFFFFFFF000000000000000100000000000000"
"000000000000000000000000000000000000000000000000000000000000");
mulDivParsed("0x10000001", "0x5", "0x50000005");
mulDivParsed(
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF01234567890ABCDEF",
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF01234567890ABCDEF",
"0x14B66DC328828BCA670CBE52943AA3894CCCE15C8F5ED1E55F"
"328F6D3F579F992299850C4B5B95213EF3FB7B4E73B5F43D4299"
"5B9F6FD5441C275F2FF89F86F28F47A94CA37481090DCCCDCA6475F09A2F2A521");
mulDivParsed(
"0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF"
"01234567890ABCDEF",
"0x1234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012"
"345678901234567890123456789012345678901234567890123456789012345678901234"
"567890123456789012345678901234567890123456789012345678901234567890123456"
"789012345678901234567890123456789012345678901234567890123456789012345678"
"90123456789012345678901234567890",
"0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2"
"516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A"
"8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F"
"0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B"
"570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57"
"0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027"
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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFF",
"0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000001");
// A 256 28-bit digits number squared.
mulDivParsed(
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000001");
mulDivParsed(
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"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"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000001");
}
main() {
testBigintMultiplyDivide();
}

View file

@ -0,0 +1,61 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints.
library bit_twiddling_test;
import "package:expect/expect.dart";
// See bit_twiddling_test.dart first. This file contains only the tests that
// need Bigint or would fail in dart2js compatibility mode.
testBitLength() {
check(int i, width) {
Expect.equals(width, i.bitLength, '$i.bitLength == $width');
// (~i) written as (-i-1) to avoid issues with limited range of dart2js ops.
Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width');
}
check(0xffffffffffffff, 56);
check(0xffffffffffffffff, 64);
check(0xffffffffffffffffff, 72);
check(0x1000000000000000000, 73);
check(0x1000000000000000001, 73);
check(0xfffffffffffffffffffffffffffffffffffffe, 152);
check(0xffffffffffffffffffffffffffffffffffffff, 152);
check(0x100000000000000000000000000000000000000, 153);
check(0x100000000000000000000000000000000000001, 153);
}
testToUnsigned() {
checkU(src, width, expected) {
Expect.equals(expected, src.toUnsigned(width));
}
checkU(0x100000100000000000001, 2, 1);
checkU(0x100000200000000000001, 60, 0x200000000000001);
checkU(0x100000200000000000001, 59, 0x200000000000001);
checkU(0x100000200000000000001, 58, 0x200000000000001);
checkU(0x100000200000000000001, 57, 1);
}
testToSigned() {
checkS(src, width, expected) {
Expect.equals(
expected, src.toSigned(width), '$src.toSigned($width) == $expected');
}
checkS(0x100000100000000000001, 2, 1);
checkS(0x100000200000000000001, 60, 0x200000000000001);
checkS(0x100000200000000000001, 59, 0x200000000000001);
checkS(0x100000200000000000001, 58, -0x200000000000000 + 1);
checkS(0x100000200000000000001, 57, 1);
}
main() {
testBitLength();
testToUnsigned();
testToSigned();
}

View file

@ -0,0 +1,173 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Testing Bigints.
library bit_twiddling_test;
import "package:expect/expect.dart";
bool haveBigints() {
return 100000000000000000000 + 1 != 100000000000000000000;
}
testBitLength() {
check(int i, width) {
Expect.equals(width, i.bitLength, '$i.bitLength == $width');
// (~i) written as (-i-1) to avoid issues with limited range of dart2js ops.
Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width');
}
check(0, 0);
check(1, 1);
check(2, 2);
check(3, 2);
check(4, 3);
check(5, 3);
check(6, 3);
check(7, 3);
check(8, 4);
check(127, 7);
check(128, 8);
check(129, 8);
check(2147483646, 31);
check(2147483647, 31);
check(2147483648, 32);
check(2147483649, 32);
check(4294967295, 32);
check(4294967296, 33);
check(0xffffffffff, 40);
check(0xfffffffffff, 44);
check(0xffffffffffff, 48);
check(0x1000000000000, 49);
check(0x1000000000001, 49);
check(0x1ffffffffffff, 49);
check(0x2000000000000, 50);
check(0x2000000000001, 50);
if (haveBigints()) {
check(0xffffffffffffff, 56);
check(0xffffffffffffffff, 64);
check(0xffffffffffffffffff, 72);
check(0x1000000000000000000, 73);
check(0x1000000000000000001, 73);
check(0xfffffffffffffffffffffffffffffffffffffe, 152);
check(0xffffffffffffffffffffffffffffffffffffff, 152);
check(0x100000000000000000000000000000000000000, 153);
check(0x100000000000000000000000000000000000001, 153);
}
}
testToUnsigned() {
checkU(src, width, expected) {
Expect.equals(expected, src.toUnsigned(width));
}
checkU(1, 8, 1);
checkU(0xff, 8, 0xff);
checkU(0xffff, 8, 0xff);
checkU(-1, 8, 0xff);
checkU(0xffffffff, 32, 0xffffffff);
checkU(0x7fffffff, 30, 0x3fffffff);
checkU(0x7fffffff, 31, 0x7fffffff);
checkU(0x7fffffff, 32, 0x7fffffff);
checkU(0x80000000, 30, 0);
checkU(0x80000000, 31, 0);
checkU(0x80000000, 32, 0x80000000);
checkU(0xffffffff, 30, 0x3fffffff);
checkU(0xffffffff, 31, 0x7fffffff);
checkU(0xffffffff, 32, 0xffffffff);
checkU(0x100000000, 30, 0);
checkU(0x100000000, 31, 0);
checkU(0x100000000, 32, 0);
checkU(0x1ffffffff, 30, 0x3fffffff);
checkU(0x1ffffffff, 31, 0x7fffffff);
checkU(0x1ffffffff, 32, 0xffffffff);
checkU(-1, 0, 0);
checkU(0, 0, 0);
checkU(1, 0, 0);
checkU(2, 0, 0);
checkU(3, 0, 0);
checkU(-1, 1, 1);
checkU(0, 1, 0);
checkU(1, 1, 1);
checkU(2, 1, 0);
checkU(3, 1, 1);
checkU(4, 1, 0);
checkU(-1, 2, 3);
checkU(0, 2, 0);
checkU(1, 2, 1);
checkU(2, 2, 2);
checkU(3, 2, 3);
checkU(4, 2, 0);
checkU(-1, 3, 7);
checkU(0, 3, 0);
checkU(1, 3, 1);
checkU(2, 3, 2);
checkU(3, 3, 3);
checkU(4, 3, 4);
}
testToSigned() {
checkS(src, width, expected) {
Expect.equals(
expected, src.toSigned(width), '$src.toSigned($width) == $expected');
}
checkS(1, 8, 1);
checkS(0xff, 8, -1);
checkS(0xffff, 8, -1);
checkS(-1, 8, -1);
checkS(128, 8, -128);
checkS(0xffffffff, 32, -1);
checkS(0x7fffffff, 30, -1);
checkS(0x7fffffff, 31, -1);
checkS(0x7fffffff, 32, 0x7fffffff);
checkS(0x80000000, 30, 0);
checkS(0x80000000, 31, 0);
checkS(0x80000000, 32, -2147483648);
checkS(0xffffffff, 30, -1);
checkS(0xffffffff, 31, -1);
checkS(0xffffffff, 32, -1);
checkS(0x100000000, 30, 0);
checkS(0x100000000, 31, 0);
checkS(0x100000000, 32, 0);
checkS(0x1ffffffff, 30, -1);
checkS(0x1ffffffff, 31, -1);
checkS(0x1ffffffff, 32, -1);
checkS(-1, 1, -1);
checkS(0, 1, 0);
checkS(1, 1, -1); // The only bit is the sign bit.
checkS(2, 1, 0);
checkS(3, 1, -1);
checkS(4, 1, 0);
checkS(-1, 2, -1);
checkS(0, 2, 0);
checkS(1, 2, 1);
checkS(2, 2, -2);
checkS(3, 2, -1);
checkS(4, 2, 0);
checkS(-1, 3, -1);
checkS(0, 3, 0);
checkS(1, 3, 1);
checkS(2, 3, 2);
checkS(3, 3, 3);
checkS(4, 3, -4);
}
main() {
testBitLength();
testToUnsigned();
testToSigned();
}

View file

@ -0,0 +1,11 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
const bool.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error
const bool.fromEnvironment('NOT_FOUND', defaultValue: 1); // //# 02: compile-time error
const bool.fromEnvironment(null); // //# 03: compile-time error
const bool.fromEnvironment(1); // //# 04: compile-time error
const bool.fromEnvironment([]); // //# 05: compile-time error
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True
import "package:expect/expect.dart";
main() {
Expect.isTrue(const bool.fromEnvironment('a'));
Expect.isFalse(const bool.fromEnvironment('b'));
Expect.isTrue(const bool.fromEnvironment('c', defaultValue: true));
Expect.isFalse(const bool.fromEnvironment('c', defaultValue: false));
Expect.isFalse(const bool.fromEnvironment('d', defaultValue: false));
Expect.equals(const bool.fromEnvironment('dart.isVM'), !identical(1.0, 1));
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class BoolHashCodeTest {
static testMain() {
Expect.notEquals(true.hashCode, false.hashCode);
}
}
main() {
BoolHashCodeTest.testMain();
}

View file

@ -0,0 +1,44 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library collection.from.test;
import "package:expect/expect.dart";
import 'dart:collection' show Queue;
class CollectionFromTest {
static testMain() {
var set = new Set<int>();
set.add(1);
set.add(2);
set.add(4);
check(set, new List<int>.from(set));
check(set, new List.from(set));
check(set, new Queue<int>.from(set));
check(set, new Queue.from(set));
check(set, new Set<int>.from(set));
check(set, new Set.from(set));
}
static check(Iterable initial, Iterable other) {
Expect.equals(3, initial.length);
Expect.equals(initial.length, other.length);
int initialSum = 0;
int otherSum = 0;
initial.forEach((e) {
initialSum += e;
});
other.forEach((e) {
otherSum += e;
});
Expect.equals(4 + 2 + 1, otherSum);
Expect.equals(otherSum, initialSum);
}
}
main() {
CollectionFromTest.testMain();
}

View file

@ -0,0 +1,76 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library map_test;
import 'dart:collection';
// Test that length/isEmpty opertions are constant time on
// maps, strings and collections.
void testString(int n) {
String s = "x";
String string = "";
int length = n;
while (true) {
if ((length & 1) == 1) {
string += s;
}
length >>= 1;
if (length == 0) break;
s += s;
}
testLength(string, n);
testLength(string.codeUnits, n);
}
void testMap(Map map, int n) {
for (int i = 0; i < n; i++) {
map[i] = i;
}
testLength(map, n);
testLength(map.keys, n);
testLength(map.values, n);
}
void testCollection(var collection, n) {
for (int i = 0; i < n; i++) {
collection.add(i);
}
testLength(collection, n);
}
void testList(List list, n) {
// Works even if list is fixed-length.
for (int i = 0; i < n; i++) {
list[i] = i;
}
testLength(list, n);
}
void testLength(var lengthable, int size) {
print(lengthable.runtimeType); // Show what hangs the test.
int length = 0;
// If length, isEmpty or isNotEmpty is not a constant-time (or very fast)
// operation, this will timeout.
for (int i = 0; i < 100000; i++) {
if (!lengthable.isEmpty) length += lengthable.length;
if (lengthable.isNotEmpty) length += lengthable.length;
}
if (length != size * 200000) throw "Bad length: $length / size: $size";
}
main() {
const int N = 100000;
testMap(new HashMap(), N);
testMap(new LinkedHashMap(), N);
testMap(new SplayTreeMap(), N);
testCollection(new HashSet(), N);
testCollection(new LinkedHashSet(), N);
testCollection(new ListQueue(), N);
testCollection(new DoubleLinkedQueue(), N);
testList(new List()..length = N, N);
testList(new List(N), N);
testString(N);
}

View file

@ -0,0 +1,130 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:collection';
import "package:expect/expect.dart";
testRemove(base) {
int length = base.length;
for (int i = 0; i < length; i++) {
Expect.isFalse(base.isEmpty);
base.remove(base.first);
}
Expect.isTrue(base.isEmpty);
}
testRemoveAll(base, Iterable removes) {
Set retained = new Set();
for (var element in base) {
if (!removes.contains(element)) {
retained.add(element);
}
}
String name = "$base.removeAll($removes) -> $retained";
base.removeAll(removes);
for (var value in base) {
Expect.isFalse(removes.contains(value), "$name: Found $value");
}
for (var value in retained) {
Expect.isTrue(base.contains(value), "$name: Found $value");
}
}
testRetainAll(base, Iterable retains) {
Set retained = new Set();
for (var element in base) {
if (retains.contains(element)) {
retained.add(element);
}
}
String name = "$base.retainAll($retains) -> $retained";
base.retainAll(retains);
for (var value in base) {
Expect.isTrue(retains.contains(value), "$name: Found $value");
}
for (var value in retained) {
Expect.isTrue(base.contains(value), "$name: Found $value");
}
}
testRemoveWhere(base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (!test(element)) {
retained.add(element);
}
}
String name = "$base.removeWhere(...) -> $retained";
base.removeWhere(test);
for (var value in base) {
Expect.isFalse(test(value), "$name: Found $value");
}
for (var value in retained) {
Expect.isTrue(base.contains(value), "$name: Found $value");
}
}
testRetainWhere(base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (test(element)) {
retained.add(element);
}
}
String name = "$base.retainWhere(...) -> $retained";
base.retainWhere(test);
for (var value in base) {
Expect.isTrue(test(value), "$name: Found $value");
}
for (var value in retained) {
Expect.isTrue(base.contains(value), "$name: Found $value");
}
}
void main() {
var collections = [
[],
[1],
[2],
[1, 2],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 3, 5, 7, 9],
[2, 4, 6, 8, 10]
];
for (var base in collections) {
for (var delta in collections) {
testRemove(base.toList());
testRemove(base.toSet());
var deltaSet = delta.toSet();
testRemoveWhere(base.toList(), deltaSet.contains);
testRetainWhere(base.toList(), (e) => !deltaSet.contains(e));
testRemoveAll(base.toSet(), delta);
testRemoveAll(base.toSet(), deltaSet);
testRetainAll(base.toSet(), delta);
testRetainAll(base.toSet(), deltaSet);
testRemoveWhere(base.toSet(), deltaSet.contains);
testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
// Test the ListBase class's List implementation.
testRemoveWhere(new MyList(base.toList()), deltaSet.contains);
testRetainWhere(new MyList(base.toList()), (e) => !deltaSet.contains(e));
}
}
}
class MyList<E> extends ListBase<E> {
List<E> _source;
MyList(this._source);
int get length => _source.length;
void set length(int length) {
_source.length = length;
}
E operator [](int index) => _source[index];
void operator []=(int index, E value) {
_source[index] = value;
}
}

View file

@ -0,0 +1,41 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library collection_test;
import "package:expect/expect.dart";
import 'dart:collection' show Queue;
class CollectionTest {
CollectionTest(Iterable iterable) {
testFold(iterable);
}
void testFold(Iterable iterable) {
Expect.equals(28, iterable.fold(0, (prev, element) => prev + element));
Expect.equals(3024, iterable.fold(1, (prev, element) => prev * element));
}
}
main() {
final TEST_ELEMENTS = const [4, 2, 6, 7, 9];
// Const list.
new CollectionTest(TEST_ELEMENTS);
// Fixed size list.
var fixedList = new List(TEST_ELEMENTS.length);
for (int i = 0; i < TEST_ELEMENTS.length; i++) {
fixedList[i] = TEST_ELEMENTS[i];
}
new CollectionTest(fixedList);
// Growable list.
new CollectionTest(new List.from(TEST_ELEMENTS));
// Set.
new CollectionTest(new Set.from(TEST_ELEMENTS));
// Queue.
new CollectionTest(new Queue.from(TEST_ELEMENTS));
}

View file

@ -0,0 +1,387 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/**
* Tests for the toString methods on collections and maps.
*/
library collection_to_string;
import "package:expect/expect.dart";
import 'dart:collection' show Queue, LinkedHashMap;
import 'dart:math' as Math;
// TODO(jjb): seed random number generator when API allows it
const int NUM_TESTS = 300;
const int MAX_COLLECTION_SIZE = 7;
Math.Random rand;
main() {
rand = new Math.Random();
smokeTest();
exactTest();
inexactTest();
}
/**
* Test a few simple examples.
*/
void smokeTest() {
// Non-const lists
Expect.equals([].toString(), '[]');
Expect.equals([1].toString(), '[1]');
Expect.equals(['Elvis'].toString(), '[Elvis]');
Expect.equals([null].toString(), '[null]');
Expect.equals([1, 2].toString(), '[1, 2]');
Expect.equals(['I', 'II'].toString(), '[I, II]');
Expect.equals(
[
[1, 2],
[3, 4],
[5, 6]
].toString(),
'[[1, 2], [3, 4], [5, 6]]');
// Const lists
Expect.equals((const []).toString(), '[]');
Expect.equals((const [1]).toString(), '[1]');
Expect.equals((const ['Elvis']).toString(), '[Elvis]');
Expect.equals((const [null]).toString(), '[null]');
Expect.equals((const [1, 2]).toString(), '[1, 2]');
Expect.equals((const ['I', 'II']).toString(), '[I, II]');
Expect.equals(
(const [
const [1, 2],
const [3, 4],
const [5, 6]
])
.toString(),
'[[1, 2], [3, 4], [5, 6]]');
// Non-const maps - Note that all keys are strings; the spec currently demands this
Expect.equals({}.toString(), '{}');
Expect.equals({'Elvis': 'King'}.toString(), '{Elvis: King}');
Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
Expect.equals({'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
Expect.equals(
{
'X': {'I': 1, 'II': 2},
'Y': {'III': 3, 'IV': 4},
'Z': {'V': 5, 'VI': 6}
}.toString(),
'{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
// Const maps
Expect.equals(const {}.toString(), '{}');
Expect.equals(const {'Elvis': 'King'}.toString(), '{Elvis: King}');
Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
Expect.equals(const {'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
Expect.equals(
const {
'X': const {'I': 1, 'II': 2},
'Y': const {'III': 3, 'IV': 4},
'Z': const {'V': 5, 'VI': 6}
}.toString(),
'{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
}
// SERIOUS "BASHER" TESTS
/**
* Generate a bunch of random collections (including Maps), and test that
* there string form is as expected. The collections include collections
* as elements, keys, and values, and include recursive references.
*
* This test restricts itself to collections with well-defined iteration
* orders (i.e., no HashSet, HashMap).
*/
void exactTest() {
for (int i = 0; i < NUM_TESTS; i++) {
// Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
int size =
Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
StringBuffer stringRep = new StringBuffer();
Object o = randomCollection(size, stringRep, exact: true);
print(stringRep);
print(o);
Expect.equals(o.toString(), stringRep.toString());
}
}
/**
* Generate a bunch of random collections (including Maps), and test that
* there string form is as expected. The collections include collections
* as elements, keys, and values, and include recursive references.
*
* This test includes collections with ill-defined iteration orders (i.e.,
* HashSet, HashMap). As a consequence, it can't use equality tests on the
* string form. Instead, it performs equality tests on their "alphagrams."
* This might allow false positives, but it does give a fair amount of
* confidence.
*/
void inexactTest() {
for (int i = 0; i < NUM_TESTS; i++) {
// Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
int size =
Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
StringBuffer stringRep = new StringBuffer();
Object o = randomCollection(size, stringRep, exact: false);
print(stringRep);
print(o);
Expect.equals(alphagram(o.toString()), alphagram(stringRep.toString()));
}
}
/**
* Return a random collection (or Map) of the specified size, placing its
* string representation into the given string buffer.
*
* If exact is true, the returned collections will not be, and will not contain
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
*/
Object randomCollection(int size, StringBuffer stringRep, {bool exact}) {
return randomCollectionHelper(size, exact, stringRep, []);
}
/**
* Return a random collection (or map) of the specified size, placing its
* string representation into the given string buffer. The beingMade
* parameter is a list of collections currently under construction, i.e.,
* candidates for recursive references.
*
* If exact is true, the returned collections will not be, and will not contain
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
*/
Object randomCollectionHelper(
int size, bool exact, StringBuffer stringRep, List beingMade) {
double interfaceFrac = rand.nextDouble();
if (exact) {
if (interfaceFrac < 1 / 3) {
return randomList(size, exact, stringRep, beingMade);
} else if (interfaceFrac < 2 / 3) {
return randomQueue(size, exact, stringRep, beingMade);
} else {
return randomMap(size, exact, stringRep, beingMade);
}
} else {
if (interfaceFrac < 1 / 4) {
return randomList(size, exact, stringRep, beingMade);
} else if (interfaceFrac < 2 / 4) {
return randomQueue(size, exact, stringRep, beingMade);
} else if (interfaceFrac < 3 / 4) {
return randomSet(size, exact, stringRep, beingMade);
} else {
return randomMap(size, exact, stringRep, beingMade);
}
}
}
/**
* Return a random List of the specified size, placing its string
* representation into the given string buffer. The beingMade
* parameter is a list of collections currently under construction, i.e.,
* candidates for recursive references.
*
* If exact is true, the returned collections will not be, and will not contain
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
*/
List randomList(int size, bool exact, StringBuffer stringRep, List beingMade) {
return populateRandomCollection(size, exact, stringRep, beingMade, [], "[]");
}
/**
* Like randomList, but returns a queue.
*/
Queue randomQueue(
int size, bool exact, StringBuffer stringRep, List beingMade) {
return populateRandomCollection(
size, exact, stringRep, beingMade, new Queue(), "{}");
}
/**
* Like randomList, but returns a Set.
*/
Set randomSet(int size, bool exact, StringBuffer stringRep, List beingMade) {
// Until we have LinkedHashSet, method will only be called with exact==true
return populateRandomSet(size, exact, stringRep, beingMade, new Set());
}
/**
* Like randomList, but returns a map.
*/
Map randomMap(int size, bool exact, StringBuffer stringRep, List beingMade) {
if (exact) {
return populateRandomMap(
size, exact, stringRep, beingMade, new LinkedHashMap());
} else {
return populateRandomMap(size, exact, stringRep, beingMade,
randomBool() ? new Map() : new LinkedHashMap());
}
}
/**
* Populates the given empty collection with elements, emitting the string
* representation of the collection to stringRep. The beingMade parameter is
* a list of collections currently under construction, i.e., candidates for
* recursive references.
*
* If exact is true, the elements of the returned collections will not be,
* and will not contain a collection with ill-defined iteration order
* (i.e., a HashSet or HashMap).
*/
populateRandomCollection(int size, bool exact, StringBuffer stringRep,
List beingMade, var coll, String delimiters) {
beingMade.add(coll);
int start = stringRep.length;
stringRep.write(delimiters[0]);
List indices = [];
for (int i = 0; i < size; i++) {
indices.add(stringRep.length);
if (i != 0) stringRep.write(', ');
coll.add(randomElement(random(size), exact, stringRep, beingMade));
}
if (size > 5 && delimiters == "()") {
const int MAX_LENGTH = 80;
const int MIN_COUNT = 3;
const int MAX_COUNT = 100;
// It's an iterable, it may omit some elements.
int end = stringRep.length;
if (size > MAX_COUNT) {
// Last two elements are also omitted, just find the first three or
// first 60 characters.
for (int i = MIN_COUNT; i < size; i++) {
int startIndex = indices[i];
if (startIndex - start > MAX_LENGTH - 6) {
// Limit - ", ...)".length.
String prefix = stringRep.toString().substring(0, startIndex);
stringRep.clear();
stringRep.write(prefix);
stringRep.write(", ...");
}
}
} else if (stringRep.length - start > MAX_LENGTH - 1) {
// 80 - ")".length.
// Last two elements are always included. Middle ones may be omitted.
int lastTwoLength = end - indices[indices.length - 2];
// Try to find first element to omit.
for (int i = 3; i <= size - 3; i++) {
int elementEnd = indices[i + 1];
int lengthAfter = elementEnd - start;
int ellipsisSize = 5; // ", ...".length
if (i == size - 3) ellipsisSize = 0; // No ellipsis if we hit the end.
if (lengthAfter + ellipsisSize + lastTwoLength > MAX_LENGTH - 1) {
// Omit this element and everything up to the last two.
int elementStart = indices[i];
// Rewrite string buffer by copying it out, clearing, and putting
// the parts back in.
String buffer = stringRep.toString();
String prefix = buffer.substring(0, elementStart);
String suffix = buffer.substring(end - lastTwoLength, end);
stringRep.clear();
stringRep.write(prefix);
stringRep.write(", ...");
stringRep.write(suffix);
break;
}
}
}
}
stringRep.write(delimiters[1]);
beingMade.removeLast();
return coll;
}
/** Like populateRandomCollection, but for sets (elements must be hashable) */
Set populateRandomSet(
int size, bool exact, StringBuffer stringRep, List beingMade, Set set) {
stringRep.write('{');
for (int i = 0; i < size; i++) {
if (i != 0) stringRep.write(', ');
set.add(i);
stringRep.write(i);
}
stringRep.write('}');
return set;
}
/** Like populateRandomCollection, but for maps. */
Map populateRandomMap(
int size, bool exact, StringBuffer stringRep, List beingMade, Map map) {
beingMade.add(map);
stringRep.write('{');
for (int i = 0; i < size; i++) {
if (i != 0) stringRep.write(', ');
int key = i; // Ensures no duplicates
stringRep.write(key);
stringRep.write(': ');
Object val = randomElement(random(size), exact, stringRep, beingMade);
map[key] = val;
}
stringRep.write('}');
beingMade.removeLast();
return map;
}
/**
* Generates a random element which can be an int, a collection, or a map,
* and emits it to StringRep. The beingMade parameter is a list of collections
* currently under construction, i.e., candidates for recursive references.
*
* If exact is true, the returned element will not be, and will not contain
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
*/
Object randomElement(
int size, bool exact, StringBuffer stringRep, List beingMade) {
Object result;
double elementTypeFrac = rand.nextDouble();
if (elementTypeFrac < 1 / 3) {
result = random(1000);
stringRep.write(result);
} else if (elementTypeFrac < 2 / 3) {
// Element is a random (new) collection
result = randomCollectionHelper(size, exact, stringRep, beingMade);
} else {
// Element is a random recursive ref
result = beingMade[random(beingMade.length)];
if (result is List) {
stringRep.write('[...]');
} else if (result is Set || result is Map || result is Queue) {
stringRep.write('{...}');
} else {
stringRep.write('(...)');
}
}
return result;
}
/** Returns a random int on [0, max) */
int random(int max) {
return rand.nextInt(max);
}
/** Returns a random boolean value. */
bool randomBool() {
return rand.nextBool();
}
/** Returns the alphabetized characters in a string. */
String alphagram(String s) {
// Calling [toList] to convert unmodifiable list to normal list.
List<int> chars = s.codeUnits.toList();
chars.sort((int a, int b) => a - b);
return new String.fromCharCodes(chars);
}

View file

@ -0,0 +1,94 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing Math.min and Math.max.
import "package:expect/expect.dart";
negate(x) => -x;
main() {
// Test matrix:
var minNonZero = 5e-324;
var maxDenormal = 2.225073858507201e-308;
var minNormal = 2.2250738585072014e-308;
var maxFraction = 0.9999999999999999;
var minAbove1 = 1.0000000000000002;
var maxNonInt = 4503599627370495.5;
var maxNonIntFloorAsInt = maxNonInt.floor();
var maxNonIntFloorAsDouble = maxNonIntFloorAsInt.toDouble();
var maxExactIntAsDouble = 9007199254740992.0;
var maxExactIntAsInt = 9007199254740992;
var two53 = 1 << 53; // Same as maxExactIntAsInt.
var two53p1 = two53 + 1;
var maxFiniteAsDouble = 1.7976931348623157e+308;
var maxFiniteAsInt = maxFiniteAsDouble.truncate();
int huge = 1 << 2000;
int hugeP1 = huge + 1;
var inf = double.INFINITY;
var nan = double.NAN;
var mnan = negate(nan);
var matrix = [
-inf,
-hugeP1,
-huge,
[-maxFiniteAsDouble, -maxFiniteAsInt],
-two53p1,
[-two53, -maxExactIntAsInt, -maxExactIntAsDouble],
-maxNonInt,
[-maxNonIntFloorAsDouble, -maxNonIntFloorAsInt],
[-499.0, -499],
-minAbove1,
[-1.0, -1],
-maxFraction,
-minNormal,
-maxDenormal,
-minNonZero,
-0.0,
[0, 0, 0],
minNonZero,
maxDenormal,
minNormal,
maxFraction,
[1.0, 1],
minAbove1,
[499.0, 499],
[maxNonIntFloorAsDouble, maxNonIntFloorAsInt],
maxNonInt,
[two53, maxExactIntAsInt, maxExactIntAsDouble],
two53p1,
[maxFiniteAsDouble, maxFiniteAsInt],
huge,
hugeP1,
inf,
[nan, mnan],
];
check(left, right, expectedResult) {
if (left is List) {
for (var x in left) check(x, right, expectedResult);
return;
}
if (right is List) {
for (var x in right) check(left, x, expectedResult);
return;
}
int actual = left.compareTo(right);
Expect.equals(
expectedResult,
actual,
"($left).compareTo($right) failed "
"(should have been $expectedResult, was $actual");
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix.length; j++) {
var left = matrix[i];
var right = matrix[j];
if (left is List) {
check(left, left, 0);
}
check(left, right, i == j ? 0 : (i < j ? -1 : 1));
}
}
}

View file

@ -0,0 +1,136 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing Math.min and Math.max.
import "package:expect/expect.dart";
negate(x) => -x;
main() {
// Test matrix:
// -inf < -499.0 == -499 < -0.0 < 0.0 == 0 < 499.0 == 499 < +inf < -NaN, NaN.
var inf = double.INFINITY;
var nan = double.NAN;
var mnan = negate(nan);
Expect.equals(0, (-inf).compareTo(-inf));
Expect.equals(-1, (-inf).compareTo(-499.0));
Expect.equals(-1, (-inf).compareTo(-499));
Expect.equals(-1, (-inf).compareTo(-0.0));
Expect.equals(-1, (-inf).compareTo(0));
Expect.equals(-1, (-inf).compareTo(0.0));
Expect.equals(-1, (-inf).compareTo(499.0));
Expect.equals(-1, (-inf).compareTo(499));
Expect.equals(-1, (-inf).compareTo(inf));
Expect.equals(-1, (-inf).compareTo(nan));
Expect.equals(-1, (-inf).compareTo(mnan));
Expect.equals(1, (-499.0).compareTo(-inf));
Expect.equals(0, (-499.0).compareTo(-499.0));
Expect.equals(0, (-499.0).compareTo(-499));
Expect.equals(-1, (-499.0).compareTo(-0.0));
Expect.equals(-1, (-499.0).compareTo(0));
Expect.equals(-1, (-499.0).compareTo(0.0));
Expect.equals(-1, (-499.0).compareTo(499.0));
Expect.equals(-1, (-499.0).compareTo(499));
Expect.equals(-1, (-499.0).compareTo(inf));
Expect.equals(-1, (-499.0).compareTo(nan));
Expect.equals(-1, (-499.0).compareTo(mnan));
Expect.equals(1, (-499).compareTo(-inf));
Expect.equals(0, (-499).compareTo(-499.0));
Expect.equals(0, (-499).compareTo(-499));
Expect.equals(-1, (-499).compareTo(-0.0));
Expect.equals(-1, (-499).compareTo(0));
Expect.equals(-1, (-499).compareTo(0.0));
Expect.equals(-1, (-499).compareTo(499.0));
Expect.equals(-1, (-499).compareTo(499));
Expect.equals(-1, (-499).compareTo(inf));
Expect.equals(-1, (-499).compareTo(nan));
Expect.equals(-1, (-499).compareTo(mnan));
Expect.equals(1, (-0.0).compareTo(-inf));
Expect.equals(1, (-0.0).compareTo(-499.0));
Expect.equals(1, (-0.0).compareTo(-499));
Expect.equals(0, (-0.0).compareTo(-0.0));
Expect.equals(-1, (-0.0).compareTo(0));
Expect.equals(-1, (-0.0).compareTo(0.0));
Expect.equals(-1, (-0.0).compareTo(499.0));
Expect.equals(-1, (-0.0).compareTo(499));
Expect.equals(-1, (-0.0).compareTo(inf));
Expect.equals(-1, (-0.0).compareTo(nan));
Expect.equals(-1, (-0.0).compareTo(mnan));
Expect.equals(1, (0).compareTo(-inf));
Expect.equals(1, (0).compareTo(-499.0));
Expect.equals(1, (0).compareTo(-499));
Expect.equals(1, (0).compareTo(-0.0));
Expect.equals(0, (0).compareTo(0));
Expect.equals(0, (0).compareTo(0.0));
Expect.equals(-1, (0).compareTo(499.0));
Expect.equals(-1, (0).compareTo(499));
Expect.equals(-1, (0).compareTo(inf));
Expect.equals(-1, (0).compareTo(nan));
Expect.equals(-1, (0).compareTo(mnan));
Expect.equals(1, (0.0).compareTo(-inf));
Expect.equals(1, (0.0).compareTo(-499.0));
Expect.equals(1, (0.0).compareTo(-499));
Expect.equals(1, (0.0).compareTo(-0.0));
Expect.equals(0, (0.0).compareTo(0));
Expect.equals(0, (0.0).compareTo(0.0));
Expect.equals(-1, (0.0).compareTo(499.0));
Expect.equals(-1, (0.0).compareTo(499));
Expect.equals(-1, (0.0).compareTo(inf));
Expect.equals(-1, (0.0).compareTo(nan));
Expect.equals(-1, (0.0).compareTo(mnan));
Expect.equals(1, (499.0).compareTo(-inf));
Expect.equals(1, (499.0).compareTo(-499.0));
Expect.equals(1, (499.0).compareTo(-499));
Expect.equals(1, (499.0).compareTo(-0.0));
Expect.equals(1, (499.0).compareTo(0));
Expect.equals(1, (499.0).compareTo(0.0));
Expect.equals(0, (499.0).compareTo(499.0));
Expect.equals(0, (499.0).compareTo(499));
Expect.equals(-1, (499.0).compareTo(inf));
Expect.equals(-1, (499.0).compareTo(nan));
Expect.equals(-1, (499.0).compareTo(mnan));
Expect.equals(1, (499).compareTo(-inf));
Expect.equals(1, (499).compareTo(-499.0));
Expect.equals(1, (499).compareTo(-499));
Expect.equals(1, (499).compareTo(-0.0));
Expect.equals(1, (499).compareTo(0));
Expect.equals(1, (499).compareTo(0.0));
Expect.equals(0, (499).compareTo(499.0));
Expect.equals(0, (499).compareTo(499));
Expect.equals(-1, (499).compareTo(inf));
Expect.equals(-1, (499).compareTo(nan));
Expect.equals(-1, (499).compareTo(mnan));
Expect.equals(1, inf.compareTo(-inf));
Expect.equals(1, inf.compareTo(-499.0));
Expect.equals(1, inf.compareTo(-499));
Expect.equals(1, inf.compareTo(-0.0));
Expect.equals(1, inf.compareTo(0));
Expect.equals(1, inf.compareTo(0.0));
Expect.equals(1, inf.compareTo(499.0));
Expect.equals(1, inf.compareTo(499));
Expect.equals(0, inf.compareTo(inf));
Expect.equals(-1, inf.compareTo(nan));
Expect.equals(-1, inf.compareTo(mnan));
Expect.equals(1, nan.compareTo(-inf));
Expect.equals(1, nan.compareTo(-499.0));
Expect.equals(1, nan.compareTo(-499));
Expect.equals(1, nan.compareTo(-0.0));
Expect.equals(1, nan.compareTo(0));
Expect.equals(1, nan.compareTo(0.0));
Expect.equals(1, nan.compareTo(499.0));
Expect.equals(1, nan.compareTo(499));
Expect.equals(1, nan.compareTo(inf));
Expect.equals(0, nan.compareTo(nan));
Expect.equals(0, nan.compareTo(mnan));
}

View file

@ -0,0 +1,80 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test that a final list literal is not expandable nor modifiable.
class ConstListLiteralTest {
static void testMain() {
var list = const [4, 2, 3];
Expect.equals(3, list.length);
var exception = null;
try {
list.add(4);
} on UnsupportedError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
Expect.equals(3, list.length);
exception = null;
exception = null;
try {
list.addAll([4, 5]);
} on UnsupportedError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
Expect.equals(3, list.length);
exception = null;
try {
list[0] = 0;
} on UnsupportedError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
Expect.equals(3, list.length);
exception = null;
try {
list.sort((a, b) => a - b);
} on UnsupportedError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
Expect.equals(3, list.length);
Expect.equals(4, list[0]);
Expect.equals(2, list[1]);
Expect.equals(3, list[2]);
exception = null;
try {
list.setRange(0, 1, [1], 0);
} on UnsupportedError catch (e) {
exception = e;
}
Expect.equals(true, exception != null);
Expect.equals(3, list.length);
Expect.equals(4, list[0]);
Expect.equals(2, list[1]);
Expect.equals(3, list[2]);
// Note: the next check is a regression test for dart2js. The immutable list
// overrides the 'length' property of List, but relies on using the native
// 'forEach' construct in Array. This test ensures that our strategy works
// correctly.
int x = 0;
list.forEach((e) {
x += e;
});
Expect.equals(9, x);
}
}
main() {
ConstListLiteralTest.testMain();
}

View file

@ -0,0 +1,27 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
testImmutable(const []);
testImmutable(const [1]);
testImmutable(const [1, 2]);
}
void expectUOE(Function f) {
Expect.throws(f, (e) => e is UnsupportedError);
}
testImmutable(var list) {
expectUOE(() {
list.removeRange(0, 0);
});
expectUOE(() {
list.removeRange(0, 1);
});
expectUOE(() {
list.removeRange(-1, 1);
});
}

View file

@ -0,0 +1,51 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
testImmutable(const []);
testImmutable(const [1]);
testImmutable(const [1, 2]);
}
void expectUOE(Function f) {
Expect.throws(f, (e) => e is UnsupportedError);
}
testImmutable(var list) {
expectUOE(() {
list.setRange(0, 0, const []);
});
expectUOE(() {
list.setRange(0, 1, const [], 1);
});
expectUOE(() {
list.setRange(0, 1, const []);
});
expectUOE(() {
list.setRange(0, 0, []);
});
expectUOE(() {
list.setRange(0, 1, [], 1);
});
expectUOE(() {
list.setRange(0, 1, []);
});
expectUOE(() {
list.setRange(0, 0, const [1]);
});
expectUOE(() {
list.setRange(0, 1, const [1]);
});
expectUOE(() {
list.setRange(0, 0, [1]);
});
expectUOE(() {
list.setRange(0, 1, [1]);
});
expectUOE(() {
list.setRange(0, 1, [1], 1);
});
}

View file

@ -0,0 +1,342 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
/**
* A test of simple runtime behavior on numbers, strings and lists with
* a focus on both correct behavior and runtime errors.
*
* This file is written to use minimal type declarations to match a
* typical dynamic language coding style.
*/
class CoreRuntimeTypesTest {
static testMain() {
testBooleanOperators();
testRationalOperators();
testIntegerOperators();
testOperatorErrors();
testRationalMethods();
testIntegerMethods();
testStringOperators();
testStringMethods();
testListOperators();
testListMethods();
testMapOperators();
testMapMethods();
testLiterals();
testDateMethods();
}
static assertEquals(a, b) {
Expect.equals(b, a);
}
static assertListEquals(List a, List b) {
Expect.equals(b.length, a.length);
for (int i = 0; i < a.length; i++) {
Expect.equals(b[i], a[i]);
}
}
static assertListContains(List<Comparable> a, List<Comparable> b) {
a.sort((x, y) => x.compareTo(y));
b.sort((x, y) => x.compareTo(y));
assertListEquals(a, b);
}
static assertTypeError(void f()) {
Expect.throws(
f,
(exception) =>
(exception is TypeError) ||
(exception is NoSuchMethodError) ||
(exception is ArgumentError));
}
static testBooleanOperators() {
var x = true, y = false;
assertEquals(x, true);
assertEquals(y, false);
assertEquals(x, !y);
assertEquals(!x, y);
}
static testRationalOperators() {
var x = 10, y = 20;
assertEquals(x + y, 30);
assertEquals(x - y, -10);
assertEquals(x * y, 200);
assertEquals(x / y, 0.5);
assertEquals(x ~/ y, 0);
assertEquals(x % y, 10);
}
static testIntegerOperators() {
var x = 18, y = 17;
assertEquals(x | y, 19);
assertEquals(x & y, 16);
assertEquals(x ^ y, 3);
assertEquals(2 >> 1, 1);
assertEquals(1 << 1, 2);
}
static testOperatorErrors() {
var objs = [
1,
'2',
[3],
null,
true,
new Map()
];
for (var i = 0; i < objs.length; i++) {
for (var j = i + 1; j < objs.length; j++) {
testBinaryOperatorErrors(objs[i], objs[j]);
// Allow "String * int".
if (j > 2) testBinaryOperatorErrors(objs[j], objs[i]);
}
if (objs[i] != 1) {
testUnaryOperatorErrors(objs[i]);
}
}
}
static testBinaryOperatorErrors(x, y) {
assertTypeError(() {
x - y;
});
assertTypeError(() {
x * y;
});
assertTypeError(() {
x / y;
});
assertTypeError(() {
x | y;
});
assertTypeError(() {
x ^ y;
});
assertTypeError(() {
x & y;
});
assertTypeError(() {
x << y;
});
assertTypeError(() {
x >> y;
});
assertTypeError(() {
x ~/ y;
});
assertTypeError(() {
x % y;
});
testComparisonOperatorErrors(x, y);
}
static testComparisonOperatorErrors(x, y) {
assertEquals(x == y, false);
assertEquals(x != y, true);
assertTypeError(() {
x < y;
});
assertTypeError(() {
x <= y;
});
assertTypeError(() {
x > y;
});
assertTypeError(() {
x >= y;
});
}
static testUnaryOperatorErrors(x) {
// TODO(jimhug): Add guard for 'is num' when 'is' is working
assertTypeError(() {
~x;
});
assertTypeError(() {
-x;
});
// TODO(jimhug): Add check for !x as an error when x is not a bool
}
static testRationalMethods() {
var x = 10.6;
assertEquals(x.abs(), 10.6);
assertEquals((-x).abs(), 10.6);
assertEquals(x.round(), 11);
assertEquals(x.floor(), 10);
assertEquals(x.ceil(), 11);
}
// TODO(jimhug): Determine correct behavior for mixing ints and floats.
static testIntegerMethods() {
var y = 9;
assertEquals(y.isEven, false);
assertEquals(y.isOdd, true);
assertEquals(y.toRadixString(2), '1001');
assertEquals(y.toRadixString(3), '100');
assertEquals(y.toRadixString(16), '9');
assertEquals((0).toRadixString(16), '0');
try {
y.toRadixString(0);
Expect.fail("Illegal radix 0 accepted.");
} catch (e) {}
try {
y.toRadixString(-1);
Expect.fail("Illegal radix -1 accepted.");
} catch (e) {}
}
static testStringOperators() {
var s = "abcdef";
assertEquals(s, "abcdef");
assertEquals(s.codeUnitAt(0), 97);
assertEquals(s[0], 'a');
assertEquals(s.length, 6);
assertTypeError(() {
s[null];
});
assertTypeError(() {
s['hello'];
});
assertTypeError(() {
s[0] = 'x';
});
}
// TODO(jimhug): Fill out full set of string methods.
static testStringMethods() {
var s = "abcdef";
assertEquals(s.isEmpty, false);
assertEquals(s.isNotEmpty, true);
assertEquals(s.startsWith("abc"), true);
assertEquals(s.endsWith("def"), true);
assertEquals(s.startsWith("aa"), false);
assertEquals(s.endsWith("ff"), false);
assertEquals(s.contains('cd', 0), true);
assertEquals(s.contains('cd', 2), true);
assertEquals(s.contains('cd', 3), false);
assertEquals(s.indexOf('cd', 2), 2);
assertEquals(s.indexOf('cd', 3), -1);
assertTypeError(() {
s.startsWith(1);
});
assertTypeError(() {
s.endsWith(1);
});
}
static testListOperators() {
var a = [1, 2, 3, 4];
assertEquals(a[0], 1);
assertTypeError(() {
a['0'];
});
a[0] = 42;
assertEquals(a[0], 42);
assertTypeError(() {
a['0'] = 99;
});
assertEquals(a.length, 4);
}
// TODO(jimhug): Fill out full set of list methods.
static testListMethods() {
var a = [1, 2, 3, 4];
assertEquals(a.isEmpty, false);
assertEquals(a.length, 4);
var exception = null;
a.clear();
assertEquals(a.length, 0);
}
static testMapOperators() {
var d = new Map();
d['a'] = 1;
d['b'] = 2;
assertEquals(d['a'], 1);
assertEquals(d['b'], 2);
assertEquals(d['c'], null);
}
static testMapMethods() {
var d = new Map();
d['a'] = 1;
d['b'] = 2;
assertEquals(d.containsValue(2), true);
assertEquals(d.containsValue(3), false);
assertEquals(d.containsKey('a'), true);
assertEquals(d.containsKey('c'), false);
assertEquals(d.keys.length, 2);
assertEquals(d.values.length, 2);
assertEquals(d.remove('c'), null);
assertEquals(d.remove('b'), 2);
assertEquals(d.keys.single, 'a');
assertEquals(d.values.single, 1);
d['c'] = 3;
d['f'] = 4;
assertEquals(d.keys.length, 3);
assertEquals(d.values.length, 3);
assertListContains(d.keys.toList(), ['a', 'c', 'f']);
assertListContains(d.values.toList(), [1, 3, 4]);
var count = 0;
d.forEach((key, value) {
count++;
assertEquals(value, d[key]);
});
assertEquals(count, 3);
d = {'a': 1, 'b': 2};
assertEquals(d.containsValue(2), true);
assertEquals(d.containsValue(3), false);
assertEquals(d.containsKey('a'), true);
assertEquals(d.containsKey('c'), false);
assertEquals(d.keys.length, 2);
assertEquals(d.values.length, 2);
d['g'] = null;
assertEquals(d.containsKey('g'), true);
assertEquals(d['g'], null);
}
static testDateMethods() {
var msec = 115201000;
var d = new DateTime.fromMillisecondsSinceEpoch(msec, isUtc: true);
assertEquals(d.second, 1);
assertEquals(d.year, 1970);
d = new DateTime.now();
assertEquals(d.year >= 1970, true);
}
static testLiterals() {
true.toString();
1.0.toString();
.5.toString();
1.toString();
if (false) {
// Depends on http://b/4198808.
null.toString();
}
'${null}'.toString();
'${true}'.toString();
'${false}'.toString();
''.toString();
''.endsWith('');
}
}
main() {
CoreRuntimeTypesTest.testMain();
}

View file

@ -0,0 +1,787 @@
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
[ $strong ]
*: SkipByDesign # tests/corelib_strong has the strong mode versions of these tests.
[ $compiler == none || $compiler == precompiler || $compiler == app_jit ]
compare_to2_test: Fail # Bug 4018
symbol_test/01: Fail, Pass # bug 11669
unicode_test: Fail # Bug 6706
# With the exception of 'void', new Symbol() should not accept reserved words.
symbol_reserved_word_test/05: CompileTimeError # bug 20191
symbol_reserved_word_test/06: RuntimeError # bug 11669
symbol_reserved_word_test/09: RuntimeError # bug 11669
symbol_reserved_word_test/12: RuntimeError # bug 11669
symbol_test/none: Fail # bug 11669
symbol_operator_test/03: Fail # bug 11669
string_case_test/01: Fail # Bug 18061
[ $compiler == none && ($runtime == vm || $runtime == flutter)]
string_trimlr_test/02: RuntimeError # Issue 29060
[ $compiler == precompiler || $compiler == app_jit ]
string_trimlr_test/02: RuntimeError # Issue 29060
# #void should be a valid symbol.
[ $compiler == none || $compiler == precompiler || $compiler == app_jit || $compiler == dart2js ]
symbol_reserved_word_test/02: CompileTimeError # bug 20191
# With the exception of 'void', const Symbol() should not accept reserved
# words.
symbol_reserved_word_test/04: MissingCompileTimeError # bug 11669, 19972
symbol_reserved_word_test/07: MissingCompileTimeError # bug 11669, 19972
symbol_reserved_word_test/10: MissingCompileTimeError # bug 11669, 19972
[ $compiler == dart2js && ! $dart2js_with_kernel ]
double_parse_test/01: Pass, Fail # JS implementations disagree on U+0085 being whitespace.
int_modulo_arith_test/bignum: RuntimeError # No bigints.
int_modulo_arith_test/modPow: RuntimeError # No bigints.
int_parse_radix_test/01: Pass, Fail # JS implementations disagree on U+0085 being whitespace.
int_parse_radix_test/02: Fail # No bigints.
integer_to_radix_string_test: RuntimeError # issue 22045
list_unmodifiable_test: Pass, RuntimeError # Issue 28712
symbol_reserved_word_test/03: RuntimeError # bug 19972, new Symbol('void') should be allowed.
symbol_reserved_word_test/05: Crash # bug 20191
[ $compiler == dart2js && $fast_startup ]
apply3_test: Fail # mirrors not supported
[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $runtime != drt ]
symbol_test/02: MissingCompileTimeError # bug 11669
symbol_test/03: MissingCompileTimeError # bug 11669
[ $runtime == ff || $runtime == jsshell ]
# Firefox takes advantage of the ECMAScript number parsing cop-out clause
# (presumably added to allow Mozilla's existing behavior)
# and only looks at the first 20 significant digits.
# The Dart VM and the other ECMAScript implementations follow the correct
# IEEE-754 rounding algorithm.
double_parse_test/02: Fail, OK
[ $runtime == safari || $runtime == safarimobilesim ]
string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier.
[ $runtime == ff ]
double_round3_test: Pass, Fail, OK # Fails on ff 34, passes on ff 35. Runtime rounds 0.49999999999999994 to 1.
double_round_to_double2_test: Pass, Fail, OK # Fails on ff 34, passes on ff 35. Runtime rounds 0.49999999999999994 to 1.
[ $compiler == dart2js && $runtime == drt && $csp && $minified ]
core_runtime_types_test: Pass, Fail # Issue 27913
[ $compiler == dart2js && ! $dart2js_with_kernel ]
error_stack_trace1_test: RuntimeError # Issue 12399
hash_set_test/01: RuntimeError # Issue 11551
integer_to_string_test/01: RuntimeError # Issue 1533
iterable_return_type_test/01: RuntimeError # Issue 20085
iterable_return_type_test/02: RuntimeError # Dart2js does not support Uint64*.
iterable_to_list_test/01: RuntimeError # Issue 26501
big_integer_*: Skip # VM specific test.
bit_twiddling_bigint_test: RuntimeError # Requires bigint support.
compare_to2_test: RuntimeError, OK # Requires bigint support.
string_base_vm_test: RuntimeError, OK # VM specific test.
nan_infinity_test/01: Fail # Issue 11551
regexp/pcre_test: Pass, Slow # Issue 21593
regress_r21715_test: RuntimeError # Requires bigint support.
[ $compiler == dart2js && $runtime == none ]
*: Fail, Pass # TODO(ahe): Triage these tests.
[ $compiler == dart2js && $runtime == chromeOnAndroid ]
list_as_map_test: Pass, Slow # TODO(kasperl): Please triage.
string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier.
[ $compiler == dart2js && $runtime == drt ]
string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier.
[ $compiler == dart2js && $runtime == safarimobilesim ]
string_split_test: RuntimeError # Issue 21431
[ $compiler == dart2js && $runtime == safarimobilesim ]
list_test/01: Fail # Safari bug: Array(-2) seen as dead code.
string_trimlr_test/01: Fail
string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier.
[ $compiler == dart2js && ($runtime == ff || $runtime == jsshell) ]
string_case_test/01: Fail, OK # Bug in Firefox.
# Analyzer's implementation of fromEnvironment assumes that undefined
# environment variables have an unspecified value (rather than being
# null) because it is expected that the user will supply a value when
# the code is run. This means that it produces slightly different
# error messages than the VM and Dart2js.
[ $compiler == dart2analyzer && $checked ]
from_environment_const_type_undefined_test/09: CompileTimeError
from_environment_const_type_undefined_test/11: CompileTimeError
from_environment_const_type_undefined_test/12: CompileTimeError
from_environment_const_type_undefined_test/13: CompileTimeError
from_environment_const_type_undefined_test/14: CompileTimeError
from_environment_const_type_undefined_test/16: CompileTimeError
[ $compiler == dart2analyzer ]
int_parse_radix_bad_handler_test: fail
hash_set_type_check_test: StaticWarning, OK # Tests failing type tests.
error_stack_trace_test: StaticWarning, OK # Test generates errors on purpose.
iterable_element_at_test: StaticWarning, OK # Test generates errors on purpose.
num_clamp_test: StaticWarning, OK # Test generates errors on purpose.
string_test: StaticWarning, OK # Test generates error on purpose.
duration2_test: StaticWarning, OK # Test generates error on purpose.
[ $compiler == dart2analyzer && $builder_tag == strong ]
*: Skip # Issue 28649
[ $system == windows && $arch == x64 ]
stopwatch_test: Skip # Flaky test due to expected performance behaviour.
[ $runtime != d8 && $runtime != vm && $runtime != dart_precompiled ]
# The regexp tests are not verified to work on non d8/vm platforms yet.
regexp/*: Skip
[ $runtime == d8 ]
uri_base_test: RuntimeError # d8 preamble uses custom URI scheme "org-dartlang-d8-preamble:".
[ $runtime == vm || $runtime == dart_precompiled || $runtime == flutter]
regexp/global_test: Skip # Timeout. Issue 21709 and 21708
regexp/pcre_test: Pass, Slow, Timeout # Issues 21593 and 22008
regexp/capture-3: Pass, Slow, Timeout # Issues 21593 and 22008
[ $runtime != vm && $runtime != dart_precompiled && $compiler != dart2analyzer]
data_resource_test: RuntimeError # Issue 23825 (not implemented yet).
file_resource_test: Skip, OK # VM specific test, uses dart:io.
http_resource_test: Skip, OK # VM specific test, uses dart:io.
[ $compiler == dart2js && ! $browser ]
package_resource_test: RuntimeError # Issue 26842
[ $mode == debug ]
regexp/pcre_test: Pass, Slow # Timeout. Issue 22008
[ ($runtime == vm || $runtime == dart_precompiled) && $arch == simarmv5te ]
int_parse_radix_test/*: Pass, Slow
big_integer_parsed_mul_div_vm_test: Pass, Slow
[ $compiler == precompiler ]
apply3_test: SkipByDesign # Imports dart:mirrors
big_integer_huge_mul_vm_test: Pass, Timeout # --no_intrinsify
big_integer_parsed_mul_div_vm_test: Pass, Timeout # --no_intrinsify
int_parse_radix_test: Pass, Timeout # --no_intrinsify
regexp/stack-overflow_test: RuntimeError, OK # Smaller limit with irregex interpreter
[ $compiler == precompiler || $compiler == app_jit ]
data_resource_test: Skip # Resolve URI not supported yet in product mode.
package_resource_test: Skip # Resolve URI not supported yet in product mode.
file_resource_test: Skip # Resolve URI not supported yet in product mode.
http_resource_test: Skip # Resolve URI not supported yet in product mode.
[ $arch == simdbc || $arch == simdbc64 ]
regexp/stack-overflow_test: RuntimeError, OK # Smaller limit with irregex interpreter
[ $hot_reload || $hot_reload_rollback ]
big_integer_parsed_mul_div_vm_test: Pass, Slow # Slow.
big_integer_huge_mul_vm_test: Pass, Slow # Slow
[ $compiler == dart2js && $dart2js_with_kernel ]
error_stack_trace1_test: Pass # Issue 27394
symbol_reserved_word_test/03: Pass # Issue 27394
map_test: Crash # Issue 27394
regexp/pcre_test: RuntimeError # Issue 27394
symbol_operator_test/03: RuntimeError # Issue 27394
symbol_reserved_word_test/06: RuntimeError # Issue 27394
symbol_reserved_word_test/09: RuntimeError # Issue 27394
symbol_reserved_word_test/12: RuntimeError # Issue 27394
symbol_test/none: RuntimeError # Issue 27394
[ $compiler == dart2js && $dart2js_with_kernel_in_ssa && $host_checked && $dart2js_with_kernel ]
regress/4562_test/01: Crash # Issue 27394
[ ($compiler == dartk || $compiler == dartkp) && ($runtime == vm || $runtime == dart_precompiled) ]
bool_from_environment2_test/01: MissingCompileTimeError
bool_from_environment2_test/02: MissingCompileTimeError
bool_from_environment2_test/03: MissingCompileTimeError
bool_from_environment2_test/04: MissingCompileTimeError
bool_from_environment2_test/05: MissingCompileTimeError
compare_to2_test: RuntimeError
int_from_environment3_test/01: MissingCompileTimeError
int_from_environment3_test/02: MissingCompileTimeError
int_from_environment3_test/03: MissingCompileTimeError
int_from_environment3_test/04: MissingCompileTimeError
int_from_environment3_test/05: MissingCompileTimeError
string_case_test/01: RuntimeError
string_from_environment3_test/01: MissingCompileTimeError
string_from_environment3_test/02: MissingCompileTimeError
string_from_environment3_test/03: MissingCompileTimeError
string_from_environment3_test/04: MissingCompileTimeError
string_from_environment3_test/05: MissingCompileTimeError
string_trimlr_test/02: RuntimeError
symbol_operator_test/03: RuntimeError
symbol_reserved_word_test/04: MissingCompileTimeError
symbol_reserved_word_test/06: RuntimeError
symbol_reserved_word_test/07: MissingCompileTimeError
symbol_reserved_word_test/09: RuntimeError
symbol_reserved_word_test/10: MissingCompileTimeError
symbol_reserved_word_test/12: RuntimeError
symbol_test/01: MissingCompileTimeError
symbol_test/02: MissingCompileTimeError
symbol_test/03: MissingCompileTimeError
symbol_test/none: RuntimeError
unicode_test: Fail # Bug 6706
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ]
big_integer_parsed_div_rem_vm_test: RuntimeError
big_integer_parsed_mul_div_vm_test: RuntimeError
const_list_literal_test: Crash
const_list_remove_range_test: Crash
const_list_set_range_test: Crash
core_runtime_types_test: Crash
data_uri_test: Crash
date_time2_test: Crash
date_time3_test: Crash
date_time4_test: Crash
date_time7_test: Crash
date_time_parse_test: Crash
date_time_test: Crash
double_floor2_test: Crash
double_parse_test/01: Crash
double_parse_test/02: Crash
double_parse_test/03: Crash
double_parse_test/none: Crash
double_round2_test: Crash
double_truncate2_test: Crash
duration2_test: Crash
duration_big_num_test: Crash
duration_double_multiplication_test: Crash
duration_test: Crash
error_stack_trace1_test: Pass # Issue 27394
error_stack_trace2_test: Crash
error_stack_trace_test: Crash
exception_implementation_test: Crash
expando_test: Crash
for_in_test: Crash
has_next_iterator_test: Crash
hash_map2_test: Crash
hash_set_test/01: Crash
hash_set_test/none: Crash
hash_set_type_check_test: Crash
hashcode_test: Crash
hidden_library2_test/01: Crash
hidden_library2_test/none: Crash
indexed_list_access_test: Crash
int_from_environment3_test/01: MissingCompileTimeError
int_from_environment3_test/02: MissingCompileTimeError
int_from_environment3_test/03: MissingCompileTimeError
int_from_environment3_test/04: MissingCompileTimeError
int_from_environment3_test/05: Crash
int_modulo_arith_test/bignum: Crash
int_modulo_arith_test/modPow: Crash
int_modulo_arith_test/none: Crash
int_parse_radix_bad_handler_test: Crash
int_parse_radix_test/01: Crash
int_parse_radix_test/02: Crash
int_parse_radix_test/none: Crash
integer_to_radix_string_test: Crash
integer_to_string_test/01: RuntimeError
is_operator_basic_types_test: Crash
iterable_contains2_test: Crash
iterable_contains_test: Crash
iterable_element_at_test: Crash
iterable_empty_test: Crash
iterable_expand_test: Crash
iterable_first_test: Crash
iterable_first_where_test: Crash
iterable_fold_test: Crash
iterable_generate_test/01: Crash
iterable_generate_test/none: Crash
iterable_join_test: Crash
iterable_last_test: Crash
iterable_last_where_test: Crash
iterable_length_test: Crash
iterable_mapping_test: Crash
iterable_reduce_test: Crash
iterable_return_type_test/01: Crash
iterable_return_type_test/02: Crash
iterable_return_type_test/none: Crash
iterable_single_test: Crash
iterable_single_where_test: Crash
iterable_skip_test: Crash
iterable_skip_while_test: Crash
iterable_take_test: Crash
iterable_take_while_test: Crash
iterable_test: Crash
iterable_to_list_test/01: Crash
iterable_to_list_test/none: Crash
iterable_to_set_test: Crash
iterable_tostring_test: Crash
json_map_test: Crash
linked_hash_map_from_iterable_test: Crash
linked_hash_map_from_iterables_test: Crash
linked_hash_map_test: Crash
list_as_map_test: Crash
list_contains_argument_order_test: Crash
list_fill_range_test: Crash
list_first_test: Crash
list_fixed_test: Crash
list_for_each_test: Crash
list_get_range_test: Crash
list_growable_test: Crash
list_index_of2_test: RuntimeError
list_insert_all_test: Crash
list_insert_test: Crash
list_iterators_test: Crash
list_last_test: Crash
list_map_test: Crash
list_remove_range_test: Crash
list_removeat_test: Crash
list_replace_range_test: Crash
list_reversed_test: Crash
list_set_all_test: Crash
list_set_range_test: Crash
list_sort_test: RuntimeError
list_sublist_test: Crash
list_test/01: Crash
list_test/none: Crash
list_to_string2_test: Crash
list_to_string_test: Crash
list_unmodifiable_test: Crash
main_test: Crash
map_contains_value_test: Crash
map_from_iterable_test: Crash
map_from_iterables_test: Crash
map_from_test: Crash
map_keys2_test: Crash
map_keys_test: Crash
map_test: Crash
map_to_string_test: Crash
map_values2_test: Crash
map_values3_test: Crash
map_values4_test: Crash
map_values_test: Crash
maps_test: Crash
nan_infinity_test/01: RuntimeError
null_nosuchmethod_test: Crash
null_test: Crash
num_clamp_test: Crash
num_parse_test/01: Crash
num_parse_test/none: Crash
queue_first_test: Crash
queue_iterator_test: Crash
queue_last_test: Crash
queue_single_test: Crash
queue_test: Crash
range_error_test: Crash
reg_exp4_test: Crash
reg_exp5_test: Crash
reg_exp_all_matches_test: Crash
reg_exp_start_end_test: Crash
regexp/ascii-regexp-subject_test: Crash
regexp/bol-with-multiline_test: Crash
regexp/capture-3_test: Crash
regexp/capture_test: Crash
regexp/compile-crash_test: Crash
regexp/compile_test: Crash
regexp/early-acid3-86_test: Crash
regexp/ecma-regex-examples_test: Crash
regexp/extended-characters-more_test: Crash
regexp/global_test: Crash
regexp/indexof_test: Crash
regexp/invalid-range-in-class_test: Crash
regexp/issue_19193_test: Crash
regexp/lastindex_test: Crash
regexp/lookahead_test: Crash
regexp/multiline_test: Crash
regexp/negative-special-characters_test: Crash
regexp/no-extensions_test: Crash
regexp/non-capturing-groups_test: Crash
regexp/parentheses_test: Crash
regexp/pcre-test-4_test: Crash
regexp/pcre_test: Crash
regexp/range-out-of-order_test: Crash
regexp/regexp_kde_test: Crash
regexp/regexp_test: Crash
regexp/regress-regexp-codeflush_test: Crash
regexp/standalones_test: Crash
regexp/toString_test: Crash
regexp/unicode-handling_test: Crash
regexp/unicodeCaseInsensitive_test: Crash
regress_11099_test: Crash
regress_r21715_test: RuntimeError
safe_to_string_test: Crash
set_containsAll_test: Crash
set_contains_test: Crash
set_intersection_test: Crash
set_iterator_test: Crash
set_removeAll_test: Crash
set_remove_test: Crash
set_retainAll_test: Crash
set_test: Crash
set_to_string_test: Crash
shuffle_test: Crash
sort_test: Crash
sort_test: RuntimeError
splay_tree_from_iterable_test: Crash
splay_tree_from_iterables_test: Crash
splay_tree_test: Crash
stacktrace_current_test: Crash
stacktrace_fromstring_test: Crash
stopwatch2_test: Crash
string_base_vm_test: Crash
string_buffer_test: Crash
string_codeunits_test: Crash
string_from_environment3_test/01: MissingCompileTimeError
string_from_environment3_test/02: MissingCompileTimeError
string_from_environment3_test/03: MissingCompileTimeError
string_from_environment3_test/04: MissingCompileTimeError
string_from_environment3_test/05: Crash
string_from_list_test: Crash
string_fromcharcode_test: Crash
string_fromcharcodes_test: Crash
string_operations_with_null_test: Crash
string_pattern_test: Crash
string_replace_all_test: Crash
string_replace_dollar_test: Crash
string_replace_test: Crash
string_runes_test: Crash
string_source_test: Crash
string_split_test: Crash
string_substring_test: Crash
string_test: Crash
string_to_lower_case_test: Crash
string_trimlr_test/01: Crash
string_trimlr_test/02: Crash
string_trimlr_test/none: Crash
symbol_operator_test/03: Crash
symbol_operator_test/none: Crash
symbol_reserved_word_test/04: MissingCompileTimeError
symbol_reserved_word_test/05: Crash
symbol_reserved_word_test/06: Crash
symbol_reserved_word_test/07: MissingCompileTimeError
symbol_reserved_word_test/09: Crash
symbol_reserved_word_test/10: MissingCompileTimeError
symbol_reserved_word_test/12: Crash
symbol_test/01: Crash
symbol_test/02: Crash
symbol_test/03: Crash
symbol_test/none: Crash
[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ]
hash_map_test: Crash
list_sort_test: Crash
map_contains_key_test: Crash
map_index_test: Crash
map_remove_test: Crash
regress_11099_test: Crash
safe_to_string_test: Crash
sort_test: Crash
[ $compiler == dart2js && $dart2js_with_kernel && $minified ]
big_integer_parsed_div_rem_vm_test: RuntimeError
big_integer_parsed_mul_div_vm_test: RuntimeError
const_list_literal_test: Crash
const_list_remove_range_test: Crash
const_list_set_range_test: Crash
core_runtime_types_test: Crash
data_uri_test: Crash
date_time2_test: Crash
date_time3_test: Crash
date_time4_test: Crash
date_time7_test: Crash
date_time_parse_test: Crash
date_time_test: Crash
double_ceil2_test: Crash
double_floor2_test: Crash
double_parse_test/01: Crash
double_parse_test/02: Crash
double_parse_test/03: Crash
double_parse_test/none: Crash
double_round2_test: Crash
double_round3_test: Crash
double_round4_test: Crash
double_round_test: Crash
double_round_to_double2_test: Crash
double_round_to_double3_test: Crash
double_round_to_double_test: Crash
double_truncate2_test: Crash
double_truncate_test: Crash
double_truncate_to_double_test: Crash
duration2_test: Crash
duration_big_num_test: Crash
duration_double_multiplication_test: Crash
duration_test: Crash
error_stack_trace1_test: Crash
error_stack_trace1_test: Pass # Issue 27394
error_stack_trace2_test: Crash
error_stack_trace_test: Crash
errors_test: Crash
exception_implementation_test: Crash
expando_test: Crash
expression_test: Crash
for_in_test: Crash
format_exception_test: Crash
from_environment_const_type_test/01: Crash
from_environment_const_type_test/02: Crash
from_environment_const_type_test/03: Crash
from_environment_const_type_test/04: Crash
from_environment_const_type_test/05: Crash
from_environment_const_type_test/06: Crash
from_environment_const_type_test/07: Crash
from_environment_const_type_test/08: Crash
from_environment_const_type_test/09: Crash
from_environment_const_type_test/10: Crash
from_environment_const_type_test/11: Crash
from_environment_const_type_test/12: Crash
from_environment_const_type_test/13: Crash
from_environment_const_type_test/14: Crash
from_environment_const_type_test/15: Crash
from_environment_const_type_test/16: Crash
from_environment_const_type_test/none: Crash
from_environment_const_type_undefined_test/01: Crash
from_environment_const_type_undefined_test/02: Crash
from_environment_const_type_undefined_test/03: Crash
from_environment_const_type_undefined_test/04: Crash
from_environment_const_type_undefined_test/05: Crash
from_environment_const_type_undefined_test/06: Crash
from_environment_const_type_undefined_test/07: Crash
from_environment_const_type_undefined_test/08: Crash
from_environment_const_type_undefined_test/09: Crash
from_environment_const_type_undefined_test/10: Crash
from_environment_const_type_undefined_test/11: Crash
from_environment_const_type_undefined_test/12: Crash
from_environment_const_type_undefined_test/13: Crash
from_environment_const_type_undefined_test/14: Crash
from_environment_const_type_undefined_test/15: Crash
from_environment_const_type_undefined_test/16: Crash
from_environment_const_type_undefined_test/none: Crash
growable_list_test: Crash
has_next_iterator_test: Crash
hash_map2_test: Crash
int_parse_radix_bad_handler_test: Crash
int_parse_radix_test/01: Crash
int_parse_radix_test/02: Crash
int_parse_radix_test/none: Crash
hash_map_test: Crash
hashcode_boxed_test: Crash
int_ceil_test: Crash
int_ceil_to_double_test: Crash
int_floor_test: Crash
int_floor_to_double_test: Crash
int_from_environment2_test: Crash
int_from_environment_test: Crash
int_round_test: Crash
int_round_to_double_test: Crash
int_to_int_test: Crash
int_truncate_test: Crash
int_truncate_to_double_test: Crash
integer_to_radix_string_test: Crash
integer_to_string_test/01: RuntimeError
is_operator_basic_types_test: Crash
iterable_contains2_test: Crash
iterable_contains_test: Crash
iterable_element_at_test: Crash
iterable_empty_test: Crash
iterable_expand_test: Crash
iterable_first_test: Crash
iterable_first_where_test: Crash
iterable_fold_test: Crash
iterable_generate_test/01: Crash
iterable_generate_test/none: Crash
iterable_join_test: Crash
iterable_last_test: Crash
iterable_last_where_test: Crash
iterable_length_test: Crash
iterable_mapping_test: Crash
iterable_reduce_test: Crash
iterable_return_type_test/01: Crash
iterable_return_type_test/02: Crash
iterable_return_type_test/none: Crash
iterable_single_test: Crash
iterable_single_where_test: Crash
iterable_skip_test: Crash
iterable_skip_while_test: Crash
iterable_take_test: Crash
iterable_take_while_test: Crash
iterable_test: Crash
iterable_to_list_test/01: Crash
iterable_to_list_test/none: Crash
iterable_to_set_test: Crash
iterable_tostring_test: Crash
json_map_test: Crash
linked_hash_map_from_iterable_test: Crash
linked_hash_map_from_iterables_test: Crash
linked_hash_map_test: Crash
list_as_map_test: Crash
list_contains_argument_order_test: Crash
list_fill_range_test: Crash
list_filled_type_argument_test: Crash
list_first_test: Crash
list_fixed_test: Crash
list_for_each_test: Crash
list_get_range_test: Crash
list_growable_test: Crash
list_index_of2_test: Crash
list_index_of_test: Crash
list_literal_is_growable_test: Crash
list_literal_test: Crash
list_sort_test: Crash
map_contains_key_test: Crash
map_index_test: Crash
map_remove_test: Crash
nan_infinity_test/01: Crash
nan_infinity_test/none: Crash
num_sign_test: Crash
print_test/01: Crash
print_test/none: Crash
reg_exp1_test: Crash
reg_exp_first_match_test: Crash
reg_exp_group_test: Crash
reg_exp_groups_test: Crash
reg_exp_has_match_test: Crash
reg_exp_pattern_test: Crash
reg_exp_string_match_test: Crash
regexp/UC16_test: Crash
regexp/alternative-length-miscalculation_test: Crash
regexp/alternatives_test: Crash
regexp/assertion_test: Crash
regexp/backreferences_test: Crash
regexp/bol-with-multiline_test: Crash
regexp/bol_test: Crash
regexp/captures_test: Crash
regexp/char-insensitive_test: Crash
regexp/character-match-out-of-order_test: Crash
regexp/constructor_test: Crash
regexp/default_arguments_test: Crash
regexp/dotstar_test: Crash
regexp/extended-characters-match_test: Crash
regexp/find-first-asserted_test: Crash
regexp/look-ahead_test: Crash
regexp/loop-capture_test: Crash
regexp/malformed-escapes_test: Crash
regexp/many-brackets_test: Crash
regexp/non-bmp_test: Crash
regexp/non-capturing-backtracking_test: Crash
regexp/non-character_test: Crash
regexp/non-greedy-parentheses_test: Crash
regexp/norepeat_test: Crash
regexp/overflow_test: Crash
regexp/parentheses_test: Crash
regexp/quantified-assertions_test: Crash
regexp/range-bound-ffff_test: Crash
regexp/ranges-and-escaped-hyphens_test: Crash
regexp/regress-6-9-regexp_test: Crash
regexp/regress-regexp-construct-result_test: Crash
regexp/repeat-match-waldemar_test: Crash
regexp/results-cache_test: Crash
regexp/stack-overflow2_test: Crash
regexp/stack-overflow_test: Crash
regexp/zero-length-alternatives_test: Crash
regress_11099_test: Crash
regress_r21715_test: RuntimeError
safe_to_string_test: Crash
set_containsAll_test: Crash
set_contains_test: Crash
set_intersection_test: Crash
set_iterator_test: Crash
set_removeAll_test: Crash
set_remove_test: Crash
set_retainAll_test: Crash
set_test: Crash
set_to_string_test: Crash
shuffle_test: Crash
sort_test: RuntimeError
splay_tree_from_iterable_test: Crash
splay_tree_from_iterables_test: Crash
splay_tree_test: Crash
stacktrace_current_test: Crash
stacktrace_fromstring_test: Crash
stopwatch2_test: Crash
string_base_vm_test: Crash
string_buffer_test: Crash
string_codeunits_test: Crash
string_from_environment3_test/01: MissingCompileTimeError
string_from_environment3_test/02: MissingCompileTimeError
string_from_environment3_test/03: MissingCompileTimeError
string_from_environment3_test/04: MissingCompileTimeError
string_from_environment3_test/05: Crash
string_from_list_test: Crash
string_fromcharcode_test: Crash
string_fromcharcodes_test: Crash
string_operations_with_null_test: Crash
string_pattern_test: Crash
string_replace_all_test: Crash
string_replace_dollar_test: Crash
string_replace_test: Crash
string_runes_test: Crash
string_source_test: Crash
string_split_test: Crash
string_substring_test: Crash
string_test: Crash
string_to_lower_case_test: Crash
string_trimlr_test/01: Crash
string_trimlr_test/02: Crash
string_trimlr_test/none: Crash
symbol_operator_test/03: Crash
symbol_operator_test/none: Crash
symbol_reserved_word_test/04: MissingCompileTimeError
symbol_reserved_word_test/05: Crash
symbol_reserved_word_test/06: Crash
symbol_reserved_word_test/07: MissingCompileTimeError
symbol_reserved_word_test/09: Crash
symbol_reserved_word_test/10: MissingCompileTimeError
symbol_reserved_word_test/12: Crash
# dartk: checked mode failures
[ $checked && ($compiler == dartk || $compiler == dartkp) ]
symbol_test/01: Pass
symbol_test/02: Pass
from_environment_const_type_test/02: MissingCompileTimeError
from_environment_const_type_test/03: MissingCompileTimeError
from_environment_const_type_test/04: MissingCompileTimeError
from_environment_const_type_test/06: MissingCompileTimeError
from_environment_const_type_test/07: MissingCompileTimeError
from_environment_const_type_test/08: MissingCompileTimeError
from_environment_const_type_test/09: MissingCompileTimeError
from_environment_const_type_test/11: MissingCompileTimeError
from_environment_const_type_test/12: MissingCompileTimeError
from_environment_const_type_test/13: MissingCompileTimeError
from_environment_const_type_test/14: MissingCompileTimeError
from_environment_const_type_test/16: MissingCompileTimeError
from_environment_const_type_undefined_test/02: MissingCompileTimeError
from_environment_const_type_undefined_test/03: MissingCompileTimeError
from_environment_const_type_undefined_test/04: MissingCompileTimeError
from_environment_const_type_undefined_test/06: MissingCompileTimeError
from_environment_const_type_undefined_test/07: MissingCompileTimeError
from_environment_const_type_undefined_test/08: MissingCompileTimeError
[ $runtime == flutter ]
# No support for mirrors
apply3_test: CompileTimeError
# Possible bugs
bool_from_environment_test: Fail # Flutter Issue 9111
format_exception_test: RuntimeError # Flutter Issue 9111
from_environment_const_type_test/01: Fail # Flutter Issue 9111
from_environment_const_type_test/02: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/03: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/04: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/05: Fail # Flutter Issue 9111
from_environment_const_type_test/06: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/07: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/08: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/09: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/10: Fail # Flutter Issue 9111
from_environment_const_type_test/11: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/12: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/13: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/14: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/15: Fail # Flutter Issue 9111
from_environment_const_type_test/16: MissingCompileTimeError # Flutter Issue 9111
from_environment_const_type_test/none: Fail # Flutter Issue 9111
int_from_environment2_test: Fail # Flutter Issue 9111
int_from_environment_test: Fail # Flutter Issue 9111
main_test: RuntimeError # Flutter Issue 9111
string_from_environment2_test: Fail # Flutter Issue 9111
string_from_environment_test: Fail # Flutter Issue 9111
string_trimlr_test/02: RuntimeError # Flutter Issue 9111

View file

@ -0,0 +1,335 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import "dart:convert";
import "dart:typed_data";
main() {
testMediaType();
testRoundTrip("");
testRoundTrip("a");
testRoundTrip("ab");
testRoundTrip("abc");
testRoundTrip("abcd");
testRoundTrip("Content with special%25 characters: # ? = % # ? = %");
testRoundTrip("blåbærgrød", UTF8);
testRoundTrip("blåbærgrød", LATIN1);
testUriEquals("data:,abc?d");
testUriEquals("DATA:,ABC?D");
testUriEquals("data:,a%20bc?d");
testUriEquals("DATA:,A%20BC?D");
testUriEquals("data:,abc?d%23e"); // # must and will be is escaped.
// Test that UriData.uri normalizes path and query.
testUtf8Encoding("\u1000\uffff");
testBytes();
testInvalidCharacters();
testNormalization();
testErrors();
}
void testMediaType() {
for (var mimeType in ["", "text/plain", "text/javascript"]) {
for (var charset in ["", ";charset=US-ASCII", ";charset=UTF-8"]) {
for (var base64 in ["", ";base64"]) {
bool isBase64 = base64.isNotEmpty;
var text = "data:$mimeType$charset$base64,";
var uri = UriData.parse(text);
String expectedCharset =
charset.isEmpty ? "US-ASCII" : charset.substring(9);
String expectedMimeType = mimeType.isEmpty ? "text/plain" : mimeType;
Expect.equals(text, "$uri");
Expect.equals(expectedMimeType, uri.mimeType);
Expect.equals(expectedCharset, uri.charset);
Expect.equals(isBase64, uri.isBase64);
}
}
}
}
void testRoundTrip(String content, [Encoding encoding]) {
UriData dataUri = new UriData.fromString(content, encoding: encoding);
Expect.isFalse(dataUri.isBase64);
Uri uri = dataUri.uri;
expectUriEquals(new Uri.dataFromString(content, encoding: encoding), uri);
if (encoding != null) {
UriData dataUriParams =
new UriData.fromString(content, parameters: {"charset": encoding.name});
Expect.equals("$dataUri", "$dataUriParams");
}
Expect.equals(encoding ?? ASCII, Encoding.getByName(dataUri.charset));
Expect.equals(content, dataUri.contentAsString(encoding: encoding));
Expect.equals(content, dataUri.contentAsString());
Expect.equals(content, (encoding ?? ASCII).decode(dataUri.contentAsBytes()));
uri = dataUri.uri;
Expect.equals(uri.toString(), dataUri.toString());
Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
dataUri = new UriData.fromBytes(content.codeUnits);
Expect.listEquals(content.codeUnits, dataUri.contentAsBytes());
Expect.equals(content, dataUri.contentAsString(encoding: LATIN1));
uri = dataUri.uri;
Expect.equals(uri.toString(), dataUri.toString());
Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
// Check that the URI is properly normalized.
expectUriEquals(uri, Uri.parse("$uri"));
}
void testUtf8Encoding(String content) {
UriData uri = new UriData.fromString(content, encoding: UTF8);
Expect.equals(content, uri.contentAsString(encoding: UTF8));
Expect.listEquals(UTF8.encode(content), uri.contentAsBytes());
}
void testInvalidCharacters() {
// SPACE, CTL and tspecial, plus '%' and '#' (URI gen-delim)
// This contains all ASCII character that are not valid in attribute/value
// parts.
var invalid =
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x7f'
' ()<>@,;:"/[]?=%#\x80\u{1000}\u{10000}';
var invalidNoSlash = invalid.replaceAll('/', '');
var dataUri = new UriData.fromString(invalid,
encoding: UTF8,
mimeType: "$invalidNoSlash/$invalidNoSlash",
parameters: {invalid: invalid});
Expect.equals(invalid, dataUri.contentAsString());
Expect.equals("$invalidNoSlash/$invalidNoSlash", dataUri.mimeType);
Expect.equals(invalid, dataUri.parameters[invalid]);
var uri = dataUri.uri;
Expect.equals("$uri", "$dataUri");
expectUriEquals(uri, Uri.parse("$uri")); // Check that it's canonicalized.
Expect.equals("$dataUri", new UriData.fromUri(uri).toString());
}
void testBytes() {
void testList(List<int> list) {
var dataUri = new UriData.fromBytes(list);
Expect.equals("application/octet-stream", dataUri.mimeType);
Expect.isTrue(dataUri.isBase64);
Expect.listEquals(list, dataUri.contentAsBytes());
dataUri = new UriData.fromBytes(list, percentEncoded: true);
Expect.equals("application/octet-stream", dataUri.mimeType);
Expect.isFalse(dataUri.isBase64);
Expect.listEquals(list, dataUri.contentAsBytes());
var string = new String.fromCharCodes(list);
dataUri = new UriData.fromString(string, encoding: LATIN1);
Expect.equals("text/plain", dataUri.mimeType);
Expect.isFalse(dataUri.isBase64);
Expect.listEquals(list, dataUri.contentAsBytes());
dataUri = new UriData.fromString(string, encoding: LATIN1, base64: true);
Expect.equals("text/plain", dataUri.mimeType);
Expect.isTrue(dataUri.isBase64);
Expect.listEquals(list, dataUri.contentAsBytes());
}
void testLists(List<int> list) {
testList(list);
for (int i = 0; i < 27; i++) {
testList(list.sublist(i, i + i)); // All lengths from 0 to 27.
}
}
var bytes = new Uint8List(512);
for (int i = 0; i < bytes.length; i++) {
bytes[i] = i;
}
testLists(bytes);
testLists(new List.from(bytes));
testLists(new List.unmodifiable(bytes));
}
void testNormalization() {
// Base-64 normalization.
// Normalized URI-alphabet characters.
Expect.equals(
"data:;base64,AA/+", UriData.parse("data:;base64,AA_-").toString());
// Normalized escapes.
Expect.equals(
"data:;base64,AB==", UriData.parse("data:;base64,A%42=%3D").toString());
Expect.equals("data:;base64,/+/+",
UriData.parse("data:;base64,%5F%2D%2F%2B").toString());
// Normalized padded data.
Expect.equals(
"data:;base64,AA==", UriData.parse("data:;base64,AA%3D%3D").toString());
Expect.equals(
"data:;base64,AAA=", UriData.parse("data:;base64,AAA%3D").toString());
// Normalized unpadded data.
Expect.equals(
"data:;base64,AA==", UriData.parse("data:;base64,AA").toString());
Expect.equals(
"data:;base64,AAA=", UriData.parse("data:;base64,AAA").toString());
// "URI normalization" of non-base64 content.
var uri = UriData.parse("data:,\x20\xa0");
Expect.equals("data:,%20%C2%A0", uri.toString());
uri = UriData.parse("data:,x://x@y:[z]:42/p/./?q=x&y=z#?#\u1234\u{12345}");
Expect.equals(
"data:,x://x@y:%5Bz%5D:42/p/./?q=x&y=z%23?%23%E1%88%B4%F0%92%8D%85",
uri.toString());
}
bool badArgument(e) => e is ArgumentError;
bool badFormat(e) => e is FormatException;
void testErrors() {
// Invalid constructor parameters.
Expect.throws(() {
new UriData.fromBytes([], mimeType: "noslash");
}, badArgument);
Expect.throws(() {
new UriData.fromBytes([257]);
}, badArgument);
Expect.throws(() {
new UriData.fromBytes([-1]);
}, badArgument);
Expect.throws(() {
new UriData.fromBytes([0x10000000]);
}, badArgument);
Expect.throws(() {
new UriData.fromString("", mimeType: "noslash");
}, badArgument);
Expect.throws(() {
new Uri.dataFromBytes([], mimeType: "noslash");
}, badArgument);
Expect.throws(() {
new Uri.dataFromBytes([257]);
}, badArgument);
Expect.throws(() {
new Uri.dataFromBytes([-1]);
}, badArgument);
Expect.throws(() {
new Uri.dataFromBytes([0x10000000]);
}, badArgument);
Expect.throws(() {
new Uri.dataFromString("", mimeType: "noslash");
}, badArgument);
// Empty parameters allowed, not an error.
var uri = new UriData.fromString("", mimeType: "", parameters: {});
Expect.equals("data:,", "$uri");
// Empty parameter key or value is an error.
Expect.throws(
() => new UriData.fromString("", parameters: {"": "X"}), badArgument);
Expect.throws(
() => new UriData.fromString("", parameters: {"X": ""}), badArgument);
// Not recognizing charset is an error.
uri = UriData.parse("data:;charset=arglebargle,X");
Expect.throws(() {
uri.contentAsString();
});
// Doesn't throw if we specify the encoding.
Expect.equals("X", uri.contentAsString(encoding: ASCII));
// Parse format.
Expect.throws(() {
UriData.parse("notdata:,");
}, badFormat);
Expect.throws(() {
UriData.parse("text/plain,noscheme");
}, badFormat);
Expect.throws(() {
UriData.parse("data:noseparator");
}, badFormat);
Expect.throws(() {
UriData.parse("data:noslash,text");
}, badFormat);
Expect.throws(() {
UriData.parse("data:type/sub;noequals,text");
}, badFormat);
Expect.throws(() {
UriData.parse("data:type/sub;knocomma=");
}, badFormat);
Expect.throws(() {
UriData.parse("data:type/sub;k=v;nocomma");
}, badFormat);
Expect.throws(() {
UriData.parse("data:type/sub;k=nocomma");
}, badFormat);
Expect.throws(() {
UriData.parse("data:type/sub;k=v;base64");
}, badFormat);
void formatError(String input) {
Expect.throws(() => UriData.parse("data:;base64,$input"), badFormat, input);
}
// Invalid base64 format (detected when parsed).
for (var a = 0; a <= 4; a++) {
for (var p = 0; p <= 4; p++) {
// Base-64 encoding must have length divisible by four and no more
// than two padding characters at the end.
if (p < 3 && (a + p) % 4 == 0) continue;
if (p == 0 && a > 1) continue;
formatError("A" * a + "=" * p);
formatError("A" * a + "%3D" * p);
}
}
// Invalid base64 encoding: padding not at end.
formatError("AA=A");
formatError("A=AA");
formatError("=AAA");
formatError("A==A");
formatError("==AA");
formatError("===A");
formatError("AAA%3D=");
formatError("A%3D==");
// Invalid unpadded data.
formatError("A");
formatError("AAAAA");
// Invalid characters.
formatError("AAA*");
formatError("AAA\x00");
formatError("AAA\\");
formatError("AAA,");
// Invalid escapes.
formatError("AAA%25");
formatError("AAA%7F");
formatError("AAA%7F");
}
/// Checks that two [Uri]s are exactly the same.
expectUriEquals(Uri expect, Uri actual) {
Expect.equals(expect.scheme, actual.scheme, "scheme");
Expect.equals(expect.hasAuthority, actual.hasAuthority, "hasAuthority");
Expect.equals(expect.userInfo, actual.userInfo, "userInfo");
Expect.equals(expect.host, actual.host, "host");
Expect.equals(expect.hasPort, actual.hasPort, "hasPort");
Expect.equals(expect.port, actual.port, "port");
Expect.equals(expect.port, actual.port, "port");
Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery");
Expect.equals(expect.query, actual.query, "query");
Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment");
Expect.equals(expect.fragment, actual.fragment, "fragment");
}
void testUriEquals(String uriText) {
var data = UriData.parse(uriText);
var uri = Uri.parse(uriText);
Expect.equals(data.uri, uri);
Expect.equals(data.toString(), uri.data.toString());
Expect.equals(data.toString(), uri.toString());
}

View file

@ -0,0 +1,54 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Make sure the years in the range of single digits are handled correctly with
// month roll-over. (This tests an edge condition when delegating to
// JavaScript's Date constructor.)
void check(String expected, DateTime actual) {
Expect.equals(expected, actual.toString());
}
testUtc() {
check("0099-01-01 00:00:00.000Z", new DateTime.utc(99, 1));
check("0100-01-01 00:00:00.000Z", new DateTime.utc(99, 1 + 12));
check("0000-01-01 00:00:00.000Z", new DateTime.utc(0, 1));
check("-0001-01-01 00:00:00.000Z", new DateTime.utc(0, 1 - 12));
check("0099-03-02 00:00:00.000Z", new DateTime.utc(99, 2, 30));
check("0100-03-02 00:00:00.000Z", new DateTime.utc(99, 2 + 12, 30));
check("0004-03-01 00:00:00.000Z", new DateTime.utc(3, 2 + 12, 30));
check("0004-03-01 00:00:00.000Z", new DateTime.utc(4, 2, 30));
check("0004-03-01 00:00:00.000Z", new DateTime.utc(5, 2 - 12, 30));
check("0005-03-02 00:00:00.000Z", new DateTime.utc(4, 2 + 12, 30));
check("0005-03-02 00:00:00.000Z", new DateTime.utc(5, 2, 30));
check("0005-03-02 00:00:00.000Z", new DateTime.utc(6, 2 - 12, 30));
}
testLocal() {
check("0099-01-01 00:00:00.000", new DateTime(99, 1));
check("0100-01-01 00:00:00.000", new DateTime(99, 1 + 12));
check("0000-01-01 00:00:00.000", new DateTime(0, 1));
check("-0001-01-01 00:00:00.000", new DateTime(0, 1 - 12));
check("0099-03-02 00:00:00.000", new DateTime(99, 2, 30));
check("0100-03-02 00:00:00.000", new DateTime(99, 2 + 12, 30));
check("0004-03-01 00:00:00.000", new DateTime(3, 2 + 12, 30));
check("0004-03-01 00:00:00.000", new DateTime(4, 2, 30));
check("0004-03-01 00:00:00.000", new DateTime(5, 2 - 12, 30));
check("0005-03-02 00:00:00.000", new DateTime(4, 2 + 12, 30));
check("0005-03-02 00:00:00.000", new DateTime(5, 2, 30));
check("0005-03-02 00:00:00.000", new DateTime(6, 2 - 12, 30));
}
main() {
testUtc();
testLocal();
}

View file

@ -0,0 +1,16 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for DateTime's hashCode.
main() {
var d = DateTime.parse("2000-01-01T00:00:00Z");
var d2 = DateTime.parse("2000-01-01T00:00:01Z");
// There is no guarantee that the hashcode for these two dates is different,
// but in the worst case we will have to fix this test.
// The important test here is, that DateTime .
Expect.isFalse(d.hashCode == d2.hashCode);
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// At some point dart was emitting a bad padding 0 for Dates where the ms were
// ending with 10.
main() {
String s = "2012-01-30 08:30:00.010";
DateTime d = DateTime.parse(s);
Expect.equals(s, d.toString());
}

View file

@ -0,0 +1,104 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test fromString with 6 digits after the decimal point.
bool get supportsMicroseconds =>
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
main() {
if (supportsMicroseconds) {
testMicrosecondPrecision();
} else {
testMillisecondPrecision();
}
}
void testMillisecondPrecision() {
// We only support milliseconds. If the user supplies more data (the "51"
// here), we round.
DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
Expect.equals(1999, dt1.year);
Expect.equals(1, dt1.month);
Expect.equals(3, dt1.day);
Expect.equals(0, dt1.hour);
Expect.equals(0, dt1.minute);
Expect.equals(0, dt1.second);
Expect.equals(0, dt1.millisecond);
Expect.equals(false, dt1.isUtc);
dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
Expect.equals(1999, dt1.year);
Expect.equals(1, dt1.month);
Expect.equals(2, dt1.day);
Expect.equals(23, dt1.hour);
Expect.equals(59, dt1.minute);
Expect.equals(0, dt1.second);
Expect.equals(0, dt1.millisecond);
Expect.equals(true, dt1.isUtc);
dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
Expect.equals(9, dt1.year);
Expect.equals(9, dt1.month);
Expect.equals(9, dt1.day);
Expect.equals(9, dt1.hour);
Expect.equals(9, dt1.minute);
Expect.equals(9, dt1.second);
Expect.equals(9, dt1.millisecond);
Expect.equals(true, dt1.isUtc);
String svnDate = "2012-03-30T04:28:13.752341Z";
dt1 = DateTime.parse(svnDate);
Expect.equals(2012, dt1.year);
Expect.equals(3, dt1.month);
Expect.equals(30, dt1.day);
Expect.equals(4, dt1.hour);
Expect.equals(28, dt1.minute);
Expect.equals(13, dt1.second);
Expect.equals(752, dt1.millisecond);
Expect.equals(true, dt1.isUtc);
}
void testMicrosecondPrecision() {
DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
Expect.equals(1999, dt1.year);
Expect.equals(1, dt1.month);
Expect.equals(2, dt1.day);
Expect.equals(23, dt1.hour);
Expect.equals(59, dt1.minute);
Expect.equals(59, dt1.second);
Expect.equals(999, dt1.millisecond);
Expect.equals(519, dt1.microsecond);
Expect.equals(false, dt1.isUtc);
dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
Expect.equals(1999, dt1.year);
Expect.equals(1, dt1.month);
Expect.equals(2, dt1.day);
Expect.equals(23, dt1.hour);
Expect.equals(58, dt1.minute);
Expect.equals(59, dt1.second);
Expect.equals(999, dt1.millisecond);
Expect.equals(519, dt1.microsecond);
Expect.equals(true, dt1.isUtc);
dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
Expect.equals(9, dt1.year);
Expect.equals(9, dt1.month);
Expect.equals(9, dt1.day);
Expect.equals(9, dt1.hour);
Expect.equals(9, dt1.minute);
Expect.equals(9, dt1.second);
Expect.equals(9, dt1.millisecond);
Expect.equals(411, dt1.microsecond);
Expect.equals(true, dt1.isUtc);
String svnDate = "2012-03-30T04:28:13.752341Z";
dt1 = DateTime.parse(svnDate);
Expect.equals(2012, dt1.year);
Expect.equals(3, dt1.month);
Expect.equals(30, dt1.day);
Expect.equals(4, dt1.hour);
Expect.equals(28, dt1.minute);
Expect.equals(13, dt1.second);
Expect.equals(752, dt1.millisecond);
Expect.equals(341, dt1.microsecond);
Expect.equals(true, dt1.isUtc);
}

View file

@ -0,0 +1,81 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime constructor with optional arguments.
main() {
var d = new DateTime(2012);
Expect.equals(2012, d.year);
Expect.equals(1, d.month);
Expect.equals(1, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(2012, 1, 28);
Expect.equals(2012, d.year);
Expect.equals(1, d.month);
Expect.equals(28, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(1970, 3);
Expect.equals(1970, d.year);
Expect.equals(3, d.month);
Expect.equals(1, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(1970, 3, 1, 11);
Expect.equals(1970, d.year);
Expect.equals(3, d.month);
Expect.equals(1, d.day);
Expect.equals(11, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(0, 12, 24, 0, 12);
Expect.equals(0, d.year);
Expect.equals(12, d.month);
Expect.equals(24, d.day);
Expect.equals(0, d.hour);
Expect.equals(12, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(-1, 2, 2, 3, 0, 0, 4);
Expect.equals(-1, d.year);
Expect.equals(2, d.month);
Expect.equals(2, d.day);
Expect.equals(3, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(4, d.millisecond);
d = new DateTime(-1, 2, 2, 3, 0, 4);
Expect.equals(-1, d.year);
Expect.equals(2, d.month);
Expect.equals(2, d.day);
Expect.equals(3, d.hour);
Expect.equals(0, d.minute);
Expect.equals(4, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(2012, 5, 15, 13, 21, 33, 12);
Expect.equals(2012, d.year);
Expect.equals(5, d.month);
Expect.equals(15, d.day);
Expect.equals(13, d.hour);
Expect.equals(21, d.minute);
Expect.equals(33, d.second);
Expect.equals(12, d.millisecond);
}

View file

@ -0,0 +1,31 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime comparison operators.
main() {
var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true);
Expect.isTrue(d.isBefore(d2));
Expect.isTrue(!d.isAfter(d2));
Expect.isTrue(d2.isAfter(d));
Expect.isTrue(!d2.isBefore(d));
Expect.isFalse(d2.isBefore(d));
Expect.isFalse(!d2.isAfter(d));
Expect.isFalse(d.isAfter(d2));
Expect.isFalse(!d.isBefore(d2));
d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true);
d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
Expect.isTrue(d.isBefore(d2));
Expect.isTrue(!d.isAfter(d2));
Expect.isTrue(d2.isAfter(d));
Expect.isTrue(!d2.isBefore(d));
Expect.isFalse(d2.isBefore(d));
Expect.isFalse(!d2.isAfter(d));
Expect.isFalse(d.isAfter(d2));
Expect.isFalse(!d.isBefore(d2));
}

View file

@ -0,0 +1,50 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime timeZoneName and timeZoneOffset getters.
testUtc() {
var d = DateTime.parse("2012-03-04T03:25:38.123Z");
Expect.equals("UTC", d.timeZoneName);
Expect.equals(0, d.timeZoneOffset.inSeconds);
}
testLocal() {
checkOffset(String name, Duration offset) {
// Timezone abbreviations are not in bijection with their timezones.
// For example AST stands for "Arab Standard Time" (UTC+03), as well as
// "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time
// and Philippine Standard Time.
//
// Hardcode some common timezones.
if (name == "CET") {
Expect.equals(1, offset.inHours);
} else if (name == "CEST") {
Expect.equals(2, offset.inHours);
} else if (name == "GMT") {
Expect.equals(0, offset.inSeconds);
} else if (name == "EST") {
Expect.equals(-5, offset.inHours);
} else if (name == "EDT") {
Expect.equals(-4, offset.inHours);
} else if (name == "PDT") {
Expect.equals(-7, offset.inHours);
}
}
var d = DateTime.parse("2012-01-02T13:45:23");
String name = d.timeZoneName;
checkOffset(name, d.timeZoneOffset);
d = DateTime.parse("2012-07-02T13:45:23");
name = d.timeZoneName;
checkOffset(name, d.timeZoneOffset);
}
main() {
testUtc();
testLocal();
}

View file

@ -0,0 +1,22 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Make sure the year 0 is correctly printed.
testUtc() {
var d = new DateTime.utc(0, 1, 1);
Expect.equals("0000-01-01 00:00:00.000Z", d.toString());
}
testLocal() {
var d = new DateTime(0, 1, 1);
Expect.equals("0000-01-01 00:00:00.000", d.toString());
}
main() {
testUtc();
testLocal();
}

View file

@ -0,0 +1,42 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
var dt = new DateTime.now();
Expect.isTrue(dt is Comparable);
var dt2 = new DateTime.fromMillisecondsSinceEpoch(100);
var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true);
var dt3b = new DateTime.fromMillisecondsSinceEpoch(200);
var dt4 = new DateTime.fromMillisecondsSinceEpoch(300);
var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true);
var dt5b = new DateTime.fromMillisecondsSinceEpoch(400);
Expect.isTrue(dt2.compareTo(dt2) == 0);
Expect.isTrue(dt3.compareTo(dt3) == 0);
Expect.isTrue(dt3b.compareTo(dt3b) == 0);
Expect.isTrue(dt4.compareTo(dt4) == 0);
Expect.isTrue(dt5.compareTo(dt5) == 0);
Expect.isTrue(dt5b.compareTo(dt5b) == 0);
// Time zones don't have any effect.
Expect.isTrue(dt3.compareTo(dt3b) == 0);
Expect.isTrue(dt5.compareTo(dt5b) == 0);
Expect.isTrue(dt2.compareTo(dt3) < 0);
Expect.isTrue(dt3.compareTo(dt4) < 0);
Expect.isTrue(dt4.compareTo(dt5) < 0);
Expect.isTrue(dt2.compareTo(dt3b) < 0);
Expect.isTrue(dt4.compareTo(dt5b) < 0);
Expect.isTrue(dt3.compareTo(dt2) > 0);
Expect.isTrue(dt4.compareTo(dt3) > 0);
Expect.isTrue(dt5.compareTo(dt4) > 0);
Expect.isTrue(dt3b.compareTo(dt2) > 0);
Expect.isTrue(dt5b.compareTo(dt4) > 0);
}

View file

@ -0,0 +1,52 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
check(DateTime expected, String str) {
DateTime actual = DateTime.parse(str);
Expect.equals(expected, actual); // Only checks if they are at the same time.
Expect.equals(expected.isUtc, actual.isUtc);
}
bool get supportsMicroseconds =>
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
main() {
check(new DateTime(2012, 02, 27, 13, 27), "2012-02-27 13:27:00");
if (supportsMicroseconds) {
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
"2012-02-27 13:27:00.123456z");
} else {
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
"2012-02-27 13:27:00.123z");
}
check(new DateTime(2012, 02, 27, 13, 27), "20120227 13:27:00");
check(new DateTime(2012, 02, 27, 13, 27), "20120227T132700");
check(new DateTime(2012, 02, 27), "20120227");
check(new DateTime(2012, 02, 27), "+20120227");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14Z");
check(new DateTime.utc(-12345, 1, 1), "-123450101 00:00:00 Z");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+0000");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00:00");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14 +00:00");
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00+11");
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11");
check(
new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11:00");
if (supportsMicroseconds) {
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500),
"2015-02-15T00:00:00.500500Z");
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500),
"2015-02-15T00:00:00.511500Z");
} else {
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 501),
"2015-02-15T00:00:00.501Z");
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 512),
"2015-02-15T00:00:00.512Z");
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.throws(() => double.INFINITY.ceil(), (e) => e is UnsupportedError);
Expect.throws(
() => double.NEGATIVE_INFINITY.ceil(), (e) => e is UnsupportedError);
Expect.throws(() => double.NAN.ceil(), (e) => e is UnsupportedError);
}

View file

@ -0,0 +1,84 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.0.ceil());
Expect.equals(1, double.MIN_POSITIVE.ceil());
Expect.equals(1, (2.0 * double.MIN_POSITIVE).ceil());
Expect.equals(1, (1.18e-38).ceil());
Expect.equals(1, (1.18e-38 * 2).ceil());
Expect.equals(1, 0.49999999999999994.ceil());
Expect.equals(1, 0.5.ceil());
Expect.equals(1, 0.9999999999999999.ceil());
Expect.equals(1, 1.0.ceil());
Expect.equals(2, 1.000000000000001.ceil());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496, 4503599627370496.0.ceil());
Expect.equals(4503599627370497, 4503599627370497.0.ceil());
Expect.equals(4503599627370498, 4503599627370498.0.ceil());
Expect.equals(4503599627370499, 4503599627370499.0.ceil());
Expect.equals(9007199254740991, 9007199254740991.0.ceil());
Expect.equals(9007199254740992, 9007199254740992.0.ceil());
Expect.equals(
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
double.MAX_FINITE.ceil());
Expect.equals(0, (-double.MIN_POSITIVE).ceil());
Expect.equals(0, (2.0 * -double.MIN_POSITIVE).ceil());
Expect.equals(0, (-1.18e-38).ceil());
Expect.equals(0, (-1.18e-38 * 2).ceil());
Expect.equals(0, (-0.49999999999999994).ceil());
Expect.equals(0, (-0.5).ceil());
Expect.equals(0, (-0.9999999999999999).ceil());
Expect.equals(-1, (-1.0).ceil());
Expect.equals(-1, (-1.000000000000001).ceil());
Expect.equals(-4503599627370496, (-4503599627370496.0).ceil());
Expect.equals(-4503599627370497, (-4503599627370497.0).ceil());
Expect.equals(-4503599627370498, (-4503599627370498.0).ceil());
Expect.equals(-4503599627370499, (-4503599627370499.0).ceil());
Expect.equals(-9007199254740991, (-9007199254740991.0).ceil());
Expect.equals(-9007199254740992, (-9007199254740992.0).ceil());
Expect.equals(
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
(-double.MAX_FINITE).ceil());
Expect.isTrue(0.0.ceil() is int);
Expect.isTrue(double.MIN_POSITIVE.ceil() is int);
Expect.isTrue((2.0 * double.MIN_POSITIVE).ceil() is int);
Expect.isTrue((1.18e-38).ceil() is int);
Expect.isTrue((1.18e-38 * 2).ceil() is int);
Expect.isTrue(0.49999999999999994.ceil() is int);
Expect.isTrue(0.5.ceil() is int);
Expect.isTrue(0.9999999999999999.ceil() is int);
Expect.isTrue(1.0.ceil() is int);
Expect.isTrue(1.000000000000001.ceil() is int);
Expect.isTrue(4503599627370496.0.ceil() is int);
Expect.isTrue(4503599627370497.0.ceil() is int);
Expect.isTrue(4503599627370498.0.ceil() is int);
Expect.isTrue(4503599627370499.0.ceil() is int);
Expect.isTrue(9007199254740991.0.ceil() is int);
Expect.isTrue(9007199254740992.0.ceil() is int);
Expect.isTrue(double.MAX_FINITE.ceil() is int);
Expect.isTrue((-double.MIN_POSITIVE).ceil() is int);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceil() is int);
Expect.isTrue((-1.18e-38).ceil() is int);
Expect.isTrue((-1.18e-38 * 2).ceil() is int);
Expect.isTrue((-0.49999999999999994).ceil() is int);
Expect.isTrue((-0.5).ceil() is int);
Expect.isTrue((-0.9999999999999999).ceil() is int);
Expect.isTrue((-1.0).ceil() is int);
Expect.isTrue((-1.000000000000001).ceil() is int);
Expect.isTrue((-4503599627370496.0).ceil() is int);
Expect.isTrue((-4503599627370497.0).ceil() is int);
Expect.isTrue((-4503599627370498.0).ceil() is int);
Expect.isTrue((-4503599627370499.0).ceil() is int);
Expect.isTrue((-9007199254740991.0).ceil() is int);
Expect.isTrue((-9007199254740992.0).ceil() is int);
Expect.isTrue((-double.MAX_FINITE).ceil() is int);
}

View file

@ -0,0 +1,93 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.0.ceilToDouble());
Expect.equals(1.0, double.MIN_POSITIVE.ceilToDouble());
Expect.equals(1.0, (2.0 * double.MIN_POSITIVE).ceilToDouble());
Expect.equals(1.0, (1.18e-38).ceilToDouble());
Expect.equals(1.0, (1.18e-38 * 2).ceilToDouble());
Expect.equals(1.0, 0.49999999999999994.ceilToDouble());
Expect.equals(1.0, 0.5.ceilToDouble());
Expect.equals(1.0, 0.9999999999999999.ceilToDouble());
Expect.equals(1.0, 1.0.ceilToDouble());
Expect.equals(2.0, 1.000000000000001.ceilToDouble());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496.0, 4503599627370496.0.ceilToDouble());
Expect.equals(4503599627370497.0, 4503599627370497.0.ceilToDouble());
Expect.equals(4503599627370498.0, 4503599627370498.0.ceilToDouble());
Expect.equals(4503599627370499.0, 4503599627370499.0.ceilToDouble());
Expect.equals(9007199254740991.0, 9007199254740991.0.ceilToDouble());
Expect.equals(9007199254740992.0, 9007199254740992.0.ceilToDouble());
Expect.equals(double.MAX_FINITE, double.MAX_FINITE.ceilToDouble());
Expect.equals(0.0, (-double.MIN_POSITIVE).ceilToDouble());
Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).ceilToDouble());
Expect.equals(0.0, (-1.18e-38).ceilToDouble());
Expect.equals(0.0, (-1.18e-38 * 2).ceilToDouble());
Expect.equals(0.0, (-0.49999999999999994).ceilToDouble());
Expect.equals(0.0, (-0.5).ceilToDouble());
Expect.equals(0.0, (-0.9999999999999999).ceilToDouble());
Expect.equals(-1.0, (-1.0).ceilToDouble());
Expect.equals(-1.0, (-1.000000000000001).ceilToDouble());
Expect.equals(-4503599627370496.0, (-4503599627370496.0).ceilToDouble());
Expect.equals(-4503599627370497.0, (-4503599627370497.0).ceilToDouble());
Expect.equals(-4503599627370498.0, (-4503599627370498.0).ceilToDouble());
Expect.equals(-4503599627370499.0, (-4503599627370499.0).ceilToDouble());
Expect.equals(-9007199254740991.0, (-9007199254740991.0).ceilToDouble());
Expect.equals(-9007199254740992.0, (-9007199254740992.0).ceilToDouble());
Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).ceilToDouble());
Expect.equals(double.INFINITY, double.INFINITY.ceilToDouble());
Expect.equals(
double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.ceilToDouble());
Expect.isTrue(double.NAN.ceilToDouble().isNaN);
Expect.isTrue(0.0.ceilToDouble() is double);
Expect.isTrue(double.MIN_POSITIVE.ceilToDouble() is double);
Expect.isTrue((2.0 * double.MIN_POSITIVE).ceilToDouble() is double);
Expect.isTrue((1.18e-38).ceilToDouble() is double);
Expect.isTrue((1.18e-38 * 2).ceilToDouble() is double);
Expect.isTrue(0.49999999999999994.ceilToDouble() is double);
Expect.isTrue(0.5.ceilToDouble() is double);
Expect.isTrue(0.9999999999999999.ceilToDouble() is double);
Expect.isTrue(1.0.ceilToDouble() is double);
Expect.isTrue(1.000000000000001.ceilToDouble() is double);
Expect.isTrue(4503599627370496.0.ceilToDouble() is double);
Expect.isTrue(4503599627370497.0.ceilToDouble() is double);
Expect.isTrue(4503599627370498.0.ceilToDouble() is double);
Expect.isTrue(4503599627370499.0.ceilToDouble() is double);
Expect.isTrue(9007199254740991.0.ceilToDouble() is double);
Expect.isTrue(9007199254740992.0.ceilToDouble() is double);
Expect.isTrue(double.MAX_FINITE.ceilToDouble() is double);
Expect.isTrue((-double.MIN_POSITIVE).ceilToDouble().isNegative);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceilToDouble().isNegative);
Expect.isTrue((-1.18e-38).ceilToDouble().isNegative);
Expect.isTrue((-1.18e-38 * 2).ceilToDouble().isNegative);
Expect.isTrue((-0.49999999999999994).ceilToDouble().isNegative);
Expect.isTrue((-0.5).ceilToDouble().isNegative);
Expect.isTrue((-0.9999999999999999).ceilToDouble().isNegative);
Expect.isTrue((-double.MIN_POSITIVE).ceilToDouble() is double);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceilToDouble() is double);
Expect.isTrue((-1.18e-38).ceilToDouble() is double);
Expect.isTrue((-1.18e-38 * 2).ceilToDouble() is double);
Expect.isTrue((-0.49999999999999994).ceilToDouble() is double);
Expect.isTrue((-0.5).ceilToDouble() is double);
Expect.isTrue((-0.9999999999999999).ceilToDouble() is double);
Expect.isTrue((-1.0).ceilToDouble() is double);
Expect.isTrue((-1.000000000000001).ceilToDouble() is double);
Expect.isTrue((-4503599627370496.0).ceilToDouble() is double);
Expect.isTrue((-4503599627370497.0).ceilToDouble() is double);
Expect.isTrue((-4503599627370498.0).ceilToDouble() is double);
Expect.isTrue((-4503599627370499.0).ceilToDouble() is double);
Expect.isTrue((-9007199254740991.0).ceilToDouble() is double);
Expect.isTrue((-9007199254740992.0).ceilToDouble() is double);
Expect.isTrue((-double.MAX_FINITE).ceilToDouble() is double);
}

View file

@ -0,0 +1,49 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for testing 'compare' on doubles.
void main() {
Expect.equals(0, (0.0).compareTo(0.0));
Expect.equals(0, (1.0).compareTo(1.0));
Expect.equals(0, (-2.0).compareTo(-2.0));
Expect.equals(0, (1e-50).compareTo(1e-50));
Expect.equals(0, (-2e50).compareTo(-2e50));
Expect.equals(0, double.NAN.compareTo(double.NAN));
Expect.equals(0, double.INFINITY.compareTo(double.INFINITY));
Expect.equals(
0, double.NEGATIVE_INFINITY.compareTo(double.NEGATIVE_INFINITY));
Expect.equals(0, (-0.0).compareTo(-0.0));
Expect.isTrue((0.0).compareTo(1.0) < 0);
Expect.isTrue((1.0).compareTo(0.0) > 0);
Expect.isTrue((0.0).compareTo(-1.0) > 0);
Expect.isTrue((-1.0).compareTo(0.0) < 0);
Expect.isTrue((0.0).compareTo(1234e11) < 0);
Expect.isTrue((123e-112).compareTo(0.0) > 0);
Expect.isTrue((0.0).compareTo(-123.0e12) > 0);
Expect.isTrue((-1.0e8).compareTo(0.0) < 0);
double maxDouble = 1.7976931348623157e308;
Expect.equals(0, maxDouble.compareTo(maxDouble));
Expect.isTrue(maxDouble.compareTo(double.INFINITY) < 0);
Expect.isTrue(double.INFINITY.compareTo(maxDouble) > 0);
double negMaxDouble = -maxDouble;
Expect.equals(0, negMaxDouble.compareTo(negMaxDouble));
Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(negMaxDouble) < 0);
Expect.isTrue(negMaxDouble.compareTo(double.NEGATIVE_INFINITY) > 0);
Expect.isTrue((-0.0).compareTo(0.0) < 0);
Expect.isTrue((0.0).compareTo(-0.0) > 0);
Expect.isTrue(double.NAN.compareTo(double.INFINITY) > 0);
Expect.isTrue(double.NAN.compareTo(double.NEGATIVE_INFINITY) > 0);
Expect.isTrue(double.INFINITY.compareTo(double.NAN) < 0);
Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(double.NAN) < 0);
Expect.isTrue(maxDouble.compareTo(double.NAN) < 0);
Expect.isTrue(negMaxDouble.compareTo(double.NAN) < 0);
Expect.isTrue(double.NAN.compareTo(maxDouble) > 0);
Expect.isTrue(double.NAN.compareTo(negMaxDouble) > 0);
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.throws(() => double.INFINITY.floor(), (e) => e is UnsupportedError);
Expect.throws(
() => double.NEGATIVE_INFINITY.floor(), (e) => e is UnsupportedError);
Expect.throws(() => double.NAN.floor(), (e) => e is UnsupportedError);
}

View file

@ -0,0 +1,84 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.0.floor());
Expect.equals(0, double.MIN_POSITIVE.floor());
Expect.equals(0, (2.0 * double.MIN_POSITIVE).floor());
Expect.equals(0, (1.18e-38).floor());
Expect.equals(0, (1.18e-38 * 2).floor());
Expect.equals(0, 0.49999999999999994.floor());
Expect.equals(0, 0.5.floor());
Expect.equals(0, 0.9999999999999999.floor());
Expect.equals(1, 1.0.floor());
Expect.equals(1, 1.000000000000001.floor());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496, 4503599627370496.0.floor());
Expect.equals(4503599627370497, 4503599627370497.0.floor());
Expect.equals(4503599627370498, 4503599627370498.0.floor());
Expect.equals(4503599627370499, 4503599627370499.0.floor());
Expect.equals(9007199254740991, 9007199254740991.0.floor());
Expect.equals(9007199254740992, 9007199254740992.0.floor());
Expect.equals(
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
double.MAX_FINITE.floor());
Expect.equals(-1, (-double.MIN_POSITIVE).floor());
Expect.equals(-1, (2.0 * -double.MIN_POSITIVE).floor());
Expect.equals(-1, (-1.18e-38).floor());
Expect.equals(-1, (-1.18e-38 * 2).floor());
Expect.equals(-1, (-0.49999999999999994).floor());
Expect.equals(-1, (-0.5).floor());
Expect.equals(-1, (-0.9999999999999999).floor());
Expect.equals(-1, (-1.0).floor());
Expect.equals(-2, (-1.000000000000001).floor());
Expect.equals(-4503599627370496, (-4503599627370496.0).floor());
Expect.equals(-4503599627370497, (-4503599627370497.0).floor());
Expect.equals(-4503599627370498, (-4503599627370498.0).floor());
Expect.equals(-4503599627370499, (-4503599627370499.0).floor());
Expect.equals(-9007199254740991, (-9007199254740991.0).floor());
Expect.equals(-9007199254740992, (-9007199254740992.0).floor());
Expect.equals(
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
(-double.MAX_FINITE).floor());
Expect.isTrue(0.0.floor() is int);
Expect.isTrue(double.MIN_POSITIVE.floor() is int);
Expect.isTrue((2.0 * double.MIN_POSITIVE).floor() is int);
Expect.isTrue((1.18e-38).floor() is int);
Expect.isTrue((1.18e-38 * 2).floor() is int);
Expect.isTrue(0.49999999999999994.floor() is int);
Expect.isTrue(0.5.floor() is int);
Expect.isTrue(0.9999999999999999.floor() is int);
Expect.isTrue(1.0.floor() is int);
Expect.isTrue(1.000000000000001.floor() is int);
Expect.isTrue(4503599627370496.0.floor() is int);
Expect.isTrue(4503599627370497.0.floor() is int);
Expect.isTrue(4503599627370498.0.floor() is int);
Expect.isTrue(4503599627370499.0.floor() is int);
Expect.isTrue(9007199254740991.0.floor() is int);
Expect.isTrue(9007199254740992.0.floor() is int);
Expect.isTrue(double.MAX_FINITE.floor() is int);
Expect.isTrue((-double.MIN_POSITIVE).floor() is int);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).floor() is int);
Expect.isTrue((-1.18e-38).floor() is int);
Expect.isTrue((-1.18e-38 * 2).floor() is int);
Expect.isTrue((-0.49999999999999994).floor() is int);
Expect.isTrue((-0.5).floor() is int);
Expect.isTrue((-0.9999999999999999).floor() is int);
Expect.isTrue((-1.0).floor() is int);
Expect.isTrue((-1.000000000000001).floor() is int);
Expect.isTrue((-4503599627370496.0).floor() is int);
Expect.isTrue((-4503599627370497.0).floor() is int);
Expect.isTrue((-4503599627370498.0).floor() is int);
Expect.isTrue((-4503599627370499.0).floor() is int);
Expect.isTrue((-9007199254740991.0).floor() is int);
Expect.isTrue((-9007199254740992.0).floor() is int);
Expect.isTrue((-double.MAX_FINITE).floor() is int);
}

View file

@ -0,0 +1,85 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.0.floorToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.floorToDouble());
Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).floorToDouble());
Expect.equals(0.0, (1.18e-38).floorToDouble());
Expect.equals(0.0, (1.18e-38 * 2).floorToDouble());
Expect.equals(0.0, 0.49999999999999994.floorToDouble());
Expect.equals(0.0, 0.5.floorToDouble());
Expect.equals(0.0, 0.9999999999999999.floorToDouble());
Expect.equals(1.0, 1.0.floorToDouble());
Expect.equals(1.0, 1.000000000000001.floorToDouble());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496.0, 4503599627370496.0.floorToDouble());
Expect.equals(4503599627370497.0, 4503599627370497.0.floorToDouble());
Expect.equals(4503599627370498.0, 4503599627370498.0.floorToDouble());
Expect.equals(4503599627370499.0, 4503599627370499.0.floorToDouble());
Expect.equals(9007199254740991.0, 9007199254740991.0.floorToDouble());
Expect.equals(9007199254740992.0, 9007199254740992.0.floorToDouble());
Expect.equals(double.MAX_FINITE, double.MAX_FINITE.floorToDouble());
Expect.equals(-1.0, (-double.MIN_POSITIVE).floorToDouble());
Expect.equals(-1.0, (2.0 * -double.MIN_POSITIVE).floorToDouble());
Expect.equals(-1.0, (-1.18e-38).floorToDouble());
Expect.equals(-1.0, (-1.18e-38 * 2).floorToDouble());
Expect.equals(-1.0, (-0.49999999999999994).floorToDouble());
Expect.equals(-1.0, (-0.5).floorToDouble());
Expect.equals(-1.0, (-0.9999999999999999).floorToDouble());
Expect.equals(-1.0, (-1.0).floorToDouble());
Expect.equals(-2.0, (-1.000000000000001).floorToDouble());
Expect.equals(-4503599627370496.0, (-4503599627370496.0).floorToDouble());
Expect.equals(-4503599627370497.0, (-4503599627370497.0).floorToDouble());
Expect.equals(-4503599627370498.0, (-4503599627370498.0).floorToDouble());
Expect.equals(-4503599627370499.0, (-4503599627370499.0).floorToDouble());
Expect.equals(-9007199254740991.0, (-9007199254740991.0).floorToDouble());
Expect.equals(-9007199254740992.0, (-9007199254740992.0).floorToDouble());
Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).floorToDouble());
Expect.equals(double.INFINITY, double.INFINITY.floorToDouble());
Expect.equals(
double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.floorToDouble());
Expect.isTrue(double.NAN.floorToDouble().isNaN);
Expect.isTrue(0.0.floorToDouble() is double);
Expect.isTrue(double.MIN_POSITIVE.floorToDouble() is double);
Expect.isTrue((2.0 * double.MIN_POSITIVE).floorToDouble() is double);
Expect.isTrue((1.18e-38).floorToDouble() is double);
Expect.isTrue((1.18e-38 * 2).floorToDouble() is double);
Expect.isTrue(0.49999999999999994.floorToDouble() is double);
Expect.isTrue(0.5.floorToDouble() is double);
Expect.isTrue(0.9999999999999999.floorToDouble() is double);
Expect.isTrue(1.0.floorToDouble() is double);
Expect.isTrue(1.000000000000001.floorToDouble() is double);
Expect.isTrue(4503599627370496.0.floorToDouble() is double);
Expect.isTrue(4503599627370497.0.floorToDouble() is double);
Expect.isTrue(4503599627370498.0.floorToDouble() is double);
Expect.isTrue(4503599627370499.0.floorToDouble() is double);
Expect.isTrue(9007199254740991.0.floorToDouble() is double);
Expect.isTrue(9007199254740992.0.floorToDouble() is double);
Expect.isTrue(double.MAX_FINITE.floorToDouble() is double);
Expect.isTrue((-double.MIN_POSITIVE).floorToDouble() is double);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).floorToDouble() is double);
Expect.isTrue((-1.18e-38).floorToDouble() is double);
Expect.isTrue((-1.18e-38 * 2).floorToDouble() is double);
Expect.isTrue((-0.49999999999999994).floorToDouble() is double);
Expect.isTrue((-0.5).floorToDouble() is double);
Expect.isTrue((-0.9999999999999999).floorToDouble() is double);
Expect.isTrue((-1.0).floorToDouble() is double);
Expect.isTrue((-1.000000000000001).floorToDouble() is double);
Expect.isTrue((-4503599627370496.0).floorToDouble() is double);
Expect.isTrue((-4503599627370497.0).floorToDouble() is double);
Expect.isTrue((-4503599627370498.0).floorToDouble() is double);
Expect.isTrue((-4503599627370499.0).floorToDouble() is double);
Expect.isTrue((-9007199254740991.0).floorToDouble() is double);
Expect.isTrue((-9007199254740992.0).floorToDouble() is double);
Expect.isTrue((-double.MAX_FINITE).floorToDouble() is double);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.throws(() => double.INFINITY.round(), (e) => e is UnsupportedError);
Expect.throws(
() => double.NEGATIVE_INFINITY.round(), (e) => e is UnsupportedError);
Expect.throws(() => double.NAN.round(), (e) => e is UnsupportedError);
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.49999999999999994.round());
Expect.equals(0, (-0.49999999999999994).round());
Expect.isTrue(0.49999999999999994.round() is int);
Expect.isTrue((-0.49999999999999994).round() is int);
}

View file

@ -0,0 +1,38 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496, 4503599627370496.0.round());
Expect.equals(4503599627370497, 4503599627370497.0.round());
Expect.equals(4503599627370498, 4503599627370498.0.round());
Expect.equals(4503599627370499, 4503599627370499.0.round());
Expect.equals(9007199254740991, 9007199254740991.0.round());
Expect.equals(9007199254740992, 9007199254740992.0.round());
Expect.equals(-4503599627370496, (-4503599627370496.0).round());
Expect.equals(-4503599627370497, (-4503599627370497.0).round());
Expect.equals(-4503599627370498, (-4503599627370498.0).round());
Expect.equals(-4503599627370499, (-4503599627370499.0).round());
Expect.equals(-9007199254740991, (-9007199254740991.0).round());
Expect.equals(-9007199254740992, (-9007199254740992.0).round());
Expect.isTrue(4503599627370496.0.round() is int);
Expect.isTrue(4503599627370497.0.round() is int);
Expect.isTrue(4503599627370498.0.round() is int);
Expect.isTrue(4503599627370499.0.round() is int);
Expect.isTrue(9007199254740991.0.round() is int);
Expect.isTrue(9007199254740992.0.round() is int);
Expect.isTrue((-4503599627370496.0).round() is int);
Expect.isTrue((-4503599627370497.0).round() is int);
Expect.isTrue((-4503599627370498.0).round() is int);
Expect.isTrue((-4503599627370499.0).round() is int);
Expect.isTrue((-9007199254740991.0).round() is int);
Expect.isTrue((-9007199254740992.0).round() is int);
}

View file

@ -0,0 +1,54 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.0.round());
Expect.equals(0, double.MIN_POSITIVE.round());
Expect.equals(0, (2.0 * double.MIN_POSITIVE).round());
Expect.equals(0, (1.18e-38).round());
Expect.equals(0, (1.18e-38 * 2).round());
Expect.equals(1, 0.5.round());
Expect.equals(1, 0.9999999999999999.round());
Expect.equals(1, 1.0.round());
Expect.equals(1, 1.000000000000001.round());
Expect.equals(
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
double.MAX_FINITE.round());
Expect.equals(0, (-double.MIN_POSITIVE).round());
Expect.equals(0, (2.0 * -double.MIN_POSITIVE).round());
Expect.equals(0, (-1.18e-38).round());
Expect.equals(0, (-1.18e-38 * 2).round());
Expect.equals(-1, (-0.5).round());
Expect.equals(-1, (-0.9999999999999999).round());
Expect.equals(-1, (-1.0).round());
Expect.equals(-1, (-1.000000000000001).round());
Expect.equals(
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
(-double.MAX_FINITE).round());
Expect.isTrue(0.0.round() is int);
Expect.isTrue(double.MIN_POSITIVE.round() is int);
Expect.isTrue((2.0 * double.MIN_POSITIVE).round() is int);
Expect.isTrue((1.18e-38).round() is int);
Expect.isTrue((1.18e-38 * 2).round() is int);
Expect.isTrue(0.5.round() is int);
Expect.isTrue(0.9999999999999999.round() is int);
Expect.isTrue(1.0.round() is int);
Expect.isTrue(1.000000000000001.round() is int);
Expect.isTrue(double.MAX_FINITE.round() is int);
Expect.isTrue((-double.MIN_POSITIVE).round() is int);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).round() is int);
Expect.isTrue((-1.18e-38).round() is int);
Expect.isTrue((-1.18e-38 * 2).round() is int);
Expect.isTrue((-0.5).round() is int);
Expect.isTrue((-0.9999999999999999).round() is int);
Expect.isTrue((-1.0).round() is int);
Expect.isTrue((-1.000000000000001).round() is int);
Expect.isTrue((-double.MAX_FINITE).round() is int);
}

View file

@ -0,0 +1,13 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.49999999999999994.roundToDouble());
Expect.equals(0.0, (-0.49999999999999994).roundToDouble());
Expect.isTrue(0.49999999999999994.roundToDouble() is double);
Expect.isTrue((-0.49999999999999994).roundToDouble().isNegative);
Expect.isTrue((-0.49999999999999994).roundToDouble() is double);
}

View file

@ -0,0 +1,34 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496.0, 4503599627370496.0.roundToDouble());
Expect.equals(4503599627370497.0, 4503599627370497.0.roundToDouble());
Expect.equals(4503599627370498.0, 4503599627370498.0.roundToDouble());
Expect.equals(4503599627370499.0, 4503599627370499.0.roundToDouble());
Expect.equals(9007199254740991.0, 9007199254740991.0.roundToDouble());
Expect.equals(9007199254740992.0, 9007199254740992.0.roundToDouble());
Expect.equals(-4503599627370496.0, (-4503599627370496.0).roundToDouble());
Expect.equals(-4503599627370497.0, (-4503599627370497.0).roundToDouble());
Expect.equals(-4503599627370498.0, (-4503599627370498.0).roundToDouble());
Expect.equals(-4503599627370499.0, (-4503599627370499.0).roundToDouble());
Expect.equals(-9007199254740991.0, (-9007199254740991.0).roundToDouble());
Expect.equals(-9007199254740992.0, (-9007199254740992.0).roundToDouble());
Expect.isTrue(4503599627370496.0.roundToDouble() is double);
Expect.isTrue(4503599627370497.0.roundToDouble() is double);
Expect.isTrue(4503599627370498.0.roundToDouble() is double);
Expect.isTrue(4503599627370499.0.roundToDouble() is double);
Expect.isTrue(9007199254740991.0.roundToDouble() is double);
Expect.isTrue(9007199254740992.0.roundToDouble() is double);
Expect.isTrue((-4503599627370496.0).roundToDouble() is double);
Expect.isTrue((-4503599627370497.0).roundToDouble() is double);
Expect.isTrue((-4503599627370498.0).roundToDouble() is double);
Expect.isTrue((-4503599627370499.0).roundToDouble() is double);
Expect.isTrue((-9007199254740991.0).roundToDouble() is double);
Expect.isTrue((-9007199254740992.0).roundToDouble() is double);
}

View file

@ -0,0 +1,62 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.0.roundToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.roundToDouble());
Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).roundToDouble());
Expect.equals(0.0, (1.18e-38).roundToDouble());
Expect.equals(0.0, (1.18e-38 * 2).roundToDouble());
Expect.equals(1.0, 0.5.roundToDouble());
Expect.equals(1.0, 0.9999999999999999.roundToDouble());
Expect.equals(1.0, 1.0.roundToDouble());
Expect.equals(1.0, 1.000000000000001.roundToDouble());
Expect.equals(2.0, 1.5.roundToDouble());
Expect.equals(double.MAX_FINITE, double.MAX_FINITE.roundToDouble());
Expect.equals(0.0, (-double.MIN_POSITIVE).roundToDouble());
Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).roundToDouble());
Expect.equals(0.0, (-1.18e-38).roundToDouble());
Expect.equals(0.0, (-1.18e-38 * 2).roundToDouble());
Expect.equals(-1.0, (-0.5).roundToDouble());
Expect.equals(-1.0, (-0.9999999999999999).roundToDouble());
Expect.equals(-1.0, (-1.0).roundToDouble());
Expect.equals(-1.0, (-1.000000000000001).roundToDouble());
Expect.equals(-2.0, (-1.5).roundToDouble());
Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).roundToDouble());
Expect.equals(double.INFINITY, double.INFINITY.roundToDouble());
Expect.equals(
double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.roundToDouble());
Expect.isTrue(double.NAN.roundToDouble().isNaN);
Expect.isTrue(0.0.roundToDouble() is double);
Expect.isTrue(double.MIN_POSITIVE.roundToDouble() is double);
Expect.isTrue((2.0 * double.MIN_POSITIVE).roundToDouble() is double);
Expect.isTrue((1.18e-38).roundToDouble() is double);
Expect.isTrue((1.18e-38 * 2).roundToDouble() is double);
Expect.isTrue(0.5.roundToDouble() is double);
Expect.isTrue(0.9999999999999999.roundToDouble() is double);
Expect.isTrue(1.0.roundToDouble() is double);
Expect.isTrue(1.000000000000001.roundToDouble() is double);
Expect.isTrue(double.MAX_FINITE.roundToDouble() is double);
Expect.isTrue((-double.MIN_POSITIVE).roundToDouble().isNegative);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).roundToDouble().isNegative);
Expect.isTrue((-1.18e-38).roundToDouble().isNegative);
Expect.isTrue((-1.18e-38 * 2).roundToDouble().isNegative);
Expect.isTrue((-double.MIN_POSITIVE).roundToDouble() is double);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).roundToDouble() is double);
Expect.isTrue((-1.18e-38).roundToDouble() is double);
Expect.isTrue((-1.18e-38 * 2).roundToDouble() is double);
Expect.isTrue((-0.5).roundToDouble() is double);
Expect.isTrue((-0.9999999999999999).roundToDouble() is double);
Expect.isTrue((-1.0).roundToDouble() is double);
Expect.isTrue((-1.000000000000001).roundToDouble() is double);
Expect.isTrue((-double.MAX_FINITE).roundToDouble() is double);
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.throws(() => double.INFINITY.truncate(), (e) => e is UnsupportedError);
Expect.throws(
() => double.NEGATIVE_INFINITY.truncate(), (e) => e is UnsupportedError);
Expect.throws(() => double.NAN.truncate(), (e) => e is UnsupportedError);
}

View file

@ -0,0 +1,92 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.0.truncate());
Expect.equals(0, double.MIN_POSITIVE.truncate());
Expect.equals(0, (2.0 * double.MIN_POSITIVE).truncate());
Expect.equals(0, (1.18e-38).truncate());
Expect.equals(0, (1.18e-38 * 2).truncate());
Expect.equals(0, 0.49999999999999994.truncate());
Expect.equals(0, 0.5.truncate());
Expect.equals(0, 0.9999999999999999.truncate());
Expect.equals(1, 1.0.truncate());
Expect.equals(1, 1.000000000000001.truncate());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496, 4503599627370496.0.truncate());
Expect.equals(4503599627370497, 4503599627370497.0.truncate());
Expect.equals(4503599627370498, 4503599627370498.0.truncate());
Expect.equals(4503599627370499, 4503599627370499.0.truncate());
Expect.equals(9007199254740991, 9007199254740991.0.truncate());
Expect.equals(9007199254740992, 9007199254740992.0.truncate());
Expect.equals(
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
double.MAX_FINITE.truncate());
Expect.equals(0, (-double.MIN_POSITIVE).truncate());
Expect.equals(0, (2.0 * -double.MIN_POSITIVE).truncate());
Expect.equals(0, (-1.18e-38).truncate());
Expect.equals(0, (-1.18e-38 * 2).truncate());
Expect.equals(0, (-0.49999999999999994).truncate());
Expect.equals(0, (-0.5).truncate());
Expect.equals(0, (-0.9999999999999999).truncate());
Expect.equals(-1, (-1.0).truncate());
Expect.equals(-1, (-1.000000000000001).truncate());
Expect.equals(-4503599627370496, (-4503599627370496.0).truncate());
Expect.equals(-4503599627370497, (-4503599627370497.0).truncate());
Expect.equals(-4503599627370498, (-4503599627370498.0).truncate());
Expect.equals(-4503599627370499, (-4503599627370499.0).truncate());
Expect.equals(-9007199254740991, (-9007199254740991.0).truncate());
Expect.equals(-9007199254740992, (-9007199254740992.0).truncate());
Expect.equals(
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
(-double.MAX_FINITE).truncate());
Expect.isTrue(0.0.truncate() is int);
Expect.isTrue(double.MIN_POSITIVE.truncate() is int);
Expect.isTrue((2.0 * double.MIN_POSITIVE).truncate() is int);
Expect.isTrue((1.18e-38).truncate() is int);
Expect.isTrue((1.18e-38 * 2).truncate() is int);
Expect.isTrue(0.49999999999999994.truncate() is int);
Expect.isTrue(0.5.truncate() is int);
Expect.isTrue(0.9999999999999999.truncate() is int);
Expect.isTrue(1.0.truncate() is int);
Expect.isTrue(1.000000000000001.truncate() is int);
Expect.isTrue(4503599627370496.0.truncate() is int);
Expect.isTrue(4503599627370497.0.truncate() is int);
Expect.isTrue(4503599627370498.0.truncate() is int);
Expect.isTrue(4503599627370499.0.truncate() is int);
Expect.isTrue(9007199254740991.0.truncate() is int);
Expect.isTrue(9007199254740992.0.truncate() is int);
Expect.isTrue(double.MAX_FINITE.truncate() is int);
Expect.isTrue((-double.MIN_POSITIVE).truncateToDouble().isNegative);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncateToDouble().isNegative);
Expect.isTrue((-1.18e-38).truncateToDouble().isNegative);
Expect.isTrue((-1.18e-38 * 2).truncateToDouble().isNegative);
Expect.isTrue((-0.49999999999999994).truncateToDouble().isNegative);
Expect.isTrue((-0.5).truncateToDouble().isNegative);
Expect.isTrue((-0.9999999999999999).truncateToDouble().isNegative);
Expect.isTrue((-double.MIN_POSITIVE).truncate() is int);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncate() is int);
Expect.isTrue((-1.18e-38).truncate() is int);
Expect.isTrue((-1.18e-38 * 2).truncate() is int);
Expect.isTrue((-0.49999999999999994).truncate() is int);
Expect.isTrue((-0.5).truncate() is int);
Expect.isTrue((-0.9999999999999999).truncate() is int);
Expect.isTrue((-1.0).truncate() is int);
Expect.isTrue((-1.000000000000001).truncate() is int);
Expect.isTrue((-4503599627370496.0).truncate() is int);
Expect.isTrue((-4503599627370497.0).truncate() is int);
Expect.isTrue((-4503599627370498.0).truncate() is int);
Expect.isTrue((-4503599627370499.0).truncate() is int);
Expect.isTrue((-9007199254740991.0).truncate() is int);
Expect.isTrue((-9007199254740992.0).truncate() is int);
Expect.isTrue((-double.MAX_FINITE).truncate() is int);
}

View file

@ -0,0 +1,85 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.0.truncateToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.truncateToDouble());
Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).truncateToDouble());
Expect.equals(0.0, (1.18e-38).truncateToDouble());
Expect.equals(0.0, (1.18e-38 * 2).truncateToDouble());
Expect.equals(0.0, 0.49999999999999994.truncateToDouble());
Expect.equals(0.0, 0.5.truncateToDouble());
Expect.equals(0.0, 0.9999999999999999.truncateToDouble());
Expect.equals(1.0, 1.0.truncateToDouble());
Expect.equals(1.0, 1.000000000000001.truncateToDouble());
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
Expect.equals(4503599627370496.0, 4503599627370496.0.truncateToDouble());
Expect.equals(4503599627370497.0, 4503599627370497.0.truncateToDouble());
Expect.equals(4503599627370498.0, 4503599627370498.0.truncateToDouble());
Expect.equals(4503599627370499.0, 4503599627370499.0.truncateToDouble());
Expect.equals(9007199254740991.0, 9007199254740991.0.truncateToDouble());
Expect.equals(9007199254740992.0, 9007199254740992.0.truncateToDouble());
Expect.equals(double.MAX_FINITE, double.MAX_FINITE.truncateToDouble());
Expect.equals(0.0, (-double.MIN_POSITIVE).truncateToDouble());
Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).truncateToDouble());
Expect.equals(0.0, (-1.18e-38).truncateToDouble());
Expect.equals(0.0, (-1.18e-38 * 2).truncateToDouble());
Expect.equals(0.0, (-0.49999999999999994).truncateToDouble());
Expect.equals(0.0, (-0.5).truncateToDouble());
Expect.equals(0.0, (-0.9999999999999999).truncateToDouble());
Expect.equals(-1.0, (-1.0).truncateToDouble());
Expect.equals(-1.0, (-1.000000000000001).truncateToDouble());
Expect.equals(-4503599627370496.0, (-4503599627370496.0).truncateToDouble());
Expect.equals(-4503599627370497.0, (-4503599627370497.0).truncateToDouble());
Expect.equals(-4503599627370498.0, (-4503599627370498.0).truncateToDouble());
Expect.equals(-4503599627370499.0, (-4503599627370499.0).truncateToDouble());
Expect.equals(-9007199254740991.0, (-9007199254740991.0).truncateToDouble());
Expect.equals(-9007199254740992.0, (-9007199254740992.0).truncateToDouble());
Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).truncateToDouble());
Expect.equals(double.INFINITY, double.INFINITY.truncateToDouble());
Expect.equals(
double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.truncateToDouble());
Expect.isTrue(double.NAN.truncateToDouble().isNaN);
Expect.isTrue(0.0.truncateToDouble() is double);
Expect.isTrue(double.MIN_POSITIVE.truncateToDouble() is double);
Expect.isTrue((2.0 * double.MIN_POSITIVE).truncateToDouble() is double);
Expect.isTrue((1.18e-38).truncateToDouble() is double);
Expect.isTrue((1.18e-38 * 2).truncateToDouble() is double);
Expect.isTrue(0.49999999999999994.truncateToDouble() is double);
Expect.isTrue(0.5.truncateToDouble() is double);
Expect.isTrue(0.9999999999999999.truncateToDouble() is double);
Expect.isTrue(1.0.truncateToDouble() is double);
Expect.isTrue(1.000000000000001.truncateToDouble() is double);
Expect.isTrue(4503599627370496.0.truncateToDouble() is double);
Expect.isTrue(4503599627370497.0.truncateToDouble() is double);
Expect.isTrue(4503599627370498.0.truncateToDouble() is double);
Expect.isTrue(4503599627370499.0.truncateToDouble() is double);
Expect.isTrue(9007199254740991.0.truncateToDouble() is double);
Expect.isTrue(9007199254740992.0.truncateToDouble() is double);
Expect.isTrue(double.MAX_FINITE.truncateToDouble() is double);
Expect.isTrue((-double.MIN_POSITIVE).truncateToDouble() is double);
Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncateToDouble() is double);
Expect.isTrue((-1.18e-38).truncateToDouble() is double);
Expect.isTrue((-1.18e-38 * 2).truncateToDouble() is double);
Expect.isTrue((-0.49999999999999994).truncateToDouble() is double);
Expect.isTrue((-0.5).truncateToDouble() is double);
Expect.isTrue((-0.9999999999999999).truncateToDouble() is double);
Expect.isTrue((-1.0).truncateToDouble() is double);
Expect.isTrue((-1.000000000000001).truncateToDouble() is double);
Expect.isTrue((-4503599627370496.0).truncateToDouble() is double);
Expect.isTrue((-4503599627370497.0).truncateToDouble() is double);
Expect.isTrue((-4503599627370498.0).truncateToDouble() is double);
Expect.isTrue((-4503599627370499.0).truncateToDouble() is double);
Expect.isTrue((-9007199254740991.0).truncateToDouble() is double);
Expect.isTrue((-9007199254740992.0).truncateToDouble() is double);
Expect.isTrue((-double.MAX_FINITE).truncateToDouble() is double);
}

View file

@ -0,0 +1,27 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
// If the duration class multiplies "str" * microseconds-per-day (instead of
// (microseconds-per-day * "str") it will try to build up a huge string and
// terminate with an out-of-memory exception instead of an ArgumentError or
// TypeError.
// See dartbug.com/22309
String longString = "str" * 1000;
Expect.throws(() => new Duration(days: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
Expect.throws(() => new Duration(hours: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
Expect.throws(() => new Duration(minutes: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
Expect.throws(() => new Duration(seconds: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
Expect.throws(() => new Duration(milliseconds: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
Expect.throws(() => new Duration(microseconds: longString),
(e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError);
}

View file

@ -0,0 +1,21 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import 'dart:math';
main() {
Duration d, d1;
d1 = new Duration(microseconds: pow(2, 53));
d = d1 * 2;
Expect.equals(pow(2, 54), d.inMicroseconds);
d = d1 * 1.5;
Expect.equals(pow(2, 53).toDouble() * 1.5, d.inMicroseconds);
Expect.isTrue(d.inMicroseconds is int);
// Test that we lose precision when multiplying with a double.
d = new Duration(microseconds: pow(2, 53) + 1) * 1.0;
Expect.equals(0, d.inMicroseconds % 2);
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
Duration d, d1;
d1 = new Duration(milliseconds: 1);
d = d1 * 0.005;
Expect.equals(1000 * 0.005, d.inMicroseconds);
d = d1 * 0.0;
Expect.equals(0, d.inMicroseconds);
d = d1 * -0.005;
Expect.equals(1000 * -0.005, d.inMicroseconds);
d = d1 * 0.0015;
Expect.equals((1000 * 0.0015).round(), d.inMicroseconds);
}

View file

@ -0,0 +1,293 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
Duration d;
d = new Duration(days: 1);
Expect.equals(86400000000, d.inMicroseconds);
Expect.equals(86400000, d.inMilliseconds);
Expect.equals(86400, d.inSeconds);
Expect.equals(1440, d.inMinutes);
Expect.equals(24, d.inHours);
Expect.equals(1, d.inDays);
d = const Duration(hours: 1);
Expect.equals(3600000000, d.inMicroseconds);
Expect.equals(3600000, d.inMilliseconds);
Expect.equals(3600, d.inSeconds);
Expect.equals(60, d.inMinutes);
Expect.equals(1, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(minutes: 1);
Expect.equals(60000000, d.inMicroseconds);
Expect.equals(60000, d.inMilliseconds);
Expect.equals(60, d.inSeconds);
Expect.equals(1, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = const Duration(seconds: 1);
Expect.equals(1000000, d.inMicroseconds);
Expect.equals(1000, d.inMilliseconds);
Expect.equals(1, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(milliseconds: 1);
Expect.equals(1000, d.inMicroseconds);
Expect.equals(1, d.inMilliseconds);
Expect.equals(0, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(microseconds: 1);
Expect.equals(1, d.inMicroseconds);
Expect.equals(0, d.inMilliseconds);
Expect.equals(0, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = const Duration(milliseconds: 1, microseconds: 999);
Expect.equals(1999, d.inMicroseconds);
Expect.equals(1, d.inMilliseconds);
d = const Duration(seconds: 1, milliseconds: 999);
Expect.equals(1999, d.inMilliseconds);
Expect.equals(1, d.inSeconds);
d = new Duration(minutes: 1, seconds: 59);
Expect.equals(119, d.inSeconds);
Expect.equals(1, d.inMinutes);
d = const Duration(hours: 1, minutes: 59);
Expect.equals(119, d.inMinutes);
Expect.equals(1, d.inHours);
d = new Duration(days: 1, hours: 23);
Expect.equals(47, d.inHours);
Expect.equals(1, d.inDays);
d = const Duration(
days: 0,
hours: 23,
minutes: 59,
seconds: 59,
milliseconds: 999,
microseconds: 999);
Expect.equals(0, d.inDays);
d = new Duration(days: -1);
Expect.equals(-86400000000, d.inMicroseconds);
Expect.equals(-86400000, d.inMilliseconds);
Expect.equals(-86400, d.inSeconds);
Expect.equals(-1440, d.inMinutes);
Expect.equals(-24, d.inHours);
Expect.equals(-1, d.inDays);
d = const Duration(hours: -1);
Expect.equals(-3600000000, d.inMicroseconds);
Expect.equals(-3600000, d.inMilliseconds);
Expect.equals(-3600, d.inSeconds);
Expect.equals(-60, d.inMinutes);
Expect.equals(-1, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(minutes: -1);
Expect.equals(-60000000, d.inMicroseconds);
Expect.equals(-60000, d.inMilliseconds);
Expect.equals(-60, d.inSeconds);
Expect.equals(-1, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = const Duration(seconds: -1);
Expect.equals(-1000000, d.inMicroseconds);
Expect.equals(-1000, d.inMilliseconds);
Expect.equals(-1, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(milliseconds: -1);
Expect.equals(-1000, d.inMicroseconds);
Expect.equals(-1, d.inMilliseconds);
Expect.equals(0, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = new Duration(microseconds: -1);
Expect.equals(-1, d.inMicroseconds);
Expect.equals(0, d.inMilliseconds);
Expect.equals(0, d.inSeconds);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inDays);
d = const Duration(days: 1, hours: -24);
Expect.equals(0, d.inMicroseconds);
d = new Duration(hours: 1, minutes: -60);
Expect.equals(0, d.inMicroseconds);
d = const Duration(minutes: 1, seconds: -60);
Expect.equals(0, d.inMicroseconds);
d = new Duration(seconds: 1, milliseconds: -1000);
Expect.equals(0, d.inMicroseconds);
d = new Duration(milliseconds: 1, microseconds: -1000);
Expect.equals(0, d.inMicroseconds);
d = const Duration(hours: 25);
Expect.equals(1, d.inDays);
Expect.equals(25, d.inHours);
Expect.equals(1500, d.inMinutes);
Expect.equals(90000, d.inSeconds);
Expect.equals(90000000, d.inMilliseconds);
Expect.equals(90000000000, d.inMicroseconds);
d = new Duration(minutes: 61);
Expect.equals(0, d.inDays);
Expect.equals(1, d.inHours);
Expect.equals(61, d.inMinutes);
Expect.equals(3660, d.inSeconds);
Expect.equals(3660000, d.inMilliseconds);
Expect.equals(3660000000, d.inMicroseconds);
d = const Duration(seconds: 61);
Expect.equals(0, d.inDays);
Expect.equals(0, d.inHours);
Expect.equals(1, d.inMinutes);
Expect.equals(61, d.inSeconds);
Expect.equals(61000, d.inMilliseconds);
Expect.equals(61000000, d.inMicroseconds);
d = new Duration(milliseconds: 1001);
Expect.equals(0, d.inDays);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inMinutes);
Expect.equals(1, d.inSeconds);
Expect.equals(1001, d.inMilliseconds);
Expect.equals(1001000, d.inMicroseconds);
d = new Duration(microseconds: 1001);
Expect.equals(0, d.inDays);
Expect.equals(0, d.inHours);
Expect.equals(0, d.inMinutes);
Expect.equals(0, d.inSeconds);
Expect.equals(1, d.inMilliseconds);
Expect.equals(1001, d.inMicroseconds);
var d1 = const Duration(milliseconds: 1000);
var d2 = const Duration(seconds: 1);
Expect.identical(d1, d2);
d1 = const Duration(microseconds: 1000);
d2 = const Duration(milliseconds: 1);
Expect.identical(d1, d2);
d1 = new Duration(hours: 1);
d2 = new Duration(hours: -1);
d = d1 + d2;
Expect.equals(0, d.inMicroseconds);
d = d1 - d2;
Expect.equals(3600000000 * 2, d.inMicroseconds);
d2 = new Duration(hours: 1);
d = d1 + d2;
Expect.equals(3600000000 * 2, d.inMicroseconds);
d = d1 - d2;
Expect.equals(0, d.inMicroseconds);
d = d1 * 2;
Expect.equals(3600000000 * 2, d.inMicroseconds);
d = d1 * -1;
Expect.equals(-3600000000, d.inMicroseconds);
d = d1 * 0;
Expect.equals(0, d.inMicroseconds);
d = d1 ~/ 2;
Expect.equals(1800000000, d.inMicroseconds);
d = d1 ~/ 3600000001;
Expect.equals(0, d.inMicroseconds);
d = d1 ~/ -3600000001;
Expect.equals(0, d.inMicroseconds);
d = d1 ~/ 3599999999;
Expect.equals(1, d.inMicroseconds);
d = d1 ~/ -3599999999;
Expect.equals(-1, d.inMicroseconds);
d = d1 ~/ -1;
Expect.equals(-3600000000, d.inMicroseconds);
d = d1 * 0;
Expect.equals(0, d.inMicroseconds);
Expect.throws(() => d1 ~/ 0, (e) => e is IntegerDivisionByZeroException);
d = new Duration(microseconds: 0);
Expect.isTrue(d < new Duration(microseconds: 1));
Expect.isTrue(d <= new Duration(microseconds: 1));
Expect.isTrue(d <= d);
Expect.isTrue(d > new Duration(microseconds: -1));
Expect.isTrue(d >= new Duration(microseconds: -1));
Expect.isTrue(d >= d);
d = const Duration(
days: 1,
hours: 3,
minutes: 17,
seconds: 42,
milliseconds: 823,
microseconds: 127);
Expect.equals("27:17:42.823127", d.toString());
d = const Duration(hours: 1999, minutes: 17, seconds: 42);
Expect.equals("1999:17:42.000000", d.toString());
d = const Duration(
days: -1,
hours: -3,
minutes: -17,
seconds: -42,
milliseconds: -823,
microseconds: -127);
Expect.equals("-27:17:42.823127", d.toString());
d = const Duration(hours: -1999, minutes: -17, seconds: -42);
Expect.equals("-1999:17:42.000000", d.toString());
// Edge conditions for toString of microseconds.
// Regression test for http://dartbug.com/15678
d = const Duration(microseconds: 1);
Expect.equals("0:00:00.000001", d.toString());
d = const Duration(microseconds: 9);
Expect.equals("0:00:00.000009", d.toString());
d = const Duration(microseconds: 10);
Expect.equals("0:00:00.000010", d.toString());
d = const Duration(microseconds: 99);
Expect.equals("0:00:00.000099", d.toString());
d = const Duration(microseconds: 100);
Expect.equals("0:00:00.000100", d.toString());
d = const Duration(microseconds: 999);
Expect.equals("0:00:00.000999", d.toString());
d = const Duration(microseconds: 1000);
Expect.equals("0:00:00.001000", d.toString());
d = const Duration(microseconds: 9999);
Expect.equals("0:00:00.009999", d.toString());
d = const Duration(microseconds: 10000);
Expect.equals("0:00:00.010000", d.toString());
d = const Duration(microseconds: 99999);
Expect.equals("0:00:00.099999", d.toString());
d = const Duration(microseconds: 100000);
Expect.equals("0:00:00.100000", d.toString());
d = const Duration(microseconds: 999999);
Expect.equals("0:00:00.999999", d.toString());
d = const Duration(microseconds: 1000000);
Expect.equals("0:00:01.000000", d.toString());
d1 = const Duration(hours: 1);
d2 = const Duration(hours: -1);
Expect.isFalse(d1.isNegative);
Expect.isTrue(d2.isNegative);
Expect.equals(d1, d1.abs());
Expect.equals(d1, d2.abs());
Expect.equals(d2, -d1);
Expect.equals(d1, -d2);
}

View file

@ -0,0 +1,40 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
static Aa() => Ab();
static Ab() => Ac();
static Ac() => throw "abc";
}
class B {
static Ba() => Bb();
static Bb() => Bc();
static Bc() {
try {
A.Aa();
} catch (e) {
// This should produce a NoSuchMethodError.
var trace = e.stackTrace;
}
}
}
main() {
bool hasThrown = false;
try {
B.Ba();
} catch (e) {
hasThrown = true;
var trace = e.stackTrace.toString();
print(trace);
Expect.isTrue(trace.contains("Bc"));
Expect.isTrue(trace.contains("Bb"));
Expect.isTrue(trace.contains("Ba"));
Expect.isTrue(trace.contains("main"));
}
Expect.isTrue(hasThrown);
}

View file

@ -0,0 +1,29 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class A {
get foo => cyclicStatic;
}
var a = new A();
var cyclicStatic = (() => a.foo + 1)();
cyclicInitialization() {
return cyclicStatic;
}
main() {
bool hasThrown = false;
try {
cyclicStatic + 1;
} catch (e2) {
var e = e2;
hasThrown = true;
Expect.isTrue(
e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace");
}
Expect.isTrue(hasThrown);
}

View file

@ -0,0 +1,83 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void argument() {
throw new ArgumentError(499);
}
void noSuchMethod() {
(499).doesNotExist();
}
void nullThrown() {
throw null;
}
void range() {
throw new RangeError.range(0, 1, 2);
}
void fallThrough() {
nested() {}
switch (5) {
case 5:
nested();
default:
Expect.fail("Should not reach");
}
}
abstract class A {
foo();
}
void abstractClassInstantiation() {
new A();
}
void unsupported() {
throw new UnsupportedError("unsupported");
}
void unimplemented() {
throw new UnimplementedError("unimplemented");
}
void state() {
return [1, 2].single;
}
void type() {
return 1 + "string";
}
main() {
List<Function> errorFunctions = [
argument,
noSuchMethod,
nullThrown,
range,
fallThrough,
abstractClassInstantiation,
unsupported,
unimplemented,
state,
type
];
for (var f in errorFunctions) {
bool hasThrown = false;
try {
f();
} catch (e) {
hasThrown = true;
Expect.isTrue(
e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace");
}
Expect.isTrue(hasThrown);
}
}

View file

@ -0,0 +1,77 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test that error constructors do what they are documented as doing.
main() {
Expect.equals("Invalid argument(s)", new ArgumentError().toString());
Expect.equals(
"Invalid argument(s): message", new ArgumentError("message").toString());
Expect.equals(
"Invalid argument: null", new ArgumentError.value(null).toString());
Expect.equals("Invalid argument: 42", new ArgumentError.value(42).toString());
Expect.equals(
"Invalid argument: \"bad\"", new ArgumentError.value("bad").toString());
Expect.equals("Invalid argument (foo): null",
new ArgumentError.value(null, "foo").toString());
Expect.equals("Invalid argument (foo): 42",
new ArgumentError.value(42, "foo").toString());
Expect.equals("Invalid argument (foo): message: 42",
new ArgumentError.value(42, "foo", "message").toString());
Expect.equals("Invalid argument: message: 42",
new ArgumentError.value(42, null, "message").toString());
Expect.equals("Invalid argument(s): Must not be null",
new ArgumentError.notNull().toString());
Expect.equals("Invalid argument(s) (foo): Must not be null",
new ArgumentError.notNull("foo").toString());
Expect.equals("RangeError", new RangeError(null).toString());
Expect.equals("RangeError: message", new RangeError("message").toString());
Expect.equals("RangeError: Value not in range: 42",
new RangeError.value(42).toString());
Expect.equals("RangeError (foo): Value not in range: 42",
new RangeError.value(42, "foo").toString());
Expect.equals("RangeError (foo): message: 42",
new RangeError.value(42, "foo", "message").toString());
Expect.equals("RangeError: message: 42",
new RangeError.value(42, null, "message").toString());
Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42",
new RangeError.range(42, 2, 9).toString());
Expect.equals(
"RangeError (foo): Invalid value: Not in range 2..9, "
"inclusive: 42",
new RangeError.range(42, 2, 9, "foo").toString());
Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42",
new RangeError.range(42, 2, 9, "foo", "message").toString());
Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42",
new RangeError.range(42, 2, 9, null, "message").toString());
Expect.equals(
"RangeError: Index out of range: "
"index should be less than 3: 42",
new RangeError.index(42, [1, 2, 3]).toString());
Expect.equals(
"RangeError (foo): Index out of range: "
"index should be less than 3: 42",
new RangeError.index(42, [1, 2, 3], "foo").toString());
Expect.equals(
"RangeError (foo): message: "
"index should be less than 3: 42",
new RangeError.index(42, [1, 2, 3], "foo", "message").toString());
Expect.equals(
"RangeError: message: "
"index should be less than 3: 42",
new RangeError.index(42, [1, 2, 3], null, "message").toString());
Expect.equals(
"RangeError (foo): message: "
"index should be less than 2: 42",
new RangeError.index(42, [1, 2, 3], "foo", "message", 2).toString());
Expect.equals(
"RangeError: Index out of range: "
"index must not be negative: -5",
new RangeError.index(-5, [1, 2, 3]).toString());
}

View file

@ -0,0 +1,18 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library exception_implementation_test;
import "package:expect/expect.dart";
main() {
final msg = 1;
try {
throw new Exception(msg);
Expect.fail("Unreachable");
} on Exception catch (e) {
Expect.isTrue(e is Exception);
Expect.equals("Exception: $msg", e.toString());
}
}

View file

@ -0,0 +1,116 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class ExpandoTest {
static Expando<int> visits;
static testMain() {
visits = new Expando<int>('visits');
var legal = [
new Object(),
new List(),
[1, 2, 3],
const [1, 2, 3],
new Map(),
{'x': 1, 'y': 2},
const {'x': 1, 'y': 2},
new Expando(),
new Expando('horse')
];
for (var object in legal) {
testNamedExpando(object);
testUnnamedExpando(object);
}
for (var object in legal) {
Expect.equals(2, visits[object], "$object");
}
testIllegal();
testIdentity();
}
static visit(object) {
int count = visits[object];
count = (count == null) ? 1 : count + 1;
visits[object] = count;
}
static testNamedExpando(object) {
Expando<int> expando = new Expando<int>('myexpando');
Expect.equals('myexpando', expando.name);
Expect.isTrue(expando.toString().startsWith('Expando:myexpando'));
testExpando(expando, object);
}
static testUnnamedExpando(object) {
Expando<int> expando = new Expando<int>();
Expect.isNull(expando.name);
Expect.isTrue(expando.toString().startsWith('Expando:'));
testExpando(expando, object);
}
static testExpando(Expando<int> expando, object) {
visit(object);
Expect.isNull(expando[object]);
expando[object] = 42;
Expect.equals(42, expando[object]);
expando[object] = null;
Expect.isNull(expando[object]);
Expando<int> alternative = new Expando('myexpando');
Expect.isNull(alternative[object]);
alternative[object] = 87;
Expect.isNull(expando[object]);
expando[object] = 99;
Expect.equals(99, expando[object]);
Expect.equals(87, alternative[object]);
}
static testIllegal() {
Expando<int> expando = new Expando<int>();
Expect.throws(
() => expando[null], (exception) => exception is ArgumentError, "null");
Expect.throws(() => expando['string'],
(exception) => exception is ArgumentError, "'string'");
Expect.throws(() => expando['string'],
(exception) => exception is ArgumentError, "'string'");
Expect.throws(
() => expando[42], (exception) => exception is ArgumentError, "42");
Expect.throws(() => expando[42.87],
(exception) => exception is ArgumentError, "42.87");
Expect.throws(
() => expando[true], (exception) => exception is ArgumentError, "true");
Expect.throws(() => expando[false],
(exception) => exception is ArgumentError, "false");
}
static testIdentity() {
// Expando only depends on identity of object.
Expando<int> expando = new Expando<int>();
var m1 = new Mutable(1);
var m2 = new Mutable(7);
var m3 = new Mutable(13);
expando[m1] = 42;
Expect.equals(42, expando[m1]);
m1.id = 37;
Expect.equals(42, expando[m1]);
expando[m2] = 37;
expando[m3] = 10;
m3.id = 1;
Expect.equals(42, expando[m1]);
Expect.equals(37, expando[m2]);
Expect.equals(10, expando[m3]);
}
}
main() => ExpandoTest.testMain();
class Mutable {
int id;
Mutable(this.id);
int get hashCode => id;
bool operator ==(other) => other is Mutable && other.id == id;
}

View file

@ -0,0 +1,117 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Tests basic expressions. Does not attempt to validate the details of arithmetic, coercion, and
// so forth.
class ExpressionTest {
ExpressionTest() {}
int foo;
static testMain() {
var test = new ExpressionTest();
test.testBinary();
test.testUnary();
test.testShifts();
test.testBitwise();
test.testIncrement();
test.testMangling();
}
testBinary() {
int x = 4, y = 2;
Expect.equals(6, x + y);
Expect.equals(2, x - y);
Expect.equals(8, x * y);
Expect.equals(2, x / y);
Expect.equals(0, x % y);
}
testUnary() {
int x = 4, y = 2, z = -5;
bool t = true, f = false;
Expect.equals(-4, -x);
Expect.equals(4, ~z);
Expect.equals(f, !t);
}
testShifts() {
int x = 4, y = 2;
Expect.equals(y, x >> 1);
Expect.equals(x, y << 1);
}
testBitwise() {
int x = 4, y = 2;
Expect.equals(6, (x | y));
Expect.equals(0, (x & y));
Expect.equals(6, (x ^ y));
}
operator [](int index) {
return foo;
}
operator []=(int index, int value) {
foo = value;
}
testIncrement() {
int x = 4, a = x++;
Expect.equals(4, a);
Expect.equals(5, x);
Expect.equals(6, ++x);
Expect.equals(6, x++);
Expect.equals(7, x);
Expect.equals(6, --x);
Expect.equals(6, x--);
Expect.equals(5, x);
this.foo = 0;
Expect.equals(0, this.foo++);
Expect.equals(1, this.foo);
Expect.equals(2, ++this.foo);
Expect.equals(2, this.foo);
Expect.equals(2, this.foo--);
Expect.equals(1, this.foo);
Expect.equals(0, --this.foo);
Expect.equals(0, this.foo);
Expect.equals(0, this[0]++);
Expect.equals(1, this[0]);
Expect.equals(2, ++this[0]);
Expect.equals(2, this[0]);
Expect.equals(2, this[0]--);
Expect.equals(1, this[0]);
Expect.equals(0, --this[0]);
Expect.equals(0, this[0]);
int $0 = 42, $1 = 87, $2 = 117;
Expect.equals(42, $0++);
Expect.equals(43, $0);
Expect.equals(44, ++$0);
Expect.equals(88, $0 += $0);
Expect.equals(87, $1++);
Expect.equals(88, $1);
Expect.equals(89, ++$1);
Expect.equals(178, ($1 += $1));
Expect.equals(117, $2++);
Expect.equals(118, $2);
Expect.equals(119, ++$2);
}
void testMangling() {
int $0 = 42, $1 = 87, $2 = 117;
this[0] = 0;
Expect.equals(42, (this[0] += $0));
Expect.equals(129, (this[0] += $1));
Expect.equals(246, (this[0] += $2));
}
}
main() {
ExpressionTest.testMain();
}

View file

@ -0,0 +1,96 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class ForInTest {
static testMain() {
testSimple();
testBreak();
testContinue();
testClosure();
}
static Set<int> getSmallSet() {
Set<int> set = new Set<int>();
set.add(1);
set.add(2);
set.add(4);
return set;
}
static void testSimple() {
Set<int> set = getSmallSet();
int count = 0;
for (final i in set) {
count += i;
}
Expect.equals(7, count);
count = 0;
for (var i in set) {
count += i;
}
Expect.equals(7, count);
count = 0;
for (int i in set) {
count += i;
}
Expect.equals(7, count);
count = 0;
for (final int i in set) {
count += i;
}
Expect.equals(7, count);
count = 0;
int i = 0;
Expect.equals(false, set.contains(i)); // Used to test [i] after loop.
for (i in set) {
count += i;
}
Expect.equals(7, count);
Expect.equals(true, set.contains(i));
// The default implementation of [Set] preserves order.
Expect.equals(4, i);
}
static void testBreak() {
Set<int> set = getSmallSet();
int count = 0;
for (final i in set) {
if (i == 4) break;
count += i;
}
Expect.equals(true, count < 4);
}
static void testContinue() {
Set<int> set = getSmallSet();
int count = 0;
for (final i in set) {
if (i < 4) continue;
count += i;
}
Expect.equals(4, count);
}
static void testClosure() {
Set<int> set = getSmallSet();
List<Function> closures = new List(set.length);
int index = 0;
for (var i in set) {
closures[index++] = () => i;
}
Expect.equals(index, set.length);
Expect.equals(7, closures[0]() + closures[1]() + closures[2]());
}
}
main() {
ForInTest.testMain();
}

View file

@ -0,0 +1,108 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library format_exception_test;
import "package:expect/expect.dart";
test(exn, message, source, offset, toString) {
Expect.equals(message, exn.message);
Expect.equals(source, exn.source);
Expect.equals(offset, exn.offset);
Expect.equals(toString, exn.toString());
}
main() {
var e;
e = new FormatException();
test(e, "", null, null, "FormatException");
e = new FormatException("");
test(e, "", null, null, "FormatException");
e = new FormatException(null);
test(e, null, null, null, "FormatException");
e = new FormatException("message");
test(e, "message", null, null, "FormatException: message");
e = new FormatException("message", "source");
test(e, "message", "source", null, "FormatException: message\nsource");
e = new FormatException("message", "source" * 25);
test(e, "message", "source" * 25, null,
"FormatException: message\n" + "source" * 12 + "sou...");
e = new FormatException("message", "source" * 25);
test(e, "message", "source" * 25, null,
"FormatException: message\n" + "source" * 12 + "sou...");
e = new FormatException("message", "s1\nsource\ns2");
test(e, "message", "s1\nsource\ns2", null,
"FormatException: message\n" + "s1\nsource\ns2");
var o = new Object();
e = new FormatException("message", o, 10);
test(e, "message", o, 10, "FormatException: message (at offset 10)");
e = new FormatException("message", "source", 3);
test(e, "message", "source", 3,
"FormatException: message (at character 4)\nsource\n ^\n");
e = new FormatException("message", "s1\nsource\ns2", 6);
test(e, "message", "s1\nsource\ns2", 6,
"FormatException: message (at line 2, character 4)\nsource\n ^\n");
var longline = "watermelon cantaloupe " * 8 + "watermelon"; // Length > 160.
var longsource = (longline + "\n") * 25;
var line10 = (longline.length + 1) * 9;
e = new FormatException("message", longsource, line10);
test(
e,
"message",
longsource,
line10,
"FormatException: message (at line 10, character 1)\n"
"${longline.substring(0, 75)}...\n^\n");
e = new FormatException("message", longsource, line10 - 1);
test(
e,
"message",
longsource,
line10 - 1,
"FormatException: message (at line 9, "
"character ${longline.length + 1})\n"
"...${longline.substring(longline.length - 75)}\n"
"${' ' * 78}^\n");
var half = longline.length ~/ 2;
e = new FormatException("message", longsource, line10 + half);
test(
e,
"message",
longsource,
line10 + half,
"FormatException: message (at line 10, character ${half + 1})\n"
"...${longline.substring(half - 36, half + 36)}...\n"
"${' ' * 39}^\n");
var sourceNL = "\nsource with leading NL";
e = new FormatException("message", sourceNL, 2);
test(
e,
"message",
sourceNL,
2,
"FormatException: message (at line 2, character 2)\n"
"source with leading NL\n"
" ^\n");
var sourceNL2 = "\n\nsource with leading NL";
e = new FormatException("message", sourceNL2, 2);
test(
e,
"message",
sourceNL2,
2,
"FormatException: message (at line 3, character 1)\n"
"source with leading NL\n"
"^\n");
}

View file

@ -0,0 +1,43 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=-Da=true -Db=false -Dc=3 -Dd=STRING
import "package:expect/expect.dart";
class Foo {}
const
bool // //# 01: ok
int // //# 02: static type warning, checked mode compile-time error
String // //# 03: static type warning, checked mode compile-time error
Foo // //# 04: static type warning, checked mode compile-time error
a = const bool.fromEnvironment('a');
const
bool // //# 05: ok
int // //# 06: static type warning, checked mode compile-time error
String // //# 07: static type warning, checked mode compile-time error
Foo // //# 08: static type warning, checked mode compile-time error
b = const bool.fromEnvironment('b');
const
bool // //# 09: static type warning, checked mode compile-time error
int // //# 10: ok
String // //# 11: static type warning, checked mode compile-time error
Foo // //# 12: static type warning, checked mode compile-time error
c = const int.fromEnvironment('c');
const
bool // //# 13: static type warning, checked mode compile-time error
int // //# 14: static type warning, checked mode compile-time error
String // //# 15: ok
Foo // //# 16: static type warning, checked mode compile-time error
d = const String.fromEnvironment('d');
main() {
Expect.equals(a, true);
Expect.equals(b, false);
Expect.equals(c, 3);
Expect.equals(d, 'STRING');
}

View file

@ -0,0 +1,42 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class Foo {}
const
bool // //# 01: ok
int // //# 02: static type warning, checked mode compile-time error
String //# 03: static type warning, checked mode compile-time error
Foo // //# 04: static type warning, checked mode compile-time error
a = const bool.fromEnvironment('a');
const
bool // //# 05: ok
int // //# 06: static type warning, checked mode compile-time error
String //# 07: static type warning, checked mode compile-time error
Foo // //# 08: static type warning, checked mode compile-time error
b = const bool.fromEnvironment('b');
const
bool // //# 09: static type warning
int // //# 10: ok
String //# 11: static type warning
Foo // //# 12: static type warning
c = const int.fromEnvironment('c');
const
bool // //# 13: static type warning
int // //# 14: static type warning
String //# 15: ok
Foo // //# 16: static type warning
d = const String.fromEnvironment('d');
main() {
Expect.equals(a, false);
Expect.equals(b, false);
Expect.equals(c, null);
Expect.equals(d, null);
}

View file

@ -0,0 +1,187 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Sanity check on the growing behavior of a growable list.
import "package:expect/expect.dart";
void main() {
testConstructor();
bool checked = false;
assert((checked = true));
// Concurrent modification checks are only guaranteed in checked mode.
if (checked) testConcurrentModification();
}
// Iterable generating numbers in range [0..count).
// May perform callback at some point underways.
class TestIterableBase extends Iterable<int> {
final int length;
final int count;
// call [callback] if generating callbackIndex.
final int callbackIndex;
final Function callback;
TestIterableBase(this.length, this.count, this.callbackIndex, this.callback);
Iterator<int> get iterator => new CallbackIterator(this);
}
class TestIterable extends TestIterableBase {
TestIterable(count, [callbackIndex = -1, callback])
: super(-1, count, callbackIndex, callback);
int get length => throw "SHOULD NOT BE CALLED";
}
// Implement Set for private EfficientLengthIterable interface.
class EfficientTestIterable extends TestIterableBase implements Set<int> {
EfficientTestIterable(length, count, [callbackIndex = -1, callback])
: super(length, count, callbackIndex, callback);
// Avoid warnings because we don't actually implement Set.
noSuchMethod(i) => super.noSuchMethod(i);
}
class CallbackIterator implements Iterator<int> {
TestIterableBase _iterable;
int _current = null;
int _nextIndex = 0;
CallbackIterator(this._iterable);
bool moveNext() {
if (_nextIndex >= _iterable.count) {
_current = null;
return false;
}
_current = _nextIndex;
_nextIndex++;
if (_current == _iterable.callbackIndex) {
_iterable.callback();
}
return true;
}
int get current => _current;
}
void testConstructor() {
// Constructor can make both growable and fixed-length lists.
testGrowable(list) {
Expect.isTrue(list is List<int>);
Expect.isFalse(list is List<String>);
int length = list.length;
list.add(42);
Expect.equals(list.length, length + 1);
}
testFixedLength(list) {
Expect.isTrue(list is List<int>);
int length = list.length;
Expect.throws(() {
list.add(42);
}, null, "adding to fixed-length list");
Expect.equals(length, list.length);
}
bool checked = false;
assert((checked = true));
testThrowsOrTypeError(fn, test, [name]) {
Expect.throws(
fn, checked ? null : test, checked ? name : "$name w/ TypeError");
}
testFixedLength(new List<int>(0));
testFixedLength(new List<int>(5));
testFixedLength(new List<int>.filled(5, null)); // default growable: false.
testGrowable(new List<int>());
testGrowable(new List<int>()..length = 5);
testGrowable(new List<int>.filled(5, null, growable: true));
Expect.throws(() => new List<int>(-1), (e) => e is ArgumentError, "-1");
// There must be limits. Fix this test if we ever allow 10^30 elements.
Expect.throws(() => new List<int>(0x7fffffffffffffff),
(e) => e is ArgumentError, "bignum");
Expect.throws(() => new List<int>(null), (e) => e is ArgumentError, "null");
testThrowsOrTypeError(
() => new List([] as Object), // Cast to avoid warning.
(e) => e is ArgumentError,
'list');
testThrowsOrTypeError(
() => new List([42] as Object), (e) => e is ArgumentError, "list2");
}
void testConcurrentModification() {
// Without EfficientLengthIterable interface
{
// Change length of list after 200 additions.
var l = [];
var ci = new TestIterable(257, 200, () {
l.add("X");
});
Expect.throws(() {
l.addAll(ci);
}, (e) => e is ConcurrentModificationError, "cm1");
}
{
// Change length of list after 200 additions.
var l = [];
var ci = new TestIterable(257, 200, () {
l.length = 0;
});
Expect.throws(() {
l.addAll(ci);
}, (e) => e is ConcurrentModificationError, "cm2");
}
// With EfficientLengthIterable interface (uses length).
{
// Change length of list after 20 additions.
var l = [];
var ci = new EfficientTestIterable(257, 257, 20, () {
l.add("X");
});
Expect.throws(() {
l.addAll(ci);
}, (e) => e is ConcurrentModificationError, "cm3");
}
{
var l = [];
var ci = new EfficientTestIterable(257, 257, 20, () {
l.length = 0;
});
Expect.throws(() {
l.addAll(ci);
}, (e) => e is ConcurrentModificationError, "cm4");
}
{
// Length 500, only 250 elements.
var l = [];
var ci = new EfficientTestIterable(500, 250);
l.addAll(ci);
Expect.listEquals(new List.generate(250, (x) => x), l, "cm5");
}
{
// Length 250, but 500 elements.
var l = [];
var ci = new EfficientTestIterable(250, 500);
l.addAll(ci);
Expect.listEquals(new List.generate(500, (x) => x), l, "cm6");
}
{
// Adding to yourself.
var l = [1];
Expect.throws(() {
l.addAll(l);
}, (e) => e is ConcurrentModificationError, "cm7");
}
{
// Adding to yourself.
var l = [1, 2, 3];
Expect.throws(() {
l.addAll(l);
}, (e) => e is ConcurrentModificationError, "cm8");
}
}

View file

@ -0,0 +1,37 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library hasNextIterator.test;
import "package:expect/expect.dart";
import 'dart:collection';
main() {
var it = new HasNextIterator([].iterator);
Expect.isFalse(it.hasNext);
Expect.isFalse(it.hasNext);
Expect.throws(() => it.next(), (e) => e is StateError);
Expect.isFalse(it.hasNext);
it = new HasNextIterator([1].iterator);
Expect.isTrue(it.hasNext);
Expect.isTrue(it.hasNext);
Expect.equals(1, it.next());
Expect.isFalse(it.hasNext);
Expect.isFalse(it.hasNext);
Expect.throws(() => it.next(), (e) => e is StateError);
Expect.isFalse(it.hasNext);
it = new HasNextIterator([1, 2].iterator);
Expect.isTrue(it.hasNext);
Expect.isTrue(it.hasNext);
Expect.equals(1, it.next());
Expect.isTrue(it.hasNext);
Expect.isTrue(it.hasNext);
Expect.equals(2, it.next());
Expect.isFalse(it.hasNext);
Expect.isFalse(it.hasNext);
Expect.throws(() => it.next(), (e) => e is StateError);
Expect.isFalse(it.hasNext);
}

View file

@ -0,0 +1,308 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Tests of hash map behavior, with focus in iteration and concurrent
// modification errors.
library hash_map2_test;
import "package:expect/expect.dart";
import 'dart:collection';
testMap(Map newMap(), Map newMapFrom(Map map)) {
Map gen(int from, int to) {
Map map = new LinkedHashMap();
for (int i = from; i < to; i++) map[i] = i;
return map;
}
bool odd(int n) => (n & 1) == 1;
bool even(int n) => (n & 1) == 0;
void addAll(Map toMap, Map fromMap) {
fromMap.forEach((k, v) {
toMap[k] = v;
});
}
{
// Test growing to largish capacity.
Map map = newMap();
for (int i = 0; i < 256; i++) {
map[i] = i;
}
addAll(map, gen(256, 512));
addAll(map, newMapFrom(gen(512, 1000)));
Expect.equals(1000, map.length);
// Remove half.
for (int i = 0; i < 1000; i += 2) map.remove(i);
Expect.equals(500, map.length);
Expect.isFalse(map.keys.any(even));
Expect.isTrue(map.keys.every(odd));
// Re-add all.
addAll(map, gen(0, 1000));
Expect.equals(1000, map.length);
}
{
// Test having many deleted elements.
Map map = newMap();
map[0] = 0;
for (int i = 0; i < 1000; i++) {
map[i + 1] = i + 1;
map.remove(i);
Expect.equals(1, map.length);
}
}
{
// Test having many elements with same hashCode
Map map = newMap();
for (int i = 0; i < 1000; i++) {
map[new BadHashCode()] = 0;
}
Expect.equals(1000, map.length);
}
{
// Check concurrent modification
Map map = newMap()
..[0] = 0
..[1] = 1;
{
// Test adding before a moveNext.
Iterator iter = map.keys.iterator;
iter.moveNext();
map[1] = 9; // Updating existing key isn't a modification.
iter.moveNext();
map[2] = 2;
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test adding after last element.
Iterator iter = map.keys.iterator;
Expect.equals(3, map.length);
iter.moveNext();
iter.moveNext();
iter.moveNext();
map[3] = 3;
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test removing during iteration.
Iterator iter = map.keys.iterator;
iter.moveNext();
map.remove(1000); // Not a modification if it's not there.
iter.moveNext();
int n = iter.current;
map.remove(n);
// Removing doesn't change current.
Expect.equals(n, iter.current);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test removing after last element.
Iterator iter = map.keys.iterator;
Expect.equals(3, map.length);
iter.moveNext();
iter.moveNext();
iter.moveNext();
int n = iter.current;
map.remove(n);
// Removing doesn't change current.
Expect.equals(n, iter.current);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test that updating value of existing key doesn't cause concurrent
// modification error.
Iterator iter = map.keys.iterator;
Expect.equals(2, map.length);
iter.moveNext();
int n = iter.current;
map[n] = n * 2;
iter.moveNext();
Expect.equals(map[iter.current], iter.current);
}
{
// Test that modification during putIfAbsent is not an error.
map.putIfAbsent(4, () {
map[5] = 5;
map[4] = -1;
return 4;
});
Expect.equals(4, map[4]);
Expect.equals(5, map[5]);
}
{
// Check adding many existing keys isn't considered modification.
Map map2 = newMap();
for (var key in map.keys) {
map2[key] = map[key] + 1;
}
Iterator iter = map.keys.iterator;
addAll(map, map2);
// Shouldn't throw.
iter.moveNext();
}
}
{
// Regression test for bug in putIfAbsent where adding an element
// that make the table grow, can be lost.
Map map = newMap();
map.putIfAbsent("S", () => 0);
map.putIfAbsent("T", () => 0);
map.putIfAbsent("U", () => 0);
map.putIfAbsent("C", () => 0);
map.putIfAbsent("a", () => 0);
map.putIfAbsent("b", () => 0);
map.putIfAbsent("n", () => 0);
Expect.isTrue(map.containsKey("n"));
}
{
// Check that putIfAbsent works just as well as put.
Map map = newMap();
for (int i = 0; i < 128; i++) {
map.putIfAbsent(i, () => i);
Expect.isTrue(map.containsKey(i));
map.putIfAbsent(i >> 1, () => -1); // Never triggers.
}
for (int i = 0; i < 128; i++) {
Expect.equals(i, map[i]);
}
}
{
// Check that updating existing elements is not a modification.
// This must be the case even if the underlying data structure is
// nearly full.
for (int i = 1; i < 128; i++) {
// Create maps of different sizes, some of which should be
// at a limit of the underlying data structure.
Map map = newMapFrom(gen(0, i));
// ForEach-iteration.
map.forEach((key, v) {
Expect.equals(key, map[key]);
map[key] = key + 1;
map.remove(1000); // Removing something not there.
map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
// Doesn't cause ConcurrentModificationError.
});
// for-in iteration.
for (int key in map.keys) {
Expect.equals(key + 1, map[key]);
map[key] = map[key] + 1;
map.remove(1000); // Removing something not there.
map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
// Doesn't cause ConcurrentModificationError.
}
// Raw iterator.
Iterator iter = map.keys.iterator;
for (int key = 0; key < i; key++) {
Expect.equals(key + 2, map[key]);
map[key] = key + 3;
map.remove(1000); // Removing something not there.
map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
// Doesn't cause ConcurrentModificationError on the moveNext.
}
iter.moveNext(); // Should not throw.
// Remove a lot of elements, which can cause a re-tabulation.
for (int key = 1; key < i; key++) {
Expect.equals(key + 3, map[key]);
map.remove(key);
}
iter = map.keys.iterator;
map[0] = 2;
iter.moveNext(); // Should not throw.
}
}
{
// Check that null can be in the map.
Map map = newMap();
map[null] = 0;
Expect.equals(1, map.length);
Expect.isTrue(map.containsKey(null));
Expect.isNull(map.keys.first);
Expect.isNull(map.keys.last);
map[null] = 1;
Expect.equals(1, map.length);
Expect.isTrue(map.containsKey(null));
map.remove(null);
Expect.isTrue(map.isEmpty);
Expect.isFalse(map.containsKey(null));
// Created using map.from.
map = newMapFrom(new Map()..[null] = 0);
Expect.equals(1, map.length);
Expect.isTrue(map.containsKey(null));
Expect.isNull(map.keys.first);
Expect.isNull(map.keys.last);
map[null] = 1;
Expect.equals(1, map.length);
Expect.isTrue(map.containsKey(null));
map.remove(null);
Expect.isTrue(map.isEmpty);
Expect.isFalse(map.containsKey(null));
Map fromMap = new Map();
fromMap[1] = 0;
fromMap[2] = 0;
fromMap[3] = 0;
fromMap[null] = 0;
fromMap[4] = 0;
fromMap[5] = 0;
fromMap[6] = 0;
Expect.equals(7, fromMap.length);
// map that grows with null in it.
map = newMapFrom(fromMap);
Expect.equals(7, map.length);
for (int i = 7; i < 128; i++) {
map[i] = 0;
}
Expect.equals(128, map.length);
Expect.isTrue(map.containsKey(null));
map[null] = 1;
Expect.equals(128, map.length);
Expect.isTrue(map.containsKey(null));
map.remove(null);
Expect.equals(127, map.length);
Expect.isFalse(map.containsKey(null));
}
}
void main() {
Expect.isTrue(new HashMap<int, String>() is Map<int, String>);
Expect.isTrue(new LinkedHashMap<int, String>() is Map<int, String>);
Expect.isTrue(new HashMap<String, int>.from({}) is Map<String, int>);
Expect.isTrue(new LinkedHashMap<String, int>.from({}) is Map<String, int>);
Expect.isTrue(<String, int>{} is Map<String, int>);
Expect.isTrue(const <String, int>{} is Map<String, int>);
testMap(() => new HashMap(), (m) => new HashMap.from(m));
testMap(() => new LinkedHashMap(), (m) => new LinkedHashMap.from(m));
}
class BadHashCode {
static int idCounter = 0;
final int id;
BadHashCode() : id = idCounter++;
int get hashCode => 42;
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test program for the HashMap class.
class HashMapTest {
static testMain() {
var m = new Map();
Expect.equals(0, m.length);
Expect.equals(true, m.isEmpty);
m["one"] = 1;
Expect.equals(1, m.length);
Expect.equals(false, m.isEmpty);
Expect.equals(1, m["one"]);
}
}
main() {
HashMapTest.testMain();
}

View file

@ -0,0 +1,363 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// VMOptions=
// Tests of hash set behavior, with focus in iteration and concurrent
// modification errors.
library hash_map2_test;
import "package:expect/expect.dart";
import 'dart:collection';
import 'dart:math' as math;
testSet(Set newSet(), Set newSetFrom(Iterable from)) {
Set gen(int from, int to) =>
new Set.from(new Iterable.generate(to - from, (n) => n + from));
bool odd(int n) => (n & 1) == 1;
bool even(int n) => (n & 1) == 0;
{
// Test growing to largish capacity.
Set set = newSet();
for (int i = 0; i < 256; i++) {
set.add(i);
}
set.addAll(gen(256, 512));
set.addAll(newSetFrom(gen(512, 1000)));
Expect.equals(1000, set.length);
// Remove half.
for (int i = 0; i < 1000; i += 2) set.remove(i);
Expect.equals(500, set.length);
Expect.isFalse(set.any(even));
Expect.isTrue(set.every(odd));
// Re-add all.
set.addAll(gen(0, 1000));
Expect.equals(1000, set.length);
}
{
// Test having many deleted elements.
Set set = newSet();
set.add(0);
for (int i = 0; i < 1000; i++) {
set.add(i + 1);
set.remove(i);
Expect.equals(1, set.length);
}
}
{
// Test having many elements with same hashCode
Set set = newSet();
for (int i = 0; i < 1000; i++) {
set.add(new BadHashCode());
}
Expect.equals(1000, set.length);
}
{
// Check concurrent modification
Set set = newSet()..add(0)..add(1);
{
// Test adding before a moveNext.
Iterator iter = set.iterator;
iter.moveNext();
set.add(1); // Updating existing key isn't a modification.
iter.moveNext();
set.add(2);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test adding after last element.
Iterator iter = set.iterator;
Expect.equals(3, set.length);
iter.moveNext();
iter.moveNext();
iter.moveNext();
set.add(3);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test removing during iteration.
Iterator iter = set.iterator;
iter.moveNext();
set.remove(1000); // Not a modification if it's not there.
iter.moveNext();
int n = iter.current;
set.remove(n);
// Removing doesn't change current.
Expect.equals(n, iter.current);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test removing after last element.
Iterator iter = set.iterator;
Expect.equals(3, set.length);
iter.moveNext();
iter.moveNext();
iter.moveNext();
int n = iter.current;
set.remove(n);
// Removing doesn't change current.
Expect.equals(n, iter.current);
Expect.throws(iter.moveNext, (e) => e is Error);
}
{
// Test that updating value doesn't cause error.
Iterator iter = set.iterator;
Expect.equals(2, set.length);
iter.moveNext();
int n = iter.current;
set.add(n);
iter.moveNext();
Expect.isTrue(set.contains(iter.current));
}
{
// Check adding many existing values isn't considered modification.
Set set2 = newSet();
for (var value in set) {
set2.add(value);
}
Iterator iter = set.iterator;
set.addAll(set2);
// Shouldn't throw.
iter.moveNext();
}
}
{
// Check that updating existing elements is not a modification.
// This must be the case even if the underlying data structure is
// nearly full.
for (int i = 1; i < 128; i++) {
// Create maps of different sizes, some of which should be
// at a limit of the underlying data structure.
Set set = newSetFrom(gen(0, i));
Iterator iter = set.iterator;
for (int j = 0; j < i; j++) {
set.add(j);
}
iter.moveNext(); // Should not throw.
for (int j = 1; j < i; j++) {
set.remove(j);
}
iter = set.iterator;
set.add(0);
iter.moveNext(); // Should not throw.
}
}
{
// Check that null can be in the set.
Set set = newSet();
set.add(null);
Expect.equals(1, set.length);
Expect.isTrue(set.contains(null));
Expect.isNull(set.first);
Expect.isNull(set.last);
set.add(null);
Expect.equals(1, set.length);
Expect.isTrue(set.contains(null));
set.remove(null);
Expect.isTrue(set.isEmpty);
Expect.isFalse(set.contains(null));
// Created using Set.from.
set = newSetFrom([null]);
Expect.equals(1, set.length);
Expect.isTrue(set.contains(null));
Expect.isNull(set.first);
Expect.isNull(set.last);
set.add(null);
Expect.equals(1, set.length);
Expect.isTrue(set.contains(null));
set.remove(null);
Expect.isTrue(set.isEmpty);
Expect.isFalse(set.contains(null));
// Set that grows with null in it.
set = newSetFrom([1, 2, 3, null, 4, 5, 6]);
Expect.equals(7, set.length);
for (int i = 7; i < 128; i++) {
set.add(i);
}
Expect.equals(128, set.length);
Expect.isTrue(set.contains(null));
set.add(null);
Expect.equals(128, set.length);
Expect.isTrue(set.contains(null));
set.remove(null);
Expect.equals(127, set.length);
Expect.isFalse(set.contains(null));
}
{
// Check that addAll and clear works.
Set set = newSet();
set.addAll([]);
Expect.isTrue(set.isEmpty);
set.addAll([1, 3, 2]);
Expect.equals(3, set.length);
Expect.isTrue(set.contains(1));
Expect.isTrue(set.contains(3));
Expect.isTrue(set.contains(2));
Expect.isFalse(set.contains(4));
set.clear();
Expect.isTrue(set.isEmpty);
}
{
// Check that removeWhere and retainWhere work.
Set set = newSetFrom([1, 2, 3]);
set.removeWhere((each) => each == 2);
Expect.equals(2, set.length);
Expect.isTrue(set.contains(1));
Expect.isFalse(set.contains(2));
Expect.isTrue(set.contains(3));
set.retainWhere((each) => each == 3);
Expect.equals(1, set.length);
Expect.isFalse(set.contains(1));
Expect.isFalse(set.contains(2));
Expect.isTrue(set.contains(3));
}
{
// Test lookup
Set set = newSet();
var m1a = new Mutable(1);
var m1b = new Mutable(1);
var m2a = new Mutable(2);
var m2b = new Mutable(2);
Expect.isNull(set.lookup(m1a));
Expect.isNull(set.lookup(m1b));
set.add(m1a);
Expect.identical(m1a, set.lookup(m1a));
Expect.identical(m1a, set.lookup(m1b));
Expect.isNull(set.lookup(m2a));
Expect.isNull(set.lookup(m2b));
set.add(m2a);
Expect.identical(m2a, set.lookup(m2a));
Expect.identical(m2a, set.lookup(m2b));
set.add(m2b); // Adding doesn't change element.
Expect.identical(m2a, set.lookup(m2a));
Expect.identical(m2a, set.lookup(m2b));
set.remove(m1a);
set.add(m1b);
Expect.identical(m1b, set.lookup(m1a));
Expect.identical(m1b, set.lookup(m1b));
set.add(1);
Expect.identical(1, set.lookup(1.0));
set.add(-0.0);
Expect.identical(-0.0, set.lookup(0.0));
}
{
// Test special hash codes
Set set = newSet();
List keys = [];
// Powers of two
for (int i = 63; i >= 2; --i) {
keys.add(new Mutable(math.pow(2, i)));
}
for (var key in keys) {
Expect.isTrue(set.add(key));
}
for (var key in keys) {
Expect.isTrue(set.contains(key));
}
}
}
void testIdentitySet(Set create()) {
Set set = create();
set.add(1);
set.add(2);
set.add(1); // Integers are identical if equal.
Expect.equals(2, set.length);
var complex = 4;
complex = set.length == 2 ? complex ~/ 4 : 87; // Avoid compile-time constant.
Expect.isTrue(set.contains(complex)); // 1 is in set, even if computed.
set.clear();
// All compile time constants are identical to themselves.
var constants = [
double.INFINITY,
double.NAN, -0.0, //# 01: ok
0.0, 42, "", null, false, true, #bif, testIdentitySet
];
set.addAll(constants);
Expect.equals(constants.length, set.length);
for (var c in constants) {
Expect.isTrue(set.contains(c), "constant: $c");
}
Expect.isTrue(set.containsAll(constants), "constants: $set");
set.clear();
var m1 = new Mutable(1);
var m2 = new Mutable(2);
var m3 = new Mutable(3);
var m4 = new Mutable(2); // Equal to m2, but not identical.
set.addAll([m1, m2, m3, m4]);
Expect.equals(4, set.length);
Expect.equals(3, m3.hashCode);
m3.id = 1;
Expect.equals(1, m3.hashCode);
// Changing hashCode doesn't affect lookup.
Expect.isTrue(set.contains(m3));
Expect.isTrue(set.contains(m1));
set.remove(m3);
Expect.isFalse(set.contains(m3));
Expect.isTrue(set.contains(m1));
Expect.identical(m1, set.lookup(m1));
Expect.identical(null, set.lookup(m3));
}
void main() {
testSet(() => new Set(), (m) => new Set.from(m));
testSet(() => new HashSet(), (m) => new HashSet.from(m));
testSet(() => new LinkedHashSet(), (m) => new LinkedHashSet.from(m));
testIdentitySet(() => new Set.identity());
testIdentitySet(() => new HashSet.identity());
testIdentitySet(() => new LinkedHashSet.identity());
testIdentitySet(() => new HashSet(
equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
testIdentitySet(() => new LinkedHashSet(
equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
}
class BadHashCode {
static int idCounter = 0;
final int id;
BadHashCode() : id = idCounter++;
int get hashCode => 42;
// operator == is identity.
// Can't make a bad compareTo that isn't invalid.
int compareTo(BadHashCode other) => id - other.id;
}
class Mutable {
int id;
Mutable(this.id);
int get hashCode => id;
bool operator ==(other) => other is Mutable && id == other.id;
}

View file

@ -0,0 +1,47 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Tests of hash set type checking.
library hash_set_type_check_test;
import "package:expect/expect.dart";
import 'dart:collection';
testSet(Set<String> newSet()) {
Set<String> s = newSet();
Expect.throws(() => s.add(1), (e) => e is Error);
Expect.isNull(s.lookup(1));
}
void testIdentitySet(Set create()) {
Set<String> s = create();
Expect.throws(() => s.add(1), (e) => e is Error);
Expect.isNull(s.lookup(1));
}
bool get inCheckedMode {
try {
var i = 1;
String j = i;
} catch (_) {
return true;
}
return false;
}
void main() {
if (!inCheckedMode) return;
testSet(() => new Set<String>());
testSet(() => new HashSet<String>());
testSet(() => new LinkedHashSet<String>());
testIdentitySet(() => new Set<String>.identity());
testIdentitySet(() => new HashSet<String>.identity());
testIdentitySet(() => new LinkedHashSet<String>.identity());
testIdentitySet(() => new HashSet<String>(
equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
testIdentitySet(() => new LinkedHashSet<String>(
equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
}

View file

@ -0,0 +1,21 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
double fib(double n) {
return n <= 1.0 ? 1.0 : fib(n - 1) + fib(n - 2);
}
main() {
// Compute the same value in a way that won't be optimized away so the results
// are different objects in memory.
var a = fib(5.0) + 1.0;
var b = fib(4.0) + 4.0;
Expect.isTrue(identical(a, b));
Expect.equals(identityHashCode(a), identityHashCode(b));
Expect.equals(a, b);
Expect.equals(a.hashCode, b.hashCode);
}

View file

@ -0,0 +1,48 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
class Override {
int hash;
int get superHash => super.hashCode;
int get hashCode => hash;
int foo() => hash; // Just some function that can be closurized.
bool operator ==(Object other) =>
other is Override && (other as Override).hash == hash;
}
int bar() => 42; // Some global function.
main() {
var o = new Object();
var hash = o.hashCode;
// Doesn't change.
Expect.equals(hash, o.hashCode);
Expect.equals(hash, identityHashCode(o));
var c = new Override();
int identityHash = c.superHash;
hash = (identityHash == 42) ? 37 : 42;
c.hash = hash;
Expect.equals(hash, c.hashCode);
Expect.equals(identityHash, identityHashCode(c));
// These classes don't override hashCode.
var samples = [0, 0x10000000, 1.5, -0, null, true, false, const Object()];
for (var v in samples) {
print(v);
Expect.equals(v.hashCode, identityHashCode(v));
}
// These do, or might do, but we can still use hashCodeOf and get the same
// result each time.
samples = ["string", "", (x) => 42, c.foo, bar];
for (var v in samples) {
print(v);
Expect.equals(v.hashCode, v.hashCode);
Expect.equals(identityHashCode(v), identityHashCode(v));
}
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Test that the internal hidden library doesn't make problems with taking
// stack-traces.
main() {
print(['x'].where((_) {
// We actually don't really care for the successful case. We just want to
// make sure that the test doesn't crash when it is negative.
throw 'fisk'; // //# 01: runtime error
return true;
}).toList());
}

View file

@ -0,0 +1,50 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Check that indexed access to lists throws correct exception if index
// is not int.
main() {
checkList(new List(10));
var growable = new List();
growable.add(1);
growable.add(1);
checkList(growable);
}
checkList(var list) {
// Check unoptimized.
Expect.isFalse(checkCatch(getIt, list, 1));
Expect.isTrue(checkCatch(getIt, list, "hi"));
Expect.isFalse(checkCatch(putIt, list, 1));
Expect.isTrue(checkCatch(putIt, list, "hi"));
// Optimize 'getIt' and 'putIt'.
for (int i = 0; i < 2000; i++) {
putIt(list, 1);
getIt(list, 1);
}
Expect.isTrue(checkCatch(getIt, list, "hi"));
Expect.isTrue(checkCatch(putIt, list, "hi"));
}
checkCatch(var f, var list, var index) {
try {
f(list, index);
} on ArgumentError catch (e) {
return true;
} on TypeError catch (t) {
return true; // thrown in type checked mode.
}
return false;
}
getIt(var a, var i) {
return a[i];
}
putIt(var a, var i) {
a[i] = null;
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.ceil());
Expect.equals(1, 1.ceil());
Expect.equals(0x1234, 0x1234.ceil());
Expect.equals(0x12345678, 0x12345678.ceil());
Expect.equals(0x123456789AB, 0x123456789AB.ceil());
Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.ceil());
Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil());
Expect.equals(-1, -1.ceil());
Expect.equals(-0x1234, -0x1234.ceil());
Expect.equals(-0x12345678, -0x12345678.ceil());
Expect.equals(-0x123456789AB, -0x123456789AB.ceil());
Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.ceil());
Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil());
Expect.isTrue(0.ceil() is int);
Expect.isTrue(1.ceil() is int);
Expect.isTrue(0x1234.ceil() is int);
Expect.isTrue(0x12345678.ceil() is int);
Expect.isTrue(0x123456789AB.ceil() is int);
Expect.isTrue(0x123456789ABCDEF.ceil() is int);
Expect
.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil() is int);
Expect.isTrue(-1.ceil() is int);
Expect.isTrue(-0x1234.ceil() is int);
Expect.isTrue(-0x12345678.ceil() is int);
Expect.isTrue(-0x123456789AB.ceil() is int);
Expect.isTrue(-0x123456789ABCDEF.ceil() is int);
Expect
.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil() is int);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.ceilToDouble());
Expect.equals(1.0, 1.ceilToDouble());
Expect.equals(0x1234, 0x1234.ceilToDouble());
Expect.equals(0x12345678, 0x12345678.ceilToDouble());
Expect.equals(0x123456789AB, 0x123456789AB.ceilToDouble());
Expect.equals(81985529216486900.0, 0x123456789ABCDEF.ceilToDouble());
Expect.equals(2.7898229935051914e+55,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble());
Expect.equals(-1.0, -1.ceilToDouble());
Expect.equals(-0x1234, -0x1234.ceilToDouble());
Expect.equals(-0x12345678, -0x12345678.ceilToDouble());
Expect.equals(-0x123456789AB, -0x123456789AB.ceilToDouble());
Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.ceilToDouble());
Expect.equals(-2.7898229935051914e+55,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble());
Expect.isTrue(0.ceilToDouble() is double);
Expect.isTrue(1.ceilToDouble() is double);
Expect.isTrue(0x1234.ceilToDouble() is double);
Expect.isTrue(0x12345678.ceilToDouble() is double);
Expect.isTrue(0x123456789AB.ceilToDouble() is double);
Expect.isTrue(0x123456789ABCDEF.ceilToDouble() is double);
Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble()
is double);
Expect.isTrue(-1.ceilToDouble() is double);
Expect.isTrue(-0x1234.ceilToDouble() is double);
Expect.isTrue(-0x12345678.ceilToDouble() is double);
Expect.isTrue(-0x123456789AB.ceilToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF.ceilToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.ceilToDouble() is double);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.floor());
Expect.equals(1, 1.floor());
Expect.equals(0x1234, 0x1234.floor());
Expect.equals(0x12345678, 0x12345678.floor());
Expect.equals(0x123456789AB, 0x123456789AB.floor());
Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.floor());
Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor());
Expect.equals(-1, -1.floor());
Expect.equals(-0x1234, -0x1234.floor());
Expect.equals(-0x12345678, -0x12345678.floor());
Expect.equals(-0x123456789AB, -0x123456789AB.floor());
Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.floor());
Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor());
Expect.isTrue(0.floor() is int);
Expect.isTrue(1.floor() is int);
Expect.isTrue(0x1234.floor() is int);
Expect.isTrue(0x12345678.floor() is int);
Expect.isTrue(0x123456789AB.floor() is int);
Expect.isTrue(0x123456789ABCDEF.floor() is int);
Expect
.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor() is int);
Expect.isTrue(-1.floor() is int);
Expect.isTrue(-0x1234.floor() is int);
Expect.isTrue(-0x12345678.floor() is int);
Expect.isTrue(-0x123456789AB.floor() is int);
Expect.isTrue(-0x123456789ABCDEF.floor() is int);
Expect.isTrue(
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor() is int);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.floorToDouble());
Expect.equals(1.0, 1.floorToDouble());
Expect.equals(0x1234, 0x1234.floorToDouble());
Expect.equals(0x12345678, 0x12345678.floorToDouble());
Expect.equals(0x123456789AB, 0x123456789AB.floorToDouble());
Expect.equals(81985529216486900.0, 0x123456789ABCDEF.floorToDouble());
Expect.equals(2.7898229935051914e+55,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floorToDouble());
Expect.equals(-1.0, -1.floorToDouble());
Expect.equals(-0x1234, -0x1234.floorToDouble());
Expect.equals(-0x12345678, -0x12345678.floorToDouble());
Expect.equals(-0x123456789AB, -0x123456789AB.floorToDouble());
Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.floorToDouble());
Expect.equals(-2.7898229935051914e+55,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floorToDouble());
Expect.isTrue(0.floorToDouble() is double);
Expect.isTrue(1.floorToDouble() is double);
Expect.isTrue(0x1234.floorToDouble() is double);
Expect.isTrue(0x12345678.floorToDouble() is double);
Expect.isTrue(0x123456789AB.floorToDouble() is double);
Expect.isTrue(0x123456789ABCDEF.floorToDouble() is double);
Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.floorToDouble() is double);
Expect.isTrue(-1.floorToDouble() is double);
Expect.isTrue(-0x1234.floorToDouble() is double);
Expect.isTrue(-0x12345678.floorToDouble() is double);
Expect.isTrue(-0x123456789AB.floorToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF.floorToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.floorToDouble() is double);
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=-Da=x -Db=- -Dc=0xg -Dd=+ -Dd=
import "package:expect/expect.dart";
main() {
Expect.isNull(const int.fromEnvironment('a'));
Expect.isNull(const int.fromEnvironment('b'));
Expect.isNull(const int.fromEnvironment('c'));
Expect.isNull(const int.fromEnvironment('d'));
Expect.isNull(const int.fromEnvironment('e'));
}

View file

@ -0,0 +1,11 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
main() {
const int.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error
const int.fromEnvironment('NOT_FOUND', defaultValue: true); // //# 02: compile-time error
const int.fromEnvironment(null); // //# 03: compile-time error
const int.fromEnvironment(1); // //# 04: compile-time error
const int.fromEnvironment([]); // //# 05: compile-time error
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=-Da=1 -Db=-12 -Dc=0x123 -Dd=-0x1234 -De=+0x112296 -Df=99999999999999999999
import "package:expect/expect.dart";
main() {
Expect.equals(1, const int.fromEnvironment('a'));
Expect.equals(-12, const int.fromEnvironment('b'));
Expect.equals(0x123, const int.fromEnvironment('c'));
Expect.equals(-0x1234, const int.fromEnvironment('d'));
Expect.equals(0x112296, const int.fromEnvironment('e'));
Expect.equals(99999999999999999999, const int.fromEnvironment('f'));
}

View file

@ -0,0 +1,197 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import "dart:math" show pow;
var smallNumber = 1234567890; // is 31-bit integer.
var mediumNumber = 1234567890123456; // is 53-bit integer
var bigNumber = 590295810358705600000; // is > 64-bit integer, exact as double.
testModPow() {
test(x, e, m, expectedResult) {
// Check that expected result is correct, using an unoptimized version.
assert(() {
if (1 is double) return true; // Don't have bignums.
slowModPow(x, e, m) {
var r = 1;
while (e > 0) {
if (e.isOdd) r = (r * x) % m;
e >>= 1;
x = (x * x) % m;
}
return r;
}
return slowModPow(x, e, m) == expectedResult;
});
var result = x.modPow(e, m);
Expect.equals(expectedResult, result, "$x.modPow($e, $m)");
}
test(10, 20, 1, 0);
test(1234567890, 1000000001, 19, 11);
test(1234567890, 19, 1000000001, 122998977);
test(19, 1234567890, 1000000001, 619059596);
test(19, 1000000001, 1234567890, 84910879);
test(1000000001, 19, 1234567890, 872984351);
test(1000000001, 1234567890, 19, 0);
test(12345678901234567890, 10000000000000000001, 19, 2);
test(12345678901234567890, 19, 10000000000000000001, 3239137215315834625);
test(19, 12345678901234567890, 10000000000000000001, 4544207837373941034);
test(19, 10000000000000000001, 12345678901234567890, 11135411705397624859);
test(10000000000000000001, 19, 12345678901234567890, 2034013733189773841);
test(10000000000000000001, 12345678901234567890, 19, 1);
test(12345678901234567890, 19, 10000000000000000001, 3239137215315834625);
test(12345678901234567890, 10000000000000000001, 19, 2);
test(123456789012345678901234567890, 123456789012345678901234567891,
123456789012345678901234567899, 116401406051033429924651549616);
test(123456789012345678901234567890, 123456789012345678901234567899,
123456789012345678901234567891, 123456789012345678901234567890);
test(123456789012345678901234567899, 123456789012345678901234567890,
123456789012345678901234567891, 35088523091000351053091545070);
test(123456789012345678901234567899, 123456789012345678901234567891,
123456789012345678901234567890, 18310047270234132455316941949);
test(123456789012345678901234567891, 123456789012345678901234567899,
123456789012345678901234567890, 1);
test(123456789012345678901234567891, 123456789012345678901234567890,
123456789012345678901234567899, 40128068573873018143207285483);
}
testModInverse() {
test(x, m, expectedResult) {
//print("$x op $m == $expectedResult");
// Check that expectedResult is an inverse.
assert(expectedResult < m);
// The 1 % m handles the m = 1 special case.
// This test may overflow if we don't have bignums, so only run on VM.
assert(1 is double || (((x % m) * expectedResult) - 1) % m == 0);
var result = x.modInverse(m);
Expect.equals(expectedResult, result, "$x modinv $m");
if (x > m) {
x = x % m;
var result = x.modInverse(m);
Expect.equals(expectedResult, result, "$x modinv $m");
}
}
testThrows(x, m) {
// Throws if not co-prime, which is a symmetric property.
Expect.throws(() => x.modInverse(m), null, "$x modinv $m");
Expect.throws(() => m.modInverse(x), null, "$m modinv $x");
}
test(1, 1, 0);
testThrows(0, 1000000001);
testThrows(2, 4);
testThrows(99, 9);
testThrows(19, 1000000001);
testThrows(123456789012345678901234567890, 123456789012345678901234567899);
// Co-prime numbers
test(1234567890, 19, 11);
test(1234567890, 1000000001, 189108911);
test(19, 1234567890, 519818059);
test(1000000001, 1234567890, 1001100101);
test(12345, 12346, 12345);
test(12345, 12346, 12345);
test(smallNumber, 137, 42);
test(137, smallNumber, 856087223);
test(mediumNumber, 137, 77);
test(137, mediumNumber, 540686667207353);
test(bigNumber, 137, 128); // //# bignum: ok
// Bigger numbers as modulo is tested in big_integer_arith_vm_test.dart.
// Big doubles are not co-prime, so there is nothing to test for dart2js.
}
testGcd() {
// Call testFunc with all combinations and orders of plus/minus
// value and other.
callCombos(value, other, testFunc) {
testFunc(value, other);
testFunc(value, -other);
testFunc(-value, other);
testFunc(-value, -other);
if (value == other) return;
testFunc(other, value);
testFunc(other, -value);
testFunc(-other, value);
testFunc(-other, -value);
}
// Test that gcd of value and other (non-negative) is expectedResult.
// Tests all combinations of positive and negative values and order of
// operands, so use positive values and order is not important.
test(value, other, expectedResult) {
// Check for bug in test.
assert(expectedResult == 0 || value % expectedResult == 0);
assert(expectedResult == 0 || other % expectedResult == 0);
callCombos(value, other, (a, b) {
var result = a.gcd(b);
/// Check that the result is a divisor.
Expect.equals(0, result == 0 ? a : a % result, "$result | $a");
Expect.equals(0, result == 0 ? b : b % result, "$result | $b");
// Check for bug in test. If assert fails, the expected value is too low,
// and the gcd call has found a greater common divisor.
assert(result >= expectedResult);
Expect.equals(expectedResult, result, "$a.gcd($b)");
});
}
// Test that gcd of value and other (non-negative) throws.
testThrows(value, other) {
callCombos(value, other, (a, b) {
Expect.throws(() => a.gcd(b), null, "$a.gcd($b)");
});
}
testThrows(2.5, 5); // Not a method on double.
testThrows(5, 2.5); // Not accepting non-int arguments.
// Format:
// test(value1, value2, expectedResult);
test(1, 1, 1); // both are 1
test(1, 2, 1); // one is 1
test(3, 5, 1); // coprime.
test(37, 37, 37); // Same larger prime.
test(9999, 7272, 909); // Larger numbers
test(0, 1000, 1000); // One operand is zero.
test(0, 0, 0); // Both operands are zero.
// Multiplying both operands by a number multiplies result by same number.
test(693, 609, 21);
test(693 << 5, 609 << 5, 21 << 5);
test(693 * 937, 609 * 937, 21 * 937);
test(693 * pow(2, 32), 609 * pow(2, 32), 21 * pow(2, 32));
test(693 * pow(2, 52), 609 * pow(2, 52), 21 * pow(2, 52));
test(693 * pow(2, 53), 609 * pow(2, 53), 21 * pow(2, 53)); // Regression.
test(693 * pow(2, 99), 609 * pow(2, 99), 21 * pow(2, 99));
test(1234567890, 19, 1);
test(1234567890, 1000000001, 1);
test(19, 1000000001, 19);
test(0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF);
test(0x3FFFFFFF, 0x40000000, 1);
test(pow(2, 54), pow(2, 53), pow(2, 53));
test((pow(2, 52) - 1) * pow(2, 14), (pow(2, 26) - 1) * pow(2, 22),
(pow(2, 26) - 1) * pow(2, 14));
}
main() {
testModPow(); // //# modPow: ok
testModInverse();
testGcd();
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
void main() {
// If handleError isn't an unary function, and it's called, it also throws
// (either TypeError in checked mode, or some failure in unchecked mode).
// These are compile time errors for strong mode.
Expect.throws(() => int.parse("9", radix: 8, onError: "not a function"));
Expect.throws(() => int.parse("9", radix: 8, onError: () => 42));
Expect.throws(() => int.parse("9", radix: 8, onError: (v1, v2) => 42));
}

View file

@ -0,0 +1,147 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import "dart:math" show pow;
void main() {
const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
"\x85" // //# 01: ok
"\xa0";
const String whiteSpace = "$oneByteWhiteSpace\u1680"
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
"\u2028\u2029\u202f\u205f\u3000\ufeff";
var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
var zeros = "0" * 64;
for (int i = 0; i < whiteSpace.length; i++) {
var ws = whiteSpace[i];
Expect.equals(0, int.parse("${ws}0${ws}", radix: 2));
}
void testParse(int result, String radixString, int radix) {
var m = "$radixString/$radix->$result";
Expect.equals(
result, int.parse(radixString.toLowerCase(), radix: radix), m);
Expect.equals(
result, int.parse(radixString.toUpperCase(), radix: radix), m);
Expect.equals(result, int.parse(" $radixString", radix: radix), m);
Expect.equals(result, int.parse("$radixString ", radix: radix), m);
Expect.equals(result, int.parse(" $radixString ", radix: radix), m);
Expect.equals(result, int.parse("+$radixString", radix: radix), m);
Expect.equals(result, int.parse(" +$radixString", radix: radix), m);
Expect.equals(result, int.parse("+$radixString ", radix: radix), m);
Expect.equals(result, int.parse(" +$radixString ", radix: radix), m);
Expect.equals(-result, int.parse("-$radixString", radix: radix), m);
Expect.equals(-result, int.parse(" -$radixString", radix: radix), m);
Expect.equals(-result, int.parse("-$radixString ", radix: radix), m);
Expect.equals(-result, int.parse(" -$radixString ", radix: radix), m);
Expect.equals(
result,
int.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
radix: radix),
m);
Expect.equals(
-result,
int.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
radix: radix),
m);
Expect.equals(result,
int.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
Expect.equals(-result,
int.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
Expect.equals(result, int.parse("$zeros$radixString", radix: radix), m);
Expect.equals(result, int.parse("+$zeros$radixString", radix: radix), m);
Expect.equals(-result, int.parse("-$zeros$radixString", radix: radix), m);
}
for (int r = 2; r <= 36; r++) {
for (int i = 0; i <= r * r; i++) {
String radixString = i.toRadixString(r);
testParse(i, radixString, r);
}
}
for (int i = 2; i <= 36; i++) { // //# 02: ok
// Test with bignums. // //# 02: continued
var digit = digits[i - 1]; // //# 02: continued
testParse(pow(i, 64) - 1, digit * 64, i); // //# 02: continued
testParse(0, zeros, i); // //# 02: continued
} // //# 02: continued
// Allow both upper- and lower-case letters.
Expect.equals(0xABCD, int.parse("ABCD", radix: 16));
Expect.equals(0xABCD, int.parse("abcd", radix: 16));
Expect.equals(15628859, int.parse("09azAZ", radix: 36));
// Big number.
Expect.equals(0x12345678123456781234567812345678, // //# 02: continued
int.parse("0x1234567812345678" // //# 02: continued
"1234567812345678")); // //# 02: continued
// Allow whitespace before and after the number.
Expect.equals(1, int.parse(" 1", radix: 2));
Expect.equals(1, int.parse("1 ", radix: 2));
Expect.equals(1, int.parse(" 1 ", radix: 2));
Expect.equals(1, int.parse("\n1", radix: 2));
Expect.equals(1, int.parse("1\n", radix: 2));
Expect.equals(1, int.parse("\n1\n", radix: 2));
Expect.equals(1, int.parse("+1", radix: 2));
void testFails(String source, int radix) {
Expect.throws(() {
throw int.parse(source, radix: radix, onError: (s) {
throw "FAIL";
});
}, isFail, "$source/$radix");
Expect.equals(-999, int.parse(source, radix: radix, onError: (s) => -999));
}
for (int i = 2; i < 36; i++) {
var char = i.toRadixString(36);
testFails(char.toLowerCase(), i);
testFails(char.toUpperCase(), i);
}
testFails("", 2);
testFails("+ 1", 2); // No space between sign and digits.
testFails("- 1", 2); // No space between sign and digits.
testFails("0x", null);
for (int i = 2; i <= 33; i++) {
// No 0x specially allowed.
// At radix 34 and above, "x" is a valid digit.
testFails("0x10", i);
}
testBadTypes(var source, var radix) {
if (!typeAssertionsEnabled) {
// No promises on what error is thrown if the type doesn't match.
// Likely either ArgumentError or NoSuchMethodError.
Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0));
return;
}
// With type assertions enabled we can be more precise.
Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0),
(e) => e is TypeError || e is CastError);
}
testBadTypes(9, 10);
testBadTypes(true, 10);
testBadTypes("0", true);
testBadTypes("0", "10");
testBadArguments(String source, int radix) {
// If the types match, it should be an ArgumentError of some sort.
Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0),
(e) => e is ArgumentError);
}
testBadArguments("0", -1);
testBadArguments("0", 0);
testBadArguments("0", 1);
testBadArguments("0", 37);
// See also int_parse_radix_bad_handler_test.dart
}
bool isFail(e) => e == "FAIL";

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.round());
Expect.equals(1, 1.round());
Expect.equals(0x1234, 0x1234.round());
Expect.equals(0x12345678, 0x12345678.round());
Expect.equals(0x123456789AB, 0x123456789AB.round());
Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.round());
Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round());
Expect.equals(-1, -1.round());
Expect.equals(-0x1234, -0x1234.round());
Expect.equals(-0x12345678, -0x12345678.round());
Expect.equals(-0x123456789AB, -0x123456789AB.round());
Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.round());
Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round());
Expect.isTrue(0.round() is int);
Expect.isTrue(1.round() is int);
Expect.isTrue(0x1234.round() is int);
Expect.isTrue(0x12345678.round() is int);
Expect.isTrue(0x123456789AB.round() is int);
Expect.isTrue(0x123456789ABCDEF.round() is int);
Expect
.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round() is int);
Expect.isTrue(-1.round() is int);
Expect.isTrue(-0x1234.round() is int);
Expect.isTrue(-0x12345678.round() is int);
Expect.isTrue(-0x123456789AB.round() is int);
Expect.isTrue(-0x123456789ABCDEF.round() is int);
Expect.isTrue(
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round() is int);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.roundToDouble());
Expect.equals(1.0, 1.roundToDouble());
Expect.equals(0x1234, 0x1234.roundToDouble());
Expect.equals(0x12345678, 0x12345678.roundToDouble());
Expect.equals(0x123456789AB, 0x123456789AB.roundToDouble());
Expect.equals(81985529216486900.0, 0x123456789ABCDEF.roundToDouble());
Expect.equals(2.7898229935051914e+55,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.roundToDouble());
Expect.equals(-1.0, -1.roundToDouble());
Expect.equals(-0x1234, -0x1234.roundToDouble());
Expect.equals(-0x12345678, -0x12345678.roundToDouble());
Expect.equals(-0x123456789AB, -0x123456789AB.roundToDouble());
Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.roundToDouble());
Expect.equals(-2.7898229935051914e+55,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.roundToDouble());
Expect.isTrue(0.roundToDouble() is double);
Expect.isTrue(1.roundToDouble() is double);
Expect.isTrue(0x1234.roundToDouble() is double);
Expect.isTrue(0x12345678.roundToDouble() is double);
Expect.isTrue(0x123456789AB.roundToDouble() is double);
Expect.isTrue(0x123456789ABCDEF.roundToDouble() is double);
Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.roundToDouble() is double);
Expect.isTrue(-1.roundToDouble() is double);
Expect.isTrue(-0x1234.roundToDouble() is double);
Expect.isTrue(-0x12345678.roundToDouble() is double);
Expect.isTrue(-0x123456789AB.roundToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF.roundToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.roundToDouble() is double);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.toInt());
Expect.equals(1, 1.toInt());
Expect.equals(0x1234, 0x1234.toInt());
Expect.equals(0x12345678, 0x12345678.toInt());
Expect.equals(0x123456789AB, 0x123456789AB.toInt());
Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.toInt());
Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt());
Expect.equals(-1, -1.toInt());
Expect.equals(-0x1234, -0x1234.toInt());
Expect.equals(-0x12345678, -0x12345678.toInt());
Expect.equals(-0x123456789AB, -0x123456789AB.toInt());
Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.toInt());
Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt());
Expect.isTrue(0.toInt() is int);
Expect.isTrue(1.toInt() is int);
Expect.isTrue(0x1234.toInt() is int);
Expect.isTrue(0x12345678.toInt() is int);
Expect.isTrue(0x123456789AB.toInt() is int);
Expect.isTrue(0x123456789ABCDEF.toInt() is int);
Expect
.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt() is int);
Expect.isTrue(-1.toInt() is int);
Expect.isTrue(-0x1234.toInt() is int);
Expect.isTrue(-0x12345678.toInt() is int);
Expect.isTrue(-0x123456789AB.toInt() is int);
Expect.isTrue(-0x123456789ABCDEF.toInt() is int);
Expect.isTrue(
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt() is int);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0, 0.truncate());
Expect.equals(1, 1.truncate());
Expect.equals(0x1234, 0x1234.truncate());
Expect.equals(0x12345678, 0x12345678.truncate());
Expect.equals(0x123456789AB, 0x123456789AB.truncate());
Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.truncate());
Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate());
Expect.equals(-1, -1.truncate());
Expect.equals(-0x1234, -0x1234.truncate());
Expect.equals(-0x12345678, -0x12345678.truncate());
Expect.equals(-0x123456789AB, -0x123456789AB.truncate());
Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.truncate());
Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate());
Expect.isTrue(0.truncate() is int);
Expect.isTrue(1.truncate() is int);
Expect.isTrue(0x1234.truncate() is int);
Expect.isTrue(0x12345678.truncate() is int);
Expect.isTrue(0x123456789AB.truncate() is int);
Expect.isTrue(0x123456789ABCDEF.truncate() is int);
Expect.isTrue(
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate() is int);
Expect.isTrue(-1.truncate() is int);
Expect.isTrue(-0x1234.truncate() is int);
Expect.isTrue(-0x12345678.truncate() is int);
Expect.isTrue(-0x123456789AB.truncate() is int);
Expect.isTrue(-0x123456789ABCDEF.truncate() is int);
Expect.isTrue(
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate() is int);
}

View file

@ -0,0 +1,39 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
Expect.equals(0.0, 0.truncateToDouble());
Expect.equals(1.0, 1.truncateToDouble());
Expect.equals(0x1234, 0x1234.truncateToDouble());
Expect.equals(0x12345678, 0x12345678.truncateToDouble());
Expect.equals(0x123456789AB, 0x123456789AB.truncateToDouble());
Expect.equals(81985529216486900.0, 0x123456789ABCDEF.truncateToDouble());
Expect.equals(2.7898229935051914e+55,
0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncateToDouble());
Expect.equals(-1.0, -1.truncateToDouble());
Expect.equals(-0x1234, -0x1234.truncateToDouble());
Expect.equals(-0x12345678, -0x12345678.truncateToDouble());
Expect.equals(-0x123456789AB, -0x123456789AB.truncateToDouble());
Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.truncateToDouble());
Expect.equals(-2.7898229935051914e+55,
-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncateToDouble());
Expect.isTrue(0.truncateToDouble() is double);
Expect.isTrue(1.truncateToDouble() is double);
Expect.isTrue(0x1234.truncateToDouble() is double);
Expect.isTrue(0x12345678.truncateToDouble() is double);
Expect.isTrue(0x123456789AB.truncateToDouble() is double);
Expect.isTrue(0x123456789ABCDEF.truncateToDouble() is double);
Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.truncateToDouble() is double);
Expect.isTrue(-1.truncateToDouble() is double);
Expect.isTrue(-0x1234.truncateToDouble() is double);
Expect.isTrue(-0x12345678.truncateToDouble() is double);
Expect.isTrue(-0x123456789AB.truncateToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF.truncateToDouble() is double);
Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
.truncateToDouble() is double);
}

View file

@ -0,0 +1,95 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
// Test that we accept radix 2 to 36 and that we use lower-case
// letters.
var expected = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z'
];
for (var radix = 2; radix <= 36; radix++) {
for (var i = 0; i < radix; i++) {
Expect.equals(expected[i], i.toRadixString(radix));
}
}
var illegalRadices = [-1, 0, 1, 37];
for (var radix in illegalRadices) {
try {
42.toRadixString(radix);
Expect.fail("Exception expected");
} on ArgumentError catch (e) {
// Nothing to do.
}
}
// Try large numbers (regression test for issue 15316).
var bignums = [
0x80000000,
0x100000000,
0x10000000000000,
0x10000000000001, // 53 significant bits.
0x20000000000000,
0x20000000000002,
0x1000000000000000,
0x1000000000000100,
0x2000000000000000,
0x2000000000000200,
0x8000000000000000,
0x8000000000000800,
0x10000000000000000,
0x10000000000001000,
0x100000000000010000,
0x1000000000000100000,
0x10000000000001000000,
0x100000000000010000000,
0x1000000000000100000000,
0x10000000000001000000000,
];
for (var bignum in bignums) {
for (int radix = 2; radix <= 36; radix++) {
String digits = bignum.toRadixString(radix);
int result = int.parse(digits, radix: radix);
Expect.equals(
bignum, result, "${bignum.toRadixString(16)} -> $digits/$radix");
}
}
}

View file

@ -0,0 +1,89 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
/// Test that converting [value] to a string gives [expect].
/// Also test that `-value` gives `"-"+expect`.
test(int value, String expect) {
Expect.equals(expect, value.toString());
Expect.equals(expect, "$value");
Expect.equals(expect, (new StringBuffer()..write(value)).toString());
if (value == 0) return;
expect = "-$expect";
value = -value;
Expect.equals(expect, value.toString());
Expect.equals(expect, "$value");
Expect.equals(expect, (new StringBuffer()..write(value)).toString());
}
// Very simple tests.
test(0, "0");
test(1, "1");
test(2, "2");
test(5, "5");
// Binary special cases.
// ~2^30.
test(0x3fffffff, "1073741823");
test(0x40000000, "1073741824");
test(0x40000001, "1073741825");
// ~2^31.
test(0x7fffffff, "2147483647");
test(0x80000000, "2147483648");
test(0x80000001, "2147483649");
// ~2^32.
test(0xffffffff, "4294967295");
test(0x100000000, "4294967296");
test(0x100000001, "4294967297");
// ~2^51.
test(0x7ffffffffffff, "2251799813685247");
test(0x8000000000000, "2251799813685248");
test(0x8000000000001, "2251799813685249");
// ~2^52.
test(0xfffffffffffff, "4503599627370495");
test(0x10000000000000, "4503599627370496");
test(0x10000000000001, "4503599627370497");
// ~2^53.
test(0x1fffffffffffff, "9007199254740991");
test(0x20000000000000, "9007199254740992");
test(0x20000000000001, "9007199254740993"); // //# 01: ok
// ~2^62.
test(0x3fffffffffffffff, "4611686018427387903"); // //# 01: continued
test(0x4000000000000000, "4611686018427387904"); // //# 01: continued
test(0x4000000000000001, "4611686018427387905"); // //# 01: continued
// ~2^63.
test(0x7fffffffffffffff, "9223372036854775807"); // //# 01: continued
test(0x8000000000000000, "9223372036854775808"); // //# 01: continued
test(0x8000000000000001, "9223372036854775809"); // //# 01: continued
// ~2^64.
test(0xffffffffffffffff, "18446744073709551615"); // //# 01: continued
test(0x10000000000000000, "18446744073709551616"); // //# 01: continued
test(0x10000000000000001, "18446744073709551617"); // //# 01: continued
// Big bignum.
test(123456789012345678901234567890, // //# 01: continued
"123456789012345678901234567890"); // //# 01: continued
// Decimal special cases.
int number = 10;
// Numbers 99..99, 100...00, and 100..01 up to 23 digits.
for (int i = 1; i < 15; i++) {
// Works in dart2js up to 10^15.
test(number - 1, "9" * i);
test(number, "1" + "0" * i);
test(number + 1, "1" + "0" * (i - 1) + "1");
number *= 10;
}
// Fails to represent exactly in dart2js.
for (int i = 15; i < 22; i++) { // //# 01: continued
test(number - 1, "9" * i); // //# 01: continued
test(number, "1" + "0" * i); // //# 01: continued
test(number + 1, "1" + "0" * (i - 1) + "1"); // //# 01: continued
number *= 10; // //# 01: continued
} // //# 01: continued
}

Some files were not shown because too many files have changed in this diff Show more