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

Unified Diff: tests/compiler/dart2js/type_representation_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_promotion_test.dart ('k') | tests/compiler/dart2js/type_substitution_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_representation_test.dart
diff --git a/tests/compiler/dart2js/type_representation_test.dart b/tests/compiler/dart2js/type_representation_test.dart
index ce4f3c857778ddd00f669334c0e3c06e2d38f46a..2b16579f390cd3389c905bf02999cbb9813bac32 100644
--- a/tests/compiler/dart2js/type_representation_test.dart
+++ b/tests/compiler/dart2js/type_representation_test.dart
@@ -9,10 +9,9 @@ import "package:async_helper/async_helper.dart";
import 'type_test_helper.dart';
import 'package:compiler/src/dart_types.dart';
import 'package:compiler/src/js/js.dart';
-import 'package:compiler/src/elements/elements.dart'
- show Element, ClassElement;
+import 'package:compiler/src/elements/elements.dart' show Element, ClassElement;
import 'package:compiler/src/js_backend/js_backend.dart'
- show JavaScriptBackend, TypeRepresentationGenerator;
+ show JavaScriptBackend, TypeRepresentationGenerator;
void main() {
testTypeRepresentations();
@@ -42,216 +41,226 @@ void testTypeRepresentations() {
m9(int a, String b, {List<int> c, d}) {}
m10(void f(int a, [b])) {}
""").then((env) {
- TypeRepresentationGenerator typeRepresentation =
- new TypeRepresentationGenerator(env.compiler);
+ TypeRepresentationGenerator typeRepresentation =
+ new TypeRepresentationGenerator(env.compiler);
- Expression onVariable(TypeVariableType variable) {
- return new VariableUse(variable.name);
- }
+ Expression onVariable(TypeVariableType variable) {
+ return new VariableUse(variable.name);
+ }
- String stringify(Expression expression) {
- return prettyPrint(expression, env.compiler);
- }
+ String stringify(Expression expression) {
+ return prettyPrint(expression, env.compiler);
+ }
- void expect(DartType type,
- String expectedRepresentation,
- [String expectedTypedefRepresentation]) {
- bool encodeTypedefName = false;
- Expression expression =
- typeRepresentation.getTypeRepresentation(type, onVariable,
- (x) => encodeTypedefName);
- Expect.stringEquals(expectedRepresentation, stringify(expression));
+ void expect(DartType type, String expectedRepresentation,
+ [String expectedTypedefRepresentation]) {
+ bool encodeTypedefName = false;
+ Expression expression = typeRepresentation.getTypeRepresentation(
+ type, onVariable, (x) => encodeTypedefName);
+ Expect.stringEquals(expectedRepresentation, stringify(expression));
- encodeTypedefName = true;
- expression =
- typeRepresentation.getTypeRepresentation(type, onVariable,
- (x) => encodeTypedefName);
- if (expectedTypedefRepresentation == null) {
- expectedTypedefRepresentation = expectedRepresentation;
- }
- Expect.stringEquals(expectedTypedefRepresentation, stringify(expression));
- }
+ encodeTypedefName = true;
+ expression = typeRepresentation.getTypeRepresentation(
+ type, onVariable, (x) => encodeTypedefName);
+ if (expectedTypedefRepresentation == null) {
+ expectedTypedefRepresentation = expectedRepresentation;
+ }
+ Expect.stringEquals(
+ expectedTypedefRepresentation, stringify(expression));
+ }
- String getJsName(Element cls) {
- Expression name = typeRepresentation.getJavaScriptClassName(cls);
- return stringify(name);
- }
+ String getJsName(Element cls) {
+ Expression name = typeRepresentation.getJavaScriptClassName(cls);
+ return stringify(name);
+ }
- JavaScriptBackend backend = env.compiler.backend;
- String func = backend.namer.functionTypeTag;
- String retvoid = backend.namer.functionTypeVoidReturnTag;
- String ret = backend.namer.functionTypeReturnTypeTag;
- String args = backend.namer.functionTypeRequiredParametersTag;
- String opt = backend.namer.functionTypeOptionalParametersTag;
- String named = backend.namer.functionTypeNamedParametersTag;
- String typedefTag = backend.namer.typedefTag;
+ JavaScriptBackend backend = env.compiler.backend;
+ String func = backend.namer.functionTypeTag;
+ String retvoid = backend.namer.functionTypeVoidReturnTag;
+ String ret = backend.namer.functionTypeReturnTypeTag;
+ String args = backend.namer.functionTypeRequiredParametersTag;
+ String opt = backend.namer.functionTypeOptionalParametersTag;
+ String named = backend.namer.functionTypeNamedParametersTag;
+ String typedefTag = backend.namer.typedefTag;
- ClassElement List_ = env.getElement('List');
- TypeVariableType List_E = List_.typeVariables[0];
- ClassElement Map_ = env.getElement('Map');
- TypeVariableType Map_K = Map_.typeVariables[0];
- TypeVariableType Map_V = Map_.typeVariables[1];
+ ClassElement List_ = env.getElement('List');
+ TypeVariableType List_E = List_.typeVariables[0];
+ ClassElement Map_ = env.getElement('Map');
+ TypeVariableType Map_K = Map_.typeVariables[0];
+ TypeVariableType Map_V = Map_.typeVariables[1];
- DartType Object_ = env['Object'];
- DartType int_ = env['int'];
- DartType String_ = env['String'];
- DartType dynamic_ = env['dynamic'];
- DartType Typedef_ = env['Typedef'];
- DartType Typedef2_ = env['Typedef2'];
- DartType Typedef3_ = env['Typedef3'];
- DartType Typedef4_ = env['Typedef4'];
- DartType Typedef5_ = env['Typedef5'];
- DartType Typedef6_ = env['Typedef6'];
- DartType Typedef7_ = env['Typedef7'];
- DartType Typedef8_ = env['Typedef8'];
- DartType Typedef9_ = env['Typedef9'];
- DartType Typedef10_ = env['Typedef10'];
+ DartType Object_ = env['Object'];
+ DartType int_ = env['int'];
+ DartType String_ = env['String'];
+ DartType dynamic_ = env['dynamic'];
+ DartType Typedef_ = env['Typedef'];
+ DartType Typedef2_ = env['Typedef2'];
+ DartType Typedef3_ = env['Typedef3'];
+ DartType Typedef4_ = env['Typedef4'];
+ DartType Typedef5_ = env['Typedef5'];
+ DartType Typedef6_ = env['Typedef6'];
+ DartType Typedef7_ = env['Typedef7'];
+ DartType Typedef8_ = env['Typedef8'];
+ DartType Typedef9_ = env['Typedef9'];
+ DartType Typedef10_ = env['Typedef10'];
- String List_rep = getJsName(List_);
- String List_E_rep = stringify(onVariable(List_E));
- String Map_rep = getJsName(Map_);
- String Map_K_rep = stringify(onVariable(Map_K));
- String Map_V_rep = stringify(onVariable(Map_V));
+ String List_rep = getJsName(List_);
+ String List_E_rep = stringify(onVariable(List_E));
+ String Map_rep = getJsName(Map_);
+ String Map_K_rep = stringify(onVariable(Map_K));
+ String Map_V_rep = stringify(onVariable(Map_V));
- String Object_rep = getJsName(Object_.element);
- String int_rep = getJsName(int_.element);
- String String_rep = getJsName(String_.element);
+ String Object_rep = getJsName(Object_.element);
+ String int_rep = getJsName(int_.element);
+ String String_rep = getJsName(String_.element);
- String Typedef_rep = getJsName(Typedef_.element);
- String Typedef2_rep = getJsName(Typedef2_.element);
- String Typedef3_rep = getJsName(Typedef3_.element);
- String Typedef4_rep = getJsName(Typedef4_.element);
- String Typedef5_rep = getJsName(Typedef5_.element);
- String Typedef6_rep = getJsName(Typedef6_.element);
- String Typedef7_rep = getJsName(Typedef7_.element);
- String Typedef8_rep = getJsName(Typedef8_.element);
- String Typedef9_rep = getJsName(Typedef9_.element);
- String Typedef10_rep = getJsName(Typedef10_.element);
+ String Typedef_rep = getJsName(Typedef_.element);
+ String Typedef2_rep = getJsName(Typedef2_.element);
+ String Typedef3_rep = getJsName(Typedef3_.element);
+ String Typedef4_rep = getJsName(Typedef4_.element);
+ String Typedef5_rep = getJsName(Typedef5_.element);
+ String Typedef6_rep = getJsName(Typedef6_.element);
+ String Typedef7_rep = getJsName(Typedef7_.element);
+ String Typedef8_rep = getJsName(Typedef8_.element);
+ String Typedef9_rep = getJsName(Typedef9_.element);
+ String Typedef10_rep = getJsName(Typedef10_.element);
- expect(int_, '$int_rep');
- expect(String_, '$String_rep');
- expect(dynamic_, 'null');
+ expect(int_, '$int_rep');
+ expect(String_, '$String_rep');
+ expect(dynamic_, 'null');
- // List<E>
- expect(List_.computeType(env.compiler.resolution),
- '[$List_rep, $List_E_rep]');
- // List
- expect(List_.rawType, '$List_rep');
- // List<dynamic>
- expect(instantiate(List_, [dynamic_]), '$List_rep');
- // List<int>
- expect(instantiate(List_, [int_]), '[$List_rep, $int_rep]');
- // List<Typedef>
- expect(instantiate(List_, [Typedef_]),
- '[$List_rep, {$func: 1, $retvoid: true}]',
- '[$List_rep, {$func: 1, $retvoid: true,'
- ' $typedefTag: $Typedef_rep}]');
- expect(instantiate(List_, [Typedef2_]),
- '[$List_rep, {$func: 1, $ret: $int_rep}]',
- '[$List_rep, {$func: 1, $ret: $int_rep,'
- ' $typedefTag: $Typedef2_rep}]');
- expect(instantiate(List_, [Typedef3_]),
- '[$List_rep, {$func: 1, $ret: [$List_rep, $int_rep]}]',
- '[$List_rep, {$func: 1, $ret: [$List_rep, $int_rep],'
- ' $typedefTag: $Typedef3_rep}]');
- expect(instantiate(List_, [Typedef4_]),
- '[$List_rep, {$func: 1}]',
- '[$List_rep, {$func: 1, $typedefTag: $Typedef4_rep}]');
- expect(instantiate(List_, [Typedef5_]),
- '[$List_rep, {$func: 1,'
- ' $args: [$int_rep, $String_rep]}]',
- '[$List_rep, {$func: 1,'
- ' $args: [$int_rep, $String_rep], $typedefTag: $Typedef5_rep}]');
- expect(instantiate(List_, [Typedef6_]),
- '[$List_rep, {$func: 1,'
- ' $args: [$int_rep], $opt: [$String_rep]}]',
- '[$List_rep, {$func: 1,'
- ' $args: [$int_rep], $opt: [$String_rep],'
- ' $typedefTag: $Typedef6_rep}]');
- expect(instantiate(List_, [Typedef7_]),
- '[$List_rep, {$func: 1, $args: '
- '[$int_rep, $String_rep], $opt: [[$List_rep, $int_rep],,]}]',
- '[$List_rep, {$func: 1, $args: '
- '[$int_rep, $String_rep], $opt: [[$List_rep, $int_rep],,], '
- '$typedefTag: $Typedef7_rep}]');
- expect(instantiate(List_, [Typedef8_]),
- '[$List_rep, {$func: 1, $args: [$int_rep],'
- ' $named: {b: $String_rep}}]',
- '[$List_rep, {$func: 1, $args: [$int_rep],'
- ' $named: {b: $String_rep}, $typedefTag: $Typedef8_rep}]');
- expect(instantiate(List_, [Typedef9_]),
- '[$List_rep, {$func: 1, '
- '$args: [$int_rep, $String_rep], $named: '
- '{c: [$List_rep, $int_rep], d: null}}]',
- '[$List_rep, {$func: 1, '
- '$args: [$int_rep, $String_rep], $named: {c: [$List_rep, $int_rep],'
- ' d: null}, $typedefTag: $Typedef9_rep}]');
- expect(instantiate(List_, [Typedef10_]),
- '[$List_rep, {$func: 1, '
- '$args: [{$func: 1, $retvoid: true, '
- '$args: [$int_rep], $opt: [,]}]}]',
- '[$List_rep, {$func: 1, '
- '$args: [{$func: 1, $retvoid: true, '
- '$args: [$int_rep], $opt: [,]}], $typedefTag: $Typedef10_rep}]');
+ // List<E>
+ expect(List_.computeType(env.compiler.resolution),
+ '[$List_rep, $List_E_rep]');
+ // List
+ expect(List_.rawType, '$List_rep');
+ // List<dynamic>
+ expect(instantiate(List_, [dynamic_]), '$List_rep');
+ // List<int>
+ expect(instantiate(List_, [int_]), '[$List_rep, $int_rep]');
+ // List<Typedef>
+ expect(
+ instantiate(List_, [Typedef_]),
+ '[$List_rep, {$func: 1, $retvoid: true}]',
+ '[$List_rep, {$func: 1, $retvoid: true,'
+ ' $typedefTag: $Typedef_rep}]');
+ expect(
+ instantiate(List_, [Typedef2_]),
+ '[$List_rep, {$func: 1, $ret: $int_rep}]',
+ '[$List_rep, {$func: 1, $ret: $int_rep,'
+ ' $typedefTag: $Typedef2_rep}]');
+ expect(
+ instantiate(List_, [Typedef3_]),
+ '[$List_rep, {$func: 1, $ret: [$List_rep, $int_rep]}]',
+ '[$List_rep, {$func: 1, $ret: [$List_rep, $int_rep],'
+ ' $typedefTag: $Typedef3_rep}]');
+ expect(instantiate(List_, [Typedef4_]), '[$List_rep, {$func: 1}]',
+ '[$List_rep, {$func: 1, $typedefTag: $Typedef4_rep}]');
+ expect(
+ instantiate(List_, [Typedef5_]),
+ '[$List_rep, {$func: 1,'
+ ' $args: [$int_rep, $String_rep]}]',
+ '[$List_rep, {$func: 1,'
+ ' $args: [$int_rep, $String_rep], $typedefTag: $Typedef5_rep}]');
+ expect(
+ instantiate(List_, [Typedef6_]),
+ '[$List_rep, {$func: 1,'
+ ' $args: [$int_rep], $opt: [$String_rep]}]',
+ '[$List_rep, {$func: 1,'
+ ' $args: [$int_rep], $opt: [$String_rep],'
+ ' $typedefTag: $Typedef6_rep}]');
+ expect(
+ instantiate(List_, [Typedef7_]),
+ '[$List_rep, {$func: 1, $args: '
+ '[$int_rep, $String_rep], $opt: [[$List_rep, $int_rep],,]}]',
+ '[$List_rep, {$func: 1, $args: '
+ '[$int_rep, $String_rep], $opt: [[$List_rep, $int_rep],,], '
+ '$typedefTag: $Typedef7_rep}]');
+ expect(
+ instantiate(List_, [Typedef8_]),
+ '[$List_rep, {$func: 1, $args: [$int_rep],'
+ ' $named: {b: $String_rep}}]',
+ '[$List_rep, {$func: 1, $args: [$int_rep],'
+ ' $named: {b: $String_rep}, $typedefTag: $Typedef8_rep}]');
+ expect(
+ instantiate(List_, [Typedef9_]),
+ '[$List_rep, {$func: 1, '
+ '$args: [$int_rep, $String_rep], $named: '
+ '{c: [$List_rep, $int_rep], d: null}}]',
+ '[$List_rep, {$func: 1, '
+ '$args: [$int_rep, $String_rep], $named: {c: [$List_rep, $int_rep],'
+ ' d: null}, $typedefTag: $Typedef9_rep}]');
+ expect(
+ instantiate(List_, [Typedef10_]),
+ '[$List_rep, {$func: 1, '
+ '$args: [{$func: 1, $retvoid: true, '
+ '$args: [$int_rep], $opt: [,]}]}]',
+ '[$List_rep, {$func: 1, '
+ '$args: [{$func: 1, $retvoid: true, '
+ '$args: [$int_rep], $opt: [,]}], $typedefTag: $Typedef10_rep}]');
- // Map<K,V>
- expect(Map_.computeType(env.compiler.resolution),
- '[$Map_rep, $Map_K_rep, $Map_V_rep]');
- // Map
- expect(Map_.rawType, '$Map_rep');
- // Map<dynamic,dynamic>
- expect(instantiate(Map_, [dynamic_, dynamic_]), '$Map_rep');
- // Map<int,String>
- expect(instantiate(Map_, [int_, String_]),
- '[$Map_rep, $int_rep, $String_rep]');
+ // Map<K,V>
+ expect(Map_.computeType(env.compiler.resolution),
+ '[$Map_rep, $Map_K_rep, $Map_V_rep]');
+ // Map
+ expect(Map_.rawType, '$Map_rep');
+ // Map<dynamic,dynamic>
+ expect(instantiate(Map_, [dynamic_, dynamic_]), '$Map_rep');
+ // Map<int,String>
+ expect(instantiate(Map_, [int_, String_]),
+ '[$Map_rep, $int_rep, $String_rep]');
+ // void m1() {}
+ expect(env.getElement('m1').computeType(env.compiler.resolution),
+ '{$func: 1, $retvoid: true}');
- // void m1() {}
- expect(env.getElement('m1').computeType(env.compiler.resolution),
- '{$func: 1, $retvoid: true}');
+ // int m2() => 0;
+ expect(env.getElement('m2').computeType(env.compiler.resolution),
+ '{$func: 1, $ret: $int_rep}');
- // int m2() => 0;
- expect(env.getElement('m2').computeType(env.compiler.resolution),
- '{$func: 1, $ret: $int_rep}');
+ // List<int> m3() => null;
+ expect(env.getElement('m3').computeType(env.compiler.resolution),
+ '{$func: 1, $ret: [$List_rep, $int_rep]}');
- // List<int> m3() => null;
- expect(env.getElement('m3').computeType(env.compiler.resolution),
- '{$func: 1, $ret: [$List_rep, $int_rep]}');
+ // m4() {}
+ expect(env.getElement('m4').computeType(env.compiler.resolution),
+ '{$func: 1}');
- // m4() {}
- expect(env.getElement('m4').computeType(env.compiler.resolution),
- '{$func: 1}');
+ // m5(int a, String b) {}
+ expect(env.getElement('m5').computeType(env.compiler.resolution),
+ '{$func: 1, $args: [$int_rep, $String_rep]}');
- // m5(int a, String b) {}
- expect(env.getElement('m5').computeType(env.compiler.resolution),
- '{$func: 1, $args: [$int_rep, $String_rep]}');
+ // m6(int a, [String b]) {}
+ expect(
+ env.getElement('m6').computeType(env.compiler.resolution),
+ '{$func: 1, $args: [$int_rep],'
+ ' $opt: [$String_rep]}');
- // m6(int a, [String b]) {}
- expect(env.getElement('m6').computeType(env.compiler.resolution),
- '{$func: 1, $args: [$int_rep],'
- ' $opt: [$String_rep]}');
+ // m7(int a, String b, [List<int> c, d]) {}
+ expect(
+ env.getElement('m7').computeType(env.compiler.resolution),
+ '{$func: 1,'
+ ' $args: [$int_rep, $String_rep],'
+ ' $opt: [[$List_rep, $int_rep],,]}');
- // m7(int a, String b, [List<int> c, d]) {}
- expect(env.getElement('m7').computeType(env.compiler.resolution),
- '{$func: 1,'
- ' $args: [$int_rep, $String_rep],'
- ' $opt: [[$List_rep, $int_rep],,]}');
+ // m8(int a, {String b}) {}
+ expect(
+ env.getElement('m8').computeType(env.compiler.resolution),
+ '{$func: 1,'
+ ' $args: [$int_rep], $named: {b: $String_rep}}');
- // m8(int a, {String b}) {}
- expect(env.getElement('m8').computeType(env.compiler.resolution),
- '{$func: 1,'
- ' $args: [$int_rep], $named: {b: $String_rep}}');
+ // m9(int a, String b, {List<int> c, d}) {}
+ expect(
+ env.getElement('m9').computeType(env.compiler.resolution),
+ '{$func: 1,'
+ ' $args: [$int_rep, $String_rep],'
+ ' $named: {c: [$List_rep, $int_rep], d: null}}');
- // m9(int a, String b, {List<int> c, d}) {}
- expect(env.getElement('m9').computeType(env.compiler.resolution),
- '{$func: 1,'
- ' $args: [$int_rep, $String_rep],'
- ' $named: {c: [$List_rep, $int_rep], d: null}}');
-
- // m10(void f(int a, [b])) {}
- expect(env.getElement('m10').computeType(env.compiler.resolution),
- '{$func: 1, $args:'
- ' [{$func: 1,'
- ' $retvoid: true, $args: [$int_rep], $opt: [,]}]}');
- }));
+ // m10(void f(int a, [b])) {}
+ expect(
+ env.getElement('m10').computeType(env.compiler.resolution),
+ '{$func: 1, $args:'
+ ' [{$func: 1,'
+ ' $retvoid: true, $args: [$int_rep], $opt: [,]}]}');
+ }));
}
« no previous file with comments | « tests/compiler/dart2js/type_promotion_test.dart ('k') | tests/compiler/dart2js/type_substitution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698