[test] Fix various static errors in corelib tests

Change-Id: I762538437b8f68f20c149b737cbe65f212c5c3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142370
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
Johnni Winther 2020-04-16 09:20:21 +00:00 committed by commit-bot@chromium.org
parent 594f77715b
commit 2d12821cba
8 changed files with 24 additions and 20 deletions

View file

@ -13,7 +13,7 @@ test0<T extends num>(T i, T j, {required T a}) => i + j + a;
main() {
test(res, func, list, map) {
map = symbolMapToStringMap(map);
map = symbolToStringMap(map);
Expect.equals(res, Function.apply(func, list, map));
}

View file

@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
import "symbol_map_helper.dart";
// Testing Function.apply calls correctly.
// This test is not testing error handling, only that correct parameters

View file

@ -13,7 +13,7 @@ stopwatch_test: Skip # Flaky test due to expected performance behaviour.
[ $builder_tag == obfuscated && $runtime == dart_precompiled ]
apply_generic_function_test: SkipByDesign # Function.apply with named args
apply_test: Skip # Uses new Symbol via symbolMapToStringMap helper
apply_test: Skip # Uses new Symbol via symbolToStringMap helper
dynamic_nosuchmethod_test: SkipByDesign # Expects names in NSM
error_stack_trace1_test: SkipByDesign # Expects unobfuscated stack trace
type_tostring_test: SkipByDesign # Expects names in Type.toString()

View file

@ -55,14 +55,17 @@ void main() {
testNumericKeys(new MapBaseMap<num, String>());
testNumericKeys(new MapMixinMap<num, String>());
// NaN maps need to have nullable value types because the forEach method
// cannot look up the value and therefore might find `null` instead of the
// actuall value. See MapMixin.forEach in dart:collection/maps.dart
testNaNKeys(new Map());
testNaNKeys(new Map<num, String>());
testNaNKeys(new Map<num, String?>());
testNaNKeys(new HashMap());
testNaNKeys(new HashMap<num, String>());
testNaNKeys(new HashMap<num, String?>());
testNaNKeys(new LinkedHashMap());
testNaNKeys(new LinkedHashMap<num, String>());
testNaNKeys(new MapBaseMap<num, String>());
testNaNKeys(new MapMixinMap<num, String>());
testNaNKeys(new LinkedHashMap<num, String?>());
testNaNKeys(new MapBaseMap<num, String?>());
testNaNKeys(new MapMixinMap<num, String?>());
// Identity maps fail the NaN-keys tests because the test assumes that
// NaN is not equal to NaN.
@ -160,7 +163,7 @@ void testLinkedHashMap() {
void testMap<K, V>(
Map<K, V> typedMap, key1, key2, key3, key4, key5, key6, key7, key8) {
var map = typedMap;
dynamic map = typedMap;
int value1 = 10;
int value2 = 20;
int value3 = 30;
@ -379,7 +382,7 @@ void testDeletedElement(Map map) {
}
void testMapLiteral() {
Map m = {"a": 1, "b": 2, "c": 3};
var m = {"a": 1, "b": 2, "c": 3};
Expect.equals(3, m.length);
int sum = 0;
m.forEach((a, b) {

View file

@ -420,12 +420,12 @@ class DoubleLinkedQueueTest extends QueueTest {
}
Expect.equals(null, entry2);
var firstEntry = queue1.firstEntry();
var secondEntry = queue1.firstEntry().nextEntry();
var thirdEntry = queue1.lastEntry();
var firstEntry = queue1.firstEntry()!;
var secondEntry = queue1.firstEntry()!.nextEntry()!;
var thirdEntry = queue1.lastEntry()!;
firstEntry.prepend(4);
firstEntry.append(5);
secondEntry!.prepend(6);
secondEntry.prepend(6);
secondEntry.append(7);
thirdEntry.prepend(8);
thirdEntry.append(9);
@ -446,11 +446,11 @@ void linkEntryTest() {
entry.append(37);
entry.prepend(87);
var prev = entry.previousEntry();
var next = entry.nextEntry();
var prev = entry.previousEntry()!;
var next = entry.nextEntry()!;
Expect.equals(42, entry.element);
Expect.equals(37, next!.element);
Expect.equals(87, prev!.element);
Expect.equals(37, next.element);
Expect.equals(87, prev.element);
Expect.identical(entry, prev.nextEntry());
Expect.identical(entry, next.previousEntry());
Expect.equals(null, next.nextEntry());

View file

@ -52,6 +52,7 @@ void main() {
if (m.group(1) != null) return "-";
if (m.group(2) != null) return "+";
if (m.group(3) != null) return "=";
throw 'Unexpected match $m';
});
assertEquals("= -. +, or + -. There is - =.", str);
@ -88,6 +89,7 @@ void main() {
if (m.group(1) != null) return "-";
if (m.group(2) != null) return "+";
if (m.group(3) != null) return "=";
throw 'Unexpected match $m';
});
assertEquals("= -. +, or + -. There is - =.", str);

View file

@ -5,7 +5,7 @@
library dart.test.symbol_map_helper;
// TODO(ahe): Update map literals to avoid this method.
Map<Symbol, dynamic> symbolMapToStringMap(Map<String, dynamic> map) {
Map<Symbol, dynamic>? symbolToStringMap(Map<String, dynamic> map) {
if (map == null) return null;
Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();
map.forEach((name, value) {

View file

@ -76,6 +76,6 @@ void testSymbolThrows(name) {
}
class Symbolize {
Symbol lastMember;
Symbol? lastMember;
noSuchMethod(m) => lastMember = m.memberName;
}