diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status index d6403c52d7b..8b8e3c95869 100644 --- a/tests/language_2/language_2_dart2js.status +++ b/tests/language_2/language_2_dart2js.status @@ -201,7 +201,7 @@ tearoff_dynamic_test: RuntimeError truncdiv_test: RuntimeError # non JS number semantics - Issue 15246 type_constants_test/none: RuntimeError # Issue 35052 type_error_test: RuntimeError -type_literal_test: RuntimeError +type_literal_canonicalization_test: RuntimeError type_promotion_more_specific_test/04: CompileTimeError vm/*: SkipByDesign # Tests for the VM. @@ -498,7 +498,7 @@ symbol_literal_test/01: MissingCompileTimeError tearoff_dynamic_test: RuntimeError truncdiv_test: RuntimeError # non JS number semantics - Issue 15246 type_check_const_function_typedef2_test: MissingCompileTimeError -type_literal_test: RuntimeError +type_literal_canonicalization_test: RuntimeError type_parameter_test/06: Crash # Internal Error: Unexpected type variable in static context. type_parameter_test/09: Crash # Internal Error: Unexpected type variable in static context. type_variable_scope_test/03: Crash # Internal Error: Unexpected type variable in static context. diff --git a/tests/language_2/type_literal_canonicalization_test.dart b/tests/language_2/type_literal_canonicalization_test.dart new file mode 100644 index 00000000000..790f1b6e966 --- /dev/null +++ b/tests/language_2/type_literal_canonicalization_test.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2019, 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"; + +class Foo {} + +class Box { + Type get typeArg => T; +} + +/// A typedef that defines a non-generic function type. +typedef int Func1(bool b); + +/// Semantically identical to [Func], but using the Dart 2 syntax. +typedef Func2 = int Function(bool); + +main() { + // Literals are canonicalized. + Expect.identical(Foo, Foo); + Expect.identical(Box, Box); + Expect.identical(new Box().typeArg, new Box().typeArg); + Expect.identical(Func1, Func1); + Expect.identical(Func2, Func2); +} diff --git a/tests/language_2/type_literal_test.dart b/tests/language_2/type_literal_test.dart index c21c95a1254..6f022ecf796 100644 --- a/tests/language_2/type_literal_test.dart +++ b/tests/language_2/type_literal_test.dart @@ -69,18 +69,16 @@ main() { ["GenericTypedef2", "GenericTypedef2", "(dynamic) => int"]); testType(new Box>().typeArg, ["GenericTypedef", "(int) => int"]); - testType(GenericFunc, ["GenericFunc", "(T) => int"]); + testType(GenericFunc, ["GenericFunc", "(T) => int", "(T1) => int"]); testType(GenericTypedefAndFunc, [ "GenericTypedefAndFunc", "GenericTypedefAndFunc", - "(T) => dynamic" + "(T) => dynamic", + "(T1) => dynamic", ]); // Literals are canonicalized. - Expect.identical(Foo, Foo); - Expect.identical(Box, Box); - Expect.identical(new Box().typeArg, new Box().typeArg); - Expect.identical(Func, Func); + // See type_literal_canonicalization_test.dart // Static member uses are not type literals. Foo.property = "value"; @@ -97,13 +95,19 @@ main() { } void testType(Type type, Object expectedToStringValues) { + Expect.isTrue(type is Type); + String text = type.toString(); + + // dart2js minified names should be tagged. We can still test types that don't + // contains minified names. + if (text.contains('minified:')) return; + if (expectedToStringValues is List) { var s = type.toString(); - Expect.isTrue(expectedToStringValues.contains(s), + Expect.isTrue(expectedToStringValues.contains(text), 'type `$type`.toString() should be one of: $expectedToStringValues.'); } else { var string = expectedToStringValues as String; - Expect.equals(string, type.toString()); + Expect.equals(string, text); } - Expect.isTrue(type is Type); }