mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
b101a7d002
Change-Id: Ib33169c3e0ffc870915c189404074a1dea472546 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196548 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Leaf Petersen <leafp@google.com>
46 lines
1.5 KiB
Dart
46 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
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);
|
|
}
|
|
}
|