OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library subtype_test; | 5 library subtype_test; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 import 'type_test_helper.dart'; | 9 import 'type_test_helper.dart'; |
10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; |
(...skipping 19 matching lines...) Expand all Loading... |
30 m6(int a, [String b]) {} | 30 m6(int a, [String b]) {} |
31 m7(int a, String b, [List<int> c, d]) {} | 31 m7(int a, String b, [List<int> c, d]) {} |
32 m8(int a, {String b}) {} | 32 m8(int a, {String b}) {} |
33 m9(int a, String b, {List<int> c, d}) {} | 33 m9(int a, String b, {List<int> c, d}) {} |
34 m10(void f(int a, [b])) {} | 34 m10(void f(int a, [b])) {} |
35 """).then((env) { | 35 """).then((env) { |
36 TypeRepresentationGenerator typeRepresentation = | 36 TypeRepresentationGenerator typeRepresentation = |
37 new TypeRepresentationGenerator(env.compiler); | 37 new TypeRepresentationGenerator(env.compiler); |
38 | 38 |
39 Expression onVariable(TypeVariableType variable) { | 39 Expression onVariable(TypeVariableType variable) { |
40 return new VariableUse(variable.name.slowToString()); | 40 return new VariableUse(variable.name); |
41 } | 41 } |
42 | 42 |
43 String stringify(Expression expression) { | 43 String stringify(Expression expression) { |
44 return prettyPrint(expression, env.compiler).buffer.toString(); | 44 return prettyPrint(expression, env.compiler).buffer.toString(); |
45 } | 45 } |
46 | 46 |
47 void expect(String expectedRepresentation, DartType type) { | 47 void expect(String expectedRepresentation, DartType type) { |
48 Expression expression = | 48 Expression expression = |
49 typeRepresentation.getTypeRepresentation(type, onVariable); | 49 typeRepresentation.getTypeRepresentation(type, onVariable); |
50 Expect.stringEquals(expectedRepresentation, stringify(expression)); | 50 Expect.stringEquals(expectedRepresentation, stringify(expression)); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 // m10(void f(int a, [b])) {} | 157 // m10(void f(int a, [b])) {} |
158 expect('{$func: "dynamic__void__int__dynamic", $args:' | 158 expect('{$func: "dynamic__void__int__dynamic", $args:' |
159 ' [{$func: "void__int__dynamic",' | 159 ' [{$func: "void__int__dynamic",' |
160 ' $retvoid: true, $args: [$int_rep], $opt: [null]}]}', | 160 ' $retvoid: true, $args: [$int_rep], $opt: [null]}]}', |
161 env.getElement('m10').computeType(env.compiler)); | 161 env.getElement('m10').computeType(env.compiler)); |
162 })); | 162 })); |
163 } | 163 } |
164 | 164 |
165 | 165 |
OLD | NEW |