From 2228b6d337eb506b02511bbcbc7e9b26e2328bf8 Mon Sep 17 00:00:00 2001 From: Mark Zhou Date: Tue, 24 Mar 2020 17:34:25 +0000 Subject: [PATCH] [tests] Cleaning up migrated corelib tests. Change-Id: I7ac31a6bf66c777202a6c642bae584af8e3288ab Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140380 Reviewed-by: Bob Nystrom Commit-Queue: Mark Zhou --- tests/corelib/date_time11_test.dart | 2 +- tests/corelib/expando_test.dart | 2 +- tests/corelib/iterable_followed_by_test.dart | 11 ++++++----- tests/corelib/iterable_to_list_test.dart | 9 ++++----- tests/corelib/map_test.dart | 2 +- tests/corelib/map_unmodifiable_cast_test.dart | 14 +++++++------- tests/corelib/set_test.dart | 2 +- tests/corelib/uri_test.dart | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/corelib/date_time11_test.dart b/tests/corelib/date_time11_test.dart index 0a1790cfec6..75c2c34b631 100644 --- a/tests/corelib/date_time11_test.dart +++ b/tests/corelib/date_time11_test.dart @@ -122,7 +122,7 @@ void runTests() { } } -void main(List 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. diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart index 3189c9b3d1a..04d6ad42cde 100644 --- a/tests/corelib/expando_test.dart +++ b/tests/corelib/expando_test.dart @@ -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; } diff --git a/tests/corelib/iterable_followed_by_test.dart b/tests/corelib/iterable_followed_by_test.dart index 33a37c5a4a1..a2e352d28ee 100644 --- a/tests/corelib/iterable_followed_by_test.dart +++ b/tests/corelib/iterable_followed_by_test.dart @@ -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 expects, Iterable 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([1, 2, 3, 4], const [], const [1, 2, 3, 4], "0+4"); types([1, 2, 3, 4], const [1, 2], const [3, 4], "2+2"); types([1, 2, 3, 4], const [1, 2, 3, 4], const [], "4+0"); -} +} \ No newline at end of file diff --git a/tests/corelib/iterable_to_list_test.dart b/tests/corelib/iterable_to_list_test.dart index 63e5954885e..112d9cd5d63 100644 --- a/tests/corelib/iterable_to_list_test.dart +++ b/tests/corelib/iterable_to_list_test.dart @@ -20,7 +20,6 @@ main() { testIterable([1, 2, 3], [1, 2, 3]); testIterable(const [1, 2], [1, 2], 0); testIterable(const [1, 2], [1, 2], 0); - testIterable(const [1, 2], [1, 2]); testIterable({"x": 1, "y": 1}.keys, ["x", "y"]); testIterable({"x": 1, "y": 1}.keys, ["x", "y"], ""); testIterable({"x": 1, "y": 1}.keys, ["x", "y"]); @@ -41,10 +40,10 @@ main() { testIterable(new Queue.from([1, 2, 3]), [1, 2, 3], 0); testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]); testIterable(new Uint8List.fromList([1, 2, 3]), // //# 01: ok - [1, 2, 3], 0); // //# 01: continued + [1, 2, 3], 0); // //# 01: continued testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), // //# 01: continued - [1.0, 2.0, 3.0], 0.1); // //# 01: continued - testIterable("abc".codeUnits, [97, 98, 99]); // //# 01: continued + [1.0, 2.0, 3.0], 0.1); // //# 01: continued + testIterable("abc".codeUnits, [97, 98, 99], 99); // //# 01: continued testIterable("abc".runes, [97, 98, 99], 99); } @@ -88,4 +87,4 @@ test(Iterable iterable, List expected, element, {bool growable: true}) { list.add(element); }); } -} +} \ No newline at end of file diff --git a/tests/corelib/map_test.dart b/tests/corelib/map_test.dart index 74f0577e8f9..09b931160ab 100644 --- a/tests/corelib/map_test.dart +++ b/tests/corelib/map_test.dart @@ -160,7 +160,7 @@ void testLinkedHashMap() { void testMap( Map typedMap, key1, key2, key3, key4, key5, key6, key7, key8) { - Map map = typedMap; + var map = typedMap; int value1 = 10; int value2 = 20; int value3 = 30; diff --git a/tests/corelib/map_unmodifiable_cast_test.dart b/tests/corelib/map_unmodifiable_cast_test.dart index 2eca99f6ae4..31466efcb1c 100644 --- a/tests/corelib/map_unmodifiable_cast_test.dart +++ b/tests/corelib/map_unmodifiable_cast_test.dart @@ -31,16 +31,16 @@ void main() { testNum(m2.cast(), "Map.unmod.cast"); Map nsm = new NsmMap().foo(a: 0); - test(nsm, #a, 0, "nsm", noSuchMethodMap: true); - test(nsm.cast(), #a, 0, "nsm.cast", noSuchMethodMap: true); + test(nsm, #a, 0, "nsm", noSuchMethodMap: true); + test(nsm.cast(), #a, 0, "nsm.cast", + noSuchMethodMap: true); } void testNum(Map map, String name) { - test(map, 1, 37, name); + test(map, 1, 37, name); } -void test( - Map map, Object firstKey, Object firstValue, String name, +void test(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}); + map.addAll({firstKey: firstValue}); }, "$name.addAll"); } diff --git a/tests/corelib/set_test.dart b/tests/corelib/set_test.dart index 5c8a12cfc7a..18deeb3d5a9 100644 --- a/tests/corelib/set_test.dart +++ b/tests/corelib/set_test.dart @@ -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; } diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart index 386838a6a01..bb45fe057be 100644 --- a/tests/corelib/uri_test.dart +++ b/tests/corelib/uri_test.dart @@ -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);