| 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 type_test_helper; | 5 library type_test_helper; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; |
| 9 import "parser_helper.dart" show SourceString; | 9 import "parser_helper.dart" show SourceString; |
| 10 import "compiler_helper.dart"; | 10 import "compiler_helper.dart"; |
| 11 | 11 |
| 12 GenericType instantiate(TypeDeclarationElement element, | 12 GenericType instantiate(TypeDeclarationElement element, |
| 13 List<DartType> arguments) { | 13 List<DartType> arguments) { |
| 14 if (element.isClass()) { | 14 if (element.isClass()) { |
| 15 return new InterfaceType(element, new Link<DartType>.fromList(arguments)); | 15 return new InterfaceType(element, new Link<DartType>.fromList(arguments)); |
| 16 } else { | 16 } else { |
| 17 assert(element.isTypedef()); | 17 assert(element.isTypedef()); |
| 18 return new TypedefType(element, new Link<DartType>.fromList(arguments)); | 18 return new TypedefType(element, new Link<DartType>.fromList(arguments)); |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 class TypeEnvironment { | 22 class TypeEnvironment { |
| 23 final MockCompiler compiler; | 23 final MockCompiler compiler; |
| 24 | 24 |
| 25 factory TypeEnvironment(String source) { | 25 factory TypeEnvironment(String source) { |
| 26 var uri = new Uri.fromComponents(scheme: 'source'); | 26 var uri = new Uri(scheme: 'source'); |
| 27 MockCompiler compiler = compilerFor(''' | 27 MockCompiler compiler = compilerFor(''' |
| 28 main() {} | 28 main() {} |
| 29 $source''', | 29 $source''', |
| 30 uri, | 30 uri, |
| 31 analyzeAll: true, | 31 analyzeAll: true, |
| 32 analyzeOnly: true); | 32 analyzeOnly: true); |
| 33 compiler.runCompiler(uri); | 33 compiler.runCompiler(uri); |
| 34 return new TypeEnvironment._(compiler); | 34 return new TypeEnvironment._(compiler); |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 namedParameterNames.addLast(sourceString(name)); | 83 namedParameterNames.addLast(sourceString(name)); |
| 84 namedParameterTypes.addLast(type); | 84 namedParameterTypes.addLast(type); |
| 85 }); | 85 }); |
| 86 } | 86 } |
| 87 FunctionType type = new FunctionType( | 87 FunctionType type = new FunctionType( |
| 88 compiler.functionClass, | 88 compiler.functionClass, |
| 89 returnType, parameterTypes, optionalParameterTypes, | 89 returnType, parameterTypes, optionalParameterTypes, |
| 90 namedParameterNames.toLink(), namedParameterTypes.toLink()); | 90 namedParameterNames.toLink(), namedParameterTypes.toLink()); |
| 91 } | 91 } |
| 92 } | 92 } |
| OLD | NEW |