mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:18:49 +00:00
[Tests] Fix corelib_2/iterable_fold_test and iterable_reduce_test
* Change 'var iterable' to dynamic as type inference can only infer Object type. * Explicitly set result type of closures passed to reduce() to make closure type compatible with parameter type expected by reduce(). * To modify List of Lists of int, add '[4]' instead of '4' to trigger expected ConcurrentModificationError instead of type error. * Remove splitting to multi-test. * Format with dartfmt. Change-Id: Ie1a35eececbf1133cb2384afad10e9d355016abe Reviewed-on: https://dart-review.googlesource.com/36300 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Régis Crelier <regis@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
8393995457
commit
4334c97dcb
|
@ -15,7 +15,6 @@ apply3_test: CompileTimeError
|
|||
bool_from_environment2_test/03: Crash
|
||||
int_modulo_arith_test/modPow: RuntimeError
|
||||
int_modulo_arith_test/none: RuntimeError
|
||||
iterable_reduce_test/01: CompileTimeError
|
||||
map_test: Crash # crash in front_end.
|
||||
null_nosuchmethod_test/01: CompileTimeError
|
||||
null_nosuchmethod_test/none: CompileTimeError
|
||||
|
@ -234,13 +233,10 @@ integer_to_radix_string_test/02: RuntimeError
|
|||
integer_to_radix_string_test/none: RuntimeError
|
||||
integer_to_string_test/01: RuntimeError
|
||||
iterable_empty_test: Crash # 'file:*/pkg/compiler/lib/src/ssa/interceptor_simplifier.dart': Failed assertion: line 391 pos 16: 'receiver.nonCheck() == user.inputs[1].nonCheck()': is not true.
|
||||
iterable_fold_test/01: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test/02: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test/none: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_generate_test/01: RuntimeError
|
||||
iterable_generate_test/none: RuntimeError
|
||||
iterable_reduce_test/01: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_reduce_test/none: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_reduce_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_return_type_test/01: RuntimeError
|
||||
iterable_return_type_test/02: RuntimeError
|
||||
iterable_return_type_test/none: RuntimeError
|
||||
|
@ -300,13 +296,10 @@ integer_to_radix_string_test/02: RuntimeError
|
|||
integer_to_radix_string_test/none: RuntimeError
|
||||
integer_to_string_test/01: RuntimeError
|
||||
iterable_empty_test: RuntimeError
|
||||
iterable_fold_test/01: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test/02: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test/none: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_fold_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_generate_test/01: RuntimeError
|
||||
iterable_generate_test/none: RuntimeError
|
||||
iterable_reduce_test/01: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_reduce_test/none: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_reduce_test: Crash # NoSuchMethodError: The getter 'isDynamic' was called on null.
|
||||
iterable_return_type_test/01: RuntimeError
|
||||
iterable_return_type_test/02: RuntimeError
|
||||
iterable_return_type_test/none: RuntimeError
|
||||
|
@ -409,9 +402,6 @@ bigint_test: Pass, Timeout # Please triage.
|
|||
[ $compiler == dartk && $runtime == vm && $strong ]
|
||||
apply3_test: CompileTimeError # Issue 31402 (Invocation arguments)
|
||||
bool_from_environment2_test/03: MissingCompileTimeError
|
||||
iterable_fold_test/02: RuntimeError
|
||||
iterable_reduce_test/01: CompileTimeError # Issue 31533
|
||||
iterable_reduce_test/none: RuntimeError
|
||||
iterable_to_list_test/01: RuntimeError
|
||||
iterable_to_list_test/none: RuntimeError
|
||||
json_map_test: RuntimeError
|
||||
|
@ -435,9 +425,6 @@ unicode_test: RuntimeError # Issue 18061: German double S.
|
|||
# ===== dartkp + dart_precompiled status lines =====
|
||||
[ $compiler == dartkp && $runtime == dart_precompiled && $strong ]
|
||||
bool_from_environment2_test/03: MissingCompileTimeError
|
||||
iterable_fold_test/02: RuntimeError
|
||||
iterable_reduce_test/01: CompileTimeError # Issue 31533
|
||||
iterable_reduce_test/none: RuntimeError
|
||||
iterable_to_list_test/01: RuntimeError
|
||||
iterable_to_list_test/none: RuntimeError
|
||||
json_map_test: RuntimeError
|
||||
|
@ -525,9 +512,6 @@ integer_arith_vm_test/modPow: RuntimeError # Issue 30170
|
|||
integer_parsed_arith_vm_test: RuntimeError # Issue 29921
|
||||
integer_to_radix_string_test: RuntimeError # Issue 29921
|
||||
integer_to_string_test/01: RuntimeError # Issue 29921
|
||||
iterable_fold_test/02: RuntimeError # different type inference problem
|
||||
iterable_reduce_test/01: RuntimeError
|
||||
iterable_reduce_test/none: RuntimeError
|
||||
iterable_return_type_test/02: RuntimeError # Issue 29921
|
||||
iterable_to_list_test/*: RuntimeError
|
||||
json_map_test: RuntimeError # Issue 29921
|
||||
|
@ -688,7 +672,6 @@ double_parse_test/02: Skip # Temporarily disable the following tests until we fi
|
|||
double_parse_test/03: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
||||
double_parse_test/04: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
||||
double_parse_test/none: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
||||
iterable_reduce_test/01: CompileTimeError # Issue 31533
|
||||
|
||||
[ $compiler == dartkp || $compiler == precompiler ]
|
||||
apply3_test: SkipByDesign
|
||||
|
|
|
@ -19,7 +19,7 @@ class MyList extends ListBase {
|
|||
operator []=(index, val) => list[index] = val;
|
||||
}
|
||||
|
||||
Iterable id (Iterable x) => x;
|
||||
Iterable id(Iterable x) => x;
|
||||
|
||||
main() {
|
||||
for (dynamic iterable in [
|
||||
|
@ -35,10 +35,10 @@ main() {
|
|||
new List.generate(3, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => x > 0),
|
||||
[0, 1, 2].map((x) => x + 1),
|
||||
[ //# 01: ok
|
||||
[1, 2], //# 01: ok
|
||||
[3] //# 01: ok
|
||||
].expand(id), //# 01: ok
|
||||
[
|
||||
[1, 2],
|
||||
[3]
|
||||
].expand(id),
|
||||
[3, 2, 1].reversed,
|
||||
[0, 1, 2, 3].skip(1),
|
||||
[1, 2, 3, 4].take(3),
|
||||
|
@ -93,7 +93,7 @@ main() {
|
|||
new List.generate(0, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => false),
|
||||
[].map((x) => x + 1),
|
||||
[[], []].expand(id), //# 01: ok
|
||||
[[], []].expand(id),
|
||||
[].reversed,
|
||||
[0, 1, 2, 3].skip(4),
|
||||
[1, 2, 3, 4].take(0),
|
||||
|
@ -123,18 +123,18 @@ main() {
|
|||
new List.generate(1, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => x == 1),
|
||||
[0].map((x) => x + 1),
|
||||
[ //# 01: ok
|
||||
[], //# 01: ok
|
||||
[1] //# 01: ok
|
||||
].expand(id), //# 01: ok
|
||||
[
|
||||
[],
|
||||
[1]
|
||||
].expand(id),
|
||||
[1].reversed,
|
||||
[0, 1].skip(1),
|
||||
[1, 2, 3, 4].take(1),
|
||||
new Uint8List(1)..[0] = 1,
|
||||
(new HashMap()..[1] = 0).keys,
|
||||
(new HashMap()..[0] = 1).values, //# 02: ok
|
||||
(new HashMap()..[0] = 1).values,
|
||||
(new SplayTreeMap()..[1] = 0).keys,
|
||||
(new SplayTreeMap()..[0] = 1).values, //# 02: ok
|
||||
(new SplayTreeMap()..[0] = 1).values,
|
||||
new HashSet()..add(1),
|
||||
new LinkedHashSet()..add(1),
|
||||
new SplayTreeSet()..add(1),
|
||||
|
@ -160,23 +160,27 @@ main() {
|
|||
collection.add(4);
|
||||
}
|
||||
|
||||
void addListOf4(collection) {
|
||||
collection.add([4]);
|
||||
}
|
||||
|
||||
void put4(map) {
|
||||
map[4] = 4;
|
||||
}
|
||||
|
||||
testModification([1, 2, 3], add4, id); //# 02: ok
|
||||
testModification(new HashSet()..add(1)..add(2)..add(3), add4, id); //# 02: ok
|
||||
testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id); //# 02: ok
|
||||
testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id); //# 02: ok
|
||||
testModification(new MyList([1, 2, 3]), add4, id); //# 02: ok
|
||||
testModification([1, 2, 3], add4, id);
|
||||
testModification(new HashSet()..add(1)..add(2)..add(3), add4, id);
|
||||
testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id);
|
||||
testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id);
|
||||
testModification(new MyList([1, 2, 3]), add4, id);
|
||||
|
||||
testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0)); //# 02: ok
|
||||
testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1)); //# 02: ok
|
||||
testModification([ //# 02: ok
|
||||
[1, 2], //# 02: ok
|
||||
[3] //# 02: ok
|
||||
], add4, (x) => x.expand((x) => x)); //# 02: ok
|
||||
testModification([3, 2, 1], add4, (x) => x.reversed); //# 02: ok
|
||||
testModification([0, 1, 2, 3], add4, (x) => x.where((int x) => x > 0));
|
||||
testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1));
|
||||
testModification([
|
||||
[1, 2],
|
||||
[3]
|
||||
], addListOf4, (x) => x.expand((List<int> x) => x));
|
||||
testModification([3, 2, 1], add4, (x) => x.reversed);
|
||||
testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys);
|
||||
testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values);
|
||||
var hashMap = new HashMap()
|
||||
|
|
|
@ -23,7 +23,7 @@ Iterable id(Iterable x) => x;
|
|||
|
||||
main() {
|
||||
// Test functionality.
|
||||
for (var iterable in [
|
||||
for (dynamic iterable in [
|
||||
const [1, 2, 3],
|
||||
[1, 2, 3],
|
||||
new List(3)
|
||||
|
@ -36,10 +36,10 @@ main() {
|
|||
new List.generate(3, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => x > 0),
|
||||
[0, 1, 2].map((x) => x + 1),
|
||||
[ //# 01: ok
|
||||
[1, 2], //# 01: ok
|
||||
[3] //# 01: ok
|
||||
].expand(id), //# 01: ok
|
||||
[
|
||||
[1, 2],
|
||||
[3]
|
||||
].expand(id),
|
||||
[3, 2, 1].reversed,
|
||||
[0, 1, 2, 3].skip(1),
|
||||
[1, 2, 3, 4].take(3),
|
||||
|
@ -75,12 +75,13 @@ main() {
|
|||
new MyList([1, 2, 3]),
|
||||
]) {
|
||||
int callCount = 0;
|
||||
var result = iterable.reduce((x, y) { //# 01: ok
|
||||
callCount++; //# 01: ok
|
||||
return x + y; //# 01: ok
|
||||
}); //# 01: ok
|
||||
Expect.equals(6, result, "${iterable.runtimeType}"); //# 01: ok
|
||||
Expect.equals(2, callCount); //# 01: ok
|
||||
var result = iterable.reduce((x, y) {
|
||||
callCount++;
|
||||
// Return type of reduce() callback should match element type.
|
||||
return (x + y) as int;
|
||||
});
|
||||
Expect.equals(6, result, "${iterable.runtimeType}");
|
||||
Expect.equals(2, callCount);
|
||||
}
|
||||
|
||||
// Empty iterables not allowed.
|
||||
|
@ -94,7 +95,7 @@ main() {
|
|||
new List.generate(0, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => false),
|
||||
[].map((x) => x + 1),
|
||||
[[], []].expand(id), //# 01: ok
|
||||
[[], []].expand(id),
|
||||
[].reversed,
|
||||
[0, 1, 2, 3].skip(4),
|
||||
[1, 2, 3, 4].take(0),
|
||||
|
@ -110,12 +111,12 @@ main() {
|
|||
"".runes,
|
||||
new MyList([]),
|
||||
]) {
|
||||
Expect.throwsStateError(
|
||||
() => iterable.reduce((x, y) => throw "Unreachable"));
|
||||
Expect
|
||||
.throwsStateError(() => iterable.reduce((x, y) => throw "Unreachable"));
|
||||
}
|
||||
|
||||
// Singleton iterables not calling reduce function.
|
||||
for (var iterable in [
|
||||
for (dynamic iterable in [
|
||||
const [1],
|
||||
[1],
|
||||
new List(1)..[0] = 1,
|
||||
|
@ -125,10 +126,10 @@ main() {
|
|||
new List.generate(1, (x) => x + 1),
|
||||
[0, 1, 2, 3].where((x) => x == 1),
|
||||
[0].map((x) => x + 1),
|
||||
[ //# 01: ok
|
||||
[], //# 01: ok
|
||||
[1] //# 01: ok
|
||||
].expand(id), //# 01: ok
|
||||
[
|
||||
[],
|
||||
[1]
|
||||
].expand(id),
|
||||
[1].reversed,
|
||||
[0, 1].skip(1),
|
||||
[1, 2, 3, 4].take(1),
|
||||
|
@ -144,7 +145,7 @@ main() {
|
|||
"\x01".runes,
|
||||
new MyList([1]),
|
||||
]) {
|
||||
Expect.equals(1, iterable.reduce((x, y) => throw "Unreachable")); //# 01: ok
|
||||
Expect.equals(1, iterable.reduce((x, y) => throw "Unreachable"));
|
||||
}
|
||||
|
||||
// Concurrent modifications not allowed.
|
||||
|
@ -153,7 +154,8 @@ main() {
|
|||
Expect.throws(() {
|
||||
iterable.reduce((x, y) {
|
||||
modify(base);
|
||||
return x + y;
|
||||
// Return type of reduce() callback should match element type.
|
||||
return (x + y) as int;
|
||||
});
|
||||
}, (e) => e is ConcurrentModificationError);
|
||||
}
|
||||
|
@ -162,6 +164,10 @@ main() {
|
|||
collection.add(4);
|
||||
}
|
||||
|
||||
void addListOf4(collection) {
|
||||
collection.add([4]);
|
||||
}
|
||||
|
||||
void put4(map) {
|
||||
map[4] = 4;
|
||||
}
|
||||
|
@ -172,12 +178,12 @@ main() {
|
|||
testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id);
|
||||
testModification(new MyList([1, 2, 3]), add4, id);
|
||||
|
||||
testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0));
|
||||
testModification([0, 1, 2, 3], add4, (x) => x.where((int x) => x > 0));
|
||||
testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1));
|
||||
testModification([
|
||||
[1, 2],
|
||||
[3]
|
||||
], add4, (x) => x.expand((x) => x));
|
||||
], addListOf4, (x) => x.expand((List<int> x) => x));
|
||||
testModification([3, 2, 1], add4, (x) => x.reversed);
|
||||
testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys);
|
||||
testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values);
|
||||
|
|
Loading…
Reference in a new issue