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 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 import 'compiler_helper.dart' as mock; | 9 import 'compiler_helper.dart' as mock; |
10 import 'memory_compiler.dart' as memory; | 10 import 'memory_compiler.dart' as memory; |
| 11 import 'package:compiler/src/commandline_options.dart'; |
11 import 'package:compiler/src/dart_types.dart'; | 12 import 'package:compiler/src/dart_types.dart'; |
12 import 'package:compiler/src/compiler.dart' | 13 import 'package:compiler/src/compiler.dart' |
13 show Compiler; | 14 show Compiler; |
14 import 'package:compiler/src/elements/elements.dart' | 15 import 'package:compiler/src/elements/elements.dart' |
15 show Element, | 16 show Element, |
16 TypeDeclarationElement, | 17 TypeDeclarationElement, |
17 ClassElement; | 18 ClassElement; |
18 | 19 |
19 GenericType instantiate(TypeDeclarationElement element, | 20 GenericType instantiate(TypeDeclarationElement element, |
20 List<DartType> arguments) { | 21 List<DartType> arguments) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 getErrors = () => mockCompiler.errors; | 59 getErrors = () => mockCompiler.errors; |
59 getWarnings = () => mockCompiler.warnings; | 60 getWarnings = () => mockCompiler.warnings; |
60 compiler = mockCompiler; | 61 compiler = mockCompiler; |
61 } else { | 62 } else { |
62 memory.DiagnosticCollector collector = new memory.DiagnosticCollector(); | 63 memory.DiagnosticCollector collector = new memory.DiagnosticCollector(); |
63 uri = Uri.parse('memory:main.dart'); | 64 uri = Uri.parse('memory:main.dart'); |
64 compiler = memory.compilerFor( | 65 compiler = memory.compilerFor( |
65 memorySourceFiles: {'main.dart': source}, | 66 memorySourceFiles: {'main.dart': source}, |
66 diagnosticHandler: collector, | 67 diagnosticHandler: collector, |
67 options: stopAfterTypeInference | 68 options: stopAfterTypeInference |
68 ? [] : ['--analyze-all', '--analyze-only']); | 69 ? [] : [Flags.analyzeAll, Flags.analyzeOnly]); |
69 getErrors = () => collector.errors; | 70 getErrors = () => collector.errors; |
70 getWarnings = () => collector.warnings; | 71 getWarnings = () => collector.warnings; |
71 } | 72 } |
72 compiler.stopAfterTypeInference = stopAfterTypeInference; | 73 compiler.stopAfterTypeInference = stopAfterTypeInference; |
73 return compiler.runCompiler(uri).then((_) { | 74 return compiler.runCompiler(uri).then((_) { |
74 if (expectNoErrors || expectNoWarningsOrErrors) { | 75 if (expectNoErrors || expectNoWarningsOrErrors) { |
75 var errors = getErrors(); | 76 var errors = getErrors(); |
76 Expect.isTrue(errors.isEmpty, | 77 Expect.isTrue(errors.isEmpty, |
77 'Unexpected errors: ${errors}'); | 78 'Unexpected errors: ${errors}'); |
78 } | 79 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 namedParameters.forEach((String name, DartType type) { | 141 namedParameters.forEach((String name, DartType type) { |
141 namedParameterNames.add(name); | 142 namedParameterNames.add(name); |
142 namedParameterTypes.add(type); | 143 namedParameterTypes.add(type); |
143 }); | 144 }); |
144 } | 145 } |
145 return new FunctionType.synthesized( | 146 return new FunctionType.synthesized( |
146 returnType, parameters, optionalParameters, | 147 returnType, parameters, optionalParameters, |
147 namedParameterNames, namedParameterTypes); | 148 namedParameterNames, namedParameterTypes); |
148 } | 149 } |
149 } | 150 } |
OLD | NEW |