Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: tests/compiler/dart2js/type_substitution_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/type_representation_test.dart ('k') | tests/compiler/dart2js/type_test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_substitution_test.dart
diff --git a/tests/compiler/dart2js/type_substitution_test.dart b/tests/compiler/dart2js/type_substitution_test.dart
index c8040e5a33ea38321371b071c2d9fec83343ab39..0114b329559274822f03640f05e0b65cfa20a82c 100644
--- a/tests/compiler/dart2js/type_substitution_test.dart
+++ b/tests/compiler/dart2js/type_substitution_test.dart
@@ -48,51 +48,61 @@ void testAsInstanceOf() {
class E<T> extends A<A<T>> {}
class F<T, U> extends B<F<T, String>> implements A<F<B<U>, int>> {}
''').then((env) {
- var compiler = env.compiler;
-
- ClassElement A = env.getElement("A");
- ClassElement B = env.getElement("B");
- ClassElement C = env.getElement("C");
- ClassElement D = env.getElement("D");
- ClassElement E = env.getElement("E");
- ClassElement F = env.getElement("F");
-
- DartType numType = env['num'];
- DartType intType = env['int'];
- DartType stringType = env['String'];
-
- InterfaceType C_int = instantiate(C, [intType]);
- Expect.equals(instantiate(C, [intType]), C_int);
- Expect.equals(instantiate(A, [intType]), C_int.asInstanceOf(A));
-
- InterfaceType D_int = instantiate(D, [stringType]);
- Expect.equals(instantiate(A, [intType]), D_int.asInstanceOf(A));
-
- InterfaceType E_int = instantiate(E, [intType]);
- Expect.equals(instantiate(A, [instantiate(A, [intType])]),
- E_int.asInstanceOf(A));
-
- InterfaceType F_int_string = instantiate(F, [intType, stringType]);
- Expect.equals(instantiate(B, [instantiate(F, [intType, stringType])]),
- F_int_string.asInstanceOf(B));
- Expect.equals(instantiate(A, [instantiate(F, [instantiate(B, [stringType]),
- intType])]),
- F_int_string.asInstanceOf(A));
-
- }));
+ var compiler = env.compiler;
+
+ ClassElement A = env.getElement("A");
+ ClassElement B = env.getElement("B");
+ ClassElement C = env.getElement("C");
+ ClassElement D = env.getElement("D");
+ ClassElement E = env.getElement("E");
+ ClassElement F = env.getElement("F");
+
+ DartType numType = env['num'];
+ DartType intType = env['int'];
+ DartType stringType = env['String'];
+
+ InterfaceType C_int = instantiate(C, [intType]);
+ Expect.equals(instantiate(C, [intType]), C_int);
+ Expect.equals(instantiate(A, [intType]), C_int.asInstanceOf(A));
+
+ InterfaceType D_int = instantiate(D, [stringType]);
+ Expect.equals(instantiate(A, [intType]), D_int.asInstanceOf(A));
+
+ InterfaceType E_int = instantiate(E, [intType]);
+ Expect.equals(
+ instantiate(A, [
+ instantiate(A, [intType])
+ ]),
+ E_int.asInstanceOf(A));
+
+ InterfaceType F_int_string = instantiate(F, [intType, stringType]);
+ Expect.equals(
+ instantiate(B, [
+ instantiate(F, [intType, stringType])
+ ]),
+ F_int_string.asInstanceOf(B));
+ Expect.equals(
+ instantiate(A, [
+ instantiate(F, [
+ instantiate(B, [stringType]),
+ intType
+ ])
+ ]),
+ F_int_string.asInstanceOf(A));
+ }));
}
/**
* Test that substitution of [parameters] by [arguments] in the type found
* through [name1] is the same as the type found through [name2].
*/
-void testSubstitution(compiler, arguments, parameters,
- String name1, String name2) {
+void testSubstitution(
+ compiler, arguments, parameters, String name1, String name2) {
DartType type1 = getType(compiler, name1);
DartType type2 = getType(compiler, name2);
DartType subst = type1.subst(arguments, parameters);
- Expect.equals(type2, subst,
- "$type1.subst($arguments,$parameters)=$subst != $type2");
+ Expect.equals(
+ type2, subst, "$type1.subst($arguments,$parameters)=$subst != $type2");
}
void testTypeSubstitution() {
@@ -149,78 +159,92 @@ void testTypeSubstitution() {
void Typedef2e(Typedef2<String> b) {}
}
""").then((env) {
- var compiler = env.compiler;
-
- InterfaceType Class_T_S = env["Class"];
- Expect.isNotNull(Class_T_S);
- Expect.identical(Class_T_S.kind, TypeKind.INTERFACE);
- Expect.equals(2, Class_T_S.typeArguments.length);
-
- DartType T = Class_T_S.typeArguments[0];
- Expect.isNotNull(T);
- Expect.identical(T.kind, TypeKind.TYPE_VARIABLE);
-
- DartType S = Class_T_S.typeArguments[1];
- Expect.isNotNull(S);
- Expect.identical(S.kind, TypeKind.TYPE_VARIABLE);
-
- DartType intType = env['int'];//getType(compiler, "int1");
- Expect.isNotNull(intType);
- Expect.identical(intType.kind, TypeKind.INTERFACE);
-
- DartType StringType = env['String'];//getType(compiler, "String1");
- Expect.isNotNull(StringType);
- Expect.identical(StringType.kind, TypeKind.INTERFACE);
-
- List<DartType> parameters = <DartType>[T, S];
- List<DartType> arguments = <DartType>[intType, StringType];
-
- // TODO(johnniwinther): Create types directly from strings to improve test
- // readability.
-
- testSubstitution(compiler, arguments, parameters, "void1", "void2");
- testSubstitution(compiler, arguments, parameters, "dynamic1", "dynamic2");
- testSubstitution(compiler, arguments, parameters, "int1", "int2");
- testSubstitution(compiler, arguments, parameters, "String1", "String2");
- testSubstitution(compiler, arguments, parameters, "ListInt1", "ListInt2");
- testSubstitution(compiler, arguments, parameters, "ListT1", "ListT2");
- testSubstitution(compiler, arguments, parameters, "ListS1", "ListS2");
- testSubstitution(compiler, arguments, parameters, "ListListT1", "ListListT2");
- testSubstitution(compiler, arguments, parameters, "ListRaw1", "ListRaw2");
- testSubstitution(compiler, arguments, parameters,
- "ListDynamic1", "ListDynamic2");
- testSubstitution(compiler, arguments, parameters,
- "MapIntString1", "MapIntString2");
- testSubstitution(compiler, arguments, parameters,
- "MapTString1", "MapTString2");
- testSubstitution(compiler, arguments, parameters,
- "MapDynamicString1", "MapDynamicString2");
- testSubstitution(compiler, arguments, parameters, "TypeVarT1", "TypeVarT2");
- testSubstitution(compiler, arguments, parameters, "TypeVarS1", "TypeVarS2");
- testSubstitution(compiler, arguments, parameters, "Function1a", "Function2a");
- testSubstitution(compiler, arguments, parameters, "Function1b", "Function2b");
- testSubstitution(compiler, arguments, parameters, "Function1c", "Function2c");
- testSubstitution(compiler, arguments, parameters, "Typedef1a", "Typedef2a");
- testSubstitution(compiler, arguments, parameters, "Typedef1b", "Typedef2b");
- testSubstitution(compiler, arguments, parameters, "Typedef1c", "Typedef2c");
- testSubstitution(compiler, arguments, parameters, "Typedef1d", "Typedef2d");
- testSubstitution(compiler, arguments, parameters, "Typedef1e", "Typedef2e");
-
- // Substitution in unalias.
- DartType Typedef2_int_String = getType(compiler, "Typedef2a");
- Expect.isNotNull(Typedef2_int_String);
- DartType Function_int_String = getType(compiler, "Function2b");
- Expect.isNotNull(Function_int_String);
- DartType unalias1 = Typedef2_int_String.unaliased;
- Expect.equals(Function_int_String, unalias1,
- '$Typedef2_int_String.unalias=$unalias1 != $Function_int_String');
-
- DartType Typedef1 = getType(compiler, "Typedef1c");
- Expect.isNotNull(Typedef1);
- DartType Function_dynamic_dynamic = getType(compiler, "Function1c");
- Expect.isNotNull(Function_dynamic_dynamic);
- DartType unalias2 = Typedef1.unaliased;
- Expect.equals(Function_dynamic_dynamic, unalias2,
- '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic');
- }));
+ var compiler = env.compiler;
+
+ InterfaceType Class_T_S = env["Class"];
+ Expect.isNotNull(Class_T_S);
+ Expect.identical(Class_T_S.kind, TypeKind.INTERFACE);
+ Expect.equals(2, Class_T_S.typeArguments.length);
+
+ DartType T = Class_T_S.typeArguments[0];
+ Expect.isNotNull(T);
+ Expect.identical(T.kind, TypeKind.TYPE_VARIABLE);
+
+ DartType S = Class_T_S.typeArguments[1];
+ Expect.isNotNull(S);
+ Expect.identical(S.kind, TypeKind.TYPE_VARIABLE);
+
+ DartType intType = env['int']; //getType(compiler, "int1");
+ Expect.isNotNull(intType);
+ Expect.identical(intType.kind, TypeKind.INTERFACE);
+
+ DartType StringType = env['String']; //getType(compiler, "String1");
+ Expect.isNotNull(StringType);
+ Expect.identical(StringType.kind, TypeKind.INTERFACE);
+
+ List<DartType> parameters = <DartType>[T, S];
+ List<DartType> arguments = <DartType>[intType, StringType];
+
+ // TODO(johnniwinther): Create types directly from strings to improve test
+ // readability.
+
+ testSubstitution(compiler, arguments, parameters, "void1", "void2");
+ testSubstitution(
+ compiler, arguments, parameters, "dynamic1", "dynamic2");
+ testSubstitution(compiler, arguments, parameters, "int1", "int2");
+ testSubstitution(compiler, arguments, parameters, "String1", "String2");
+ testSubstitution(
+ compiler, arguments, parameters, "ListInt1", "ListInt2");
+ testSubstitution(compiler, arguments, parameters, "ListT1", "ListT2");
+ testSubstitution(compiler, arguments, parameters, "ListS1", "ListS2");
+ testSubstitution(
+ compiler, arguments, parameters, "ListListT1", "ListListT2");
+ testSubstitution(
+ compiler, arguments, parameters, "ListRaw1", "ListRaw2");
+ testSubstitution(
+ compiler, arguments, parameters, "ListDynamic1", "ListDynamic2");
+ testSubstitution(
+ compiler, arguments, parameters, "MapIntString1", "MapIntString2");
+ testSubstitution(
+ compiler, arguments, parameters, "MapTString1", "MapTString2");
+ testSubstitution(compiler, arguments, parameters, "MapDynamicString1",
+ "MapDynamicString2");
+ testSubstitution(
+ compiler, arguments, parameters, "TypeVarT1", "TypeVarT2");
+ testSubstitution(
+ compiler, arguments, parameters, "TypeVarS1", "TypeVarS2");
+ testSubstitution(
+ compiler, arguments, parameters, "Function1a", "Function2a");
+ testSubstitution(
+ compiler, arguments, parameters, "Function1b", "Function2b");
+ testSubstitution(
+ compiler, arguments, parameters, "Function1c", "Function2c");
+ testSubstitution(
+ compiler, arguments, parameters, "Typedef1a", "Typedef2a");
+ testSubstitution(
+ compiler, arguments, parameters, "Typedef1b", "Typedef2b");
+ testSubstitution(
+ compiler, arguments, parameters, "Typedef1c", "Typedef2c");
+ testSubstitution(
+ compiler, arguments, parameters, "Typedef1d", "Typedef2d");
+ testSubstitution(
+ compiler, arguments, parameters, "Typedef1e", "Typedef2e");
+
+ // Substitution in unalias.
+ DartType Typedef2_int_String = getType(compiler, "Typedef2a");
+ Expect.isNotNull(Typedef2_int_String);
+ DartType Function_int_String = getType(compiler, "Function2b");
+ Expect.isNotNull(Function_int_String);
+ DartType unalias1 = Typedef2_int_String.unaliased;
+ Expect.equals(Function_int_String, unalias1,
+ '$Typedef2_int_String.unalias=$unalias1 != $Function_int_String');
+
+ DartType Typedef1 = getType(compiler, "Typedef1c");
+ Expect.isNotNull(Typedef1);
+ DartType Function_dynamic_dynamic = getType(compiler, "Function1c");
+ Expect.isNotNull(Function_dynamic_dynamic);
+ DartType unalias2 = Typedef1.unaliased;
+ Expect.equals(Function_dynamic_dynamic, unalias2,
+ '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic');
+ }));
}
« no previous file with comments | « tests/compiler/dart2js/type_representation_test.dart ('k') | tests/compiler/dart2js/type_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698