mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
b9d35ded2e
Split out int64 lines of multi-test for corelib/iterable_return_type_test and added status to skip the int64 test on the web compilers. Change-Id: I1e56299973956932c5b16b1ceeeb2b8f00457bf5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141802 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Riley Porter <rileyporter@google.com>
44 lines
1.5 KiB
Dart
44 lines
1.5 KiB
Dart
// Copyright (c) 2020, 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";
|
|
|
|
testIntIterable(iterable) {
|
|
Expect.isTrue(iterable is Iterable<int>, "${iterable.runtimeType}");
|
|
Expect.isFalse(iterable is Iterable<String>, "${iterable.runtimeType}");
|
|
}
|
|
|
|
void testIterable(Iterable<int> iterable, [int depth = 3]) {
|
|
testIntIterable(iterable);
|
|
if (depth > 0) {
|
|
testIterable(iterable.where((x) => true), depth - 1);
|
|
testIterable(iterable.skip(1), depth - 1);
|
|
testIterable(iterable.take(1), depth - 1);
|
|
testIterable(iterable.skipWhile((x) => false), depth - 1);
|
|
testIterable(iterable.takeWhile((x) => true), depth - 1);
|
|
testList(iterable.toList(growable: true), depth - 1);
|
|
testList(iterable.toList(growable: false), depth - 1);
|
|
testIterable(iterable.toSet(), depth - 1);
|
|
}
|
|
}
|
|
|
|
void testList(List<int> list, [int depth = 3]) {
|
|
testIterable(list, depth);
|
|
if (depth > 0) {
|
|
testIterable(list.getRange(0, list.length), depth - 1);
|
|
testIterable(list.reversed, depth - 1);
|
|
testMap(list.asMap(), depth - 1);
|
|
}
|
|
}
|
|
|
|
void testMap(Map<int, int> map, [int depth = 3]) {
|
|
Expect.isTrue(map is Map<int, int>);
|
|
Expect.isFalse(map is Map<int, String>);
|
|
Expect.isFalse(map is Map<String, int>);
|
|
if (depth > 0) {
|
|
testIterable(map.keys, depth - 1);
|
|
testIterable(map.values, depth - 1);
|
|
}
|
|
}
|