[tests] Cleaning up migrated corelib tests.

Change-Id: I7ac31a6bf66c777202a6c642bae584af8e3288ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140380
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
This commit is contained in:
Mark Zhou
2020-03-24 17:34:25 +00:00
committed by commit-bot@chromium.org
parent 29f47fdccb
commit 2228b6d337
8 changed files with 22 additions and 22 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ void runTests() {
}
}
void main(List<String> args) {
void main() {
// The following code constructs a String with all timezones that are
// relevant for this test.
// This can be helpful for running tests in multiple timezones.
+1 -1
View File
@@ -31,7 +31,7 @@ class ExpandoTest {
}
static visit(object) {
int count = visits[object]!;
int? count = visits[object];
count = (count == null) ? 1 : count + 1;
visits[object] = count;
}
+6 -5
View File
@@ -29,8 +29,9 @@ test(List expects, Iterable iterable, [String? name]) {
expect, iterable.elementAt(index), "$name: elementAt($index)");
Expect.isTrue(iterable.contains(expect), "$name:contains $index");
}
Expect.isFalse(it.moveNext(),
"$name: extra element at ${expects.length}: ${it.current}");
var hasNext = it.moveNext();
Expect.isFalse(hasNext,
"$name: extra element at ${expects.length}: ${hasNext ? it.current : ''}");
} on Error {
print("Failed during: $name");
rethrow;
@@ -50,9 +51,9 @@ tests(List<int> expects, Iterable<int> follow, [String? name]) {
for (int i = 0; i <= length; i++) {
for (int j = 0; j <= length - i; j++) {
test(expects.sublist(i, i + j), follow.skip(i).take(j),
"$name.skiptake($i,${i+j})");
"$name.skiptake($i,${i + j})");
test(expects.sublist(i, i + j), follow.take(i + j).skip(i),
"$name.takeskip($i,${i+j})");
"$name.takeskip($i,${i + j})");
}
}
}
@@ -99,4 +100,4 @@ main() {
types(<int>[1, 2, 3, 4], const <int>[], const <int>[1, 2, 3, 4], "0+4");
types(<int>[1, 2, 3, 4], const <int>[1, 2], const <int>[3, 4], "2+2");
types(<int>[1, 2, 3, 4], const <int>[1, 2, 3, 4], const <int>[], "4+0");
}
}
+4 -5
View File
@@ -20,7 +20,6 @@ main() {
testIterable(<int?>[1, 2, 3], <int?>[1, 2, 3]);
testIterable(const [1, 2], [1, 2], 0);
testIterable(const <int>[1, 2], <int>[1, 2], 0);
testIterable(const <int?>[1, 2], <int?>[1, 2]);
testIterable(<dynamic, dynamic>{"x": 1, "y": 1}.keys, <dynamic>["x", "y"]);
testIterable(<String, int>{"x": 1, "y": 1}.keys, <String>["x", "y"], "");
testIterable(<String?, int>{"x": 1, "y": 1}.keys, <String?>["x", "y"]);
@@ -41,10 +40,10 @@ main() {
testIterable(new Queue<int>.from(<int>[1, 2, 3]), <int>[1, 2, 3], 0);
testIterable(new Queue<int?>.from(<int?>[1, 2, 3]), <int?>[1, 2, 3]);
testIterable(new Uint8List.fromList(<int>[1, 2, 3]), // //# 01: ok
<int>[1, 2, 3], 0); // //# 01: continued
<int>[1, 2, 3], 0); // //# 01: continued
testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), // //# 01: continued
<double>[1.0, 2.0, 3.0], 0.1); // //# 01: continued
testIterable("abc".codeUnits, <int>[97, 98, 99]); // //# 01: continued
<double>[1.0, 2.0, 3.0], 0.1); // //# 01: continued
testIterable("abc".codeUnits, <int>[97, 98, 99], 99); // //# 01: continued
testIterable("abc".runes, <int>[97, 98, 99], 99);
}
@@ -88,4 +87,4 @@ test(Iterable iterable, List expected, element, {bool growable: true}) {
list.add(element);
});
}
}
}
+1 -1
View File
@@ -160,7 +160,7 @@ void testLinkedHashMap() {
void testMap<K, V>(
Map<K, V> typedMap, key1, key2, key3, key4, key5, key6, key7, key8) {
Map map = typedMap;
var map = typedMap;
int value1 = 10;
int value2 = 20;
int value3 = 30;
@@ -31,16 +31,16 @@ void main() {
testNum(m2.cast<int, int>(), "Map<num>.unmod.cast<int>");
Map<Symbol, dynamic> nsm = new NsmMap().foo(a: 0);
test(nsm, #a, 0, "nsm", noSuchMethodMap: true);
test(nsm.cast<Object, int>(), #a, 0, "nsm.cast", noSuchMethodMap: true);
test<Symbol, dynamic>(nsm, #a, 0, "nsm", noSuchMethodMap: true);
test<Object, int>(nsm.cast<Object, int>(), #a, 0, "nsm.cast",
noSuchMethodMap: true);
}
void testNum(Map<Object, Object> map, String name) {
test(map, 1, 37, name);
test<int, int>(map, 1, 37, name);
}
void test(
Map<Object?, Object?> map, Object firstKey, Object firstValue, String name,
void test<K, V>(map, firstKey, firstValue, String name,
{bool noSuchMethodMap: false}) {
if (!noSuchMethodMap) {
Expect.isTrue(map.containsKey(firstKey), "$name.containsKey");
@@ -54,10 +54,10 @@ void test(
map.remove(firstKey);
}, "$name.remove");
Expect.throwsUnsupportedError(() {
map[null] = null;
map[firstKey] = firstValue;
}, "$name[]=");
Expect.throwsUnsupportedError(() {
map.addAll(<Null, Null>{null: null});
map.addAll(<K, V>{firstKey: firstValue});
}, "$name.addAll");
}
+1 -1
View File
@@ -61,7 +61,7 @@ void testInts(Set create()) {
Expect.isTrue(set.containsAll(set));
// Test Set.map.
bool testMap(dynamic val) {
int testMap(dynamic val) {
return (val as int) * val;
}
+1 -1
View File
@@ -42,7 +42,7 @@ testEncodeDecodeComponent(String orig, String encoded) {
}
testEncodeDecodeQueryComponent(String orig, String encodedUTF8,
String encodedLatin1, String encodedAscii) {
String encodedLatin1, String? encodedAscii) {
var e, d;
e = Uri.encodeQueryComponent(orig);
Expect.stringEquals(encodedUTF8, e);