| Index: tests/compiler/dart2js/type_test_helper.dart
|
| diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
|
| index b64cecbe782b8b13c2fd8976cf03222cf149a004..01e8c16fad5869ffd0075d015e758555509aa74a 100644
|
| --- a/tests/compiler/dart2js/type_test_helper.dart
|
| +++ b/tests/compiler/dart2js/type_test_helper.dart
|
| @@ -5,18 +5,9 @@
|
| library type_test_helper;
|
|
|
| import 'dart:async';
|
| -import 'package:expect/expect.dart';
|
| -import 'compiler_helper.dart' as mock;
|
| -import 'memory_compiler.dart' as memory;
|
| +import "package:expect/expect.dart";
|
| import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
|
| -import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
|
| - show Compiler;
|
| -import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart'
|
| - show Element,
|
| - TypeDeclarationElement,
|
| - ClassElement;
|
| -import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'
|
| - show Link, LinkBuilder;
|
| +import "compiler_helper.dart";
|
|
|
| GenericType instantiate(TypeDeclarationElement element,
|
| List<DartType> arguments) {
|
| @@ -29,56 +20,35 @@ GenericType instantiate(TypeDeclarationElement element,
|
| }
|
|
|
| class TypeEnvironment {
|
| - final Compiler compiler;
|
| + final MockCompiler compiler;
|
|
|
| static Future<TypeEnvironment> create(
|
| - String source, {bool useMockCompiler: true,
|
| - bool expectNoErrors: false,
|
| + String source, {bool expectNoErrors: false,
|
| bool expectNoWarningsOrErrors: false}) {
|
| - Uri uri;
|
| - Function getErrors;
|
| - Function getWarnings;
|
| - Compiler compiler;
|
| - if (useMockCompiler) {
|
| - uri = new Uri(scheme: 'source');
|
| - mock.MockCompiler mockCompiler = mock.compilerFor('''
|
| - main() {}
|
| - $source''',
|
| - uri,
|
| - analyzeAll: true,
|
| - analyzeOnly: true);
|
| - getErrors = () => mockCompiler.errors;
|
| - getWarnings = () => mockCompiler.warnings;
|
| - compiler = mockCompiler;
|
| - } else {
|
| - memory.DiagnosticCollector collector = new memory.DiagnosticCollector();
|
| - uri = Uri.parse('memory:main.dart');
|
| - compiler = memory.compilerFor(
|
| - {'main.dart': source},
|
| - diagnosticHandler: collector,
|
| - options: ['--analyze-all', '--analyze-only']);
|
| - getErrors = () => collector.errors;
|
| - getWarnings = () => collector.warnings;
|
| - }
|
| + var uri = new Uri(scheme: 'source');
|
| + MockCompiler compiler = compilerFor('''
|
| + main() {}
|
| + $source''',
|
| + uri,
|
| + analyzeAll: true,
|
| + analyzeOnly: true);
|
| return compiler.runCompiler(uri).then((_) {
|
| if (expectNoErrors || expectNoWarningsOrErrors) {
|
| - var errors = getErrors();
|
| - Expect.isTrue(errors.isEmpty,
|
| - 'Unexpected errors: ${errors}');
|
| + Expect.isTrue(compiler.errors.isEmpty,
|
| + 'Unexpected errors: ${compiler.errors}');
|
| }
|
| if (expectNoWarningsOrErrors) {
|
| - var warnings = getWarnings();
|
| - Expect.isTrue(warnings.isEmpty,
|
| - 'Unexpected warnings: ${warnings}');
|
| + Expect.isTrue(compiler.warnings.isEmpty,
|
| + 'Unexpected warnings: ${compiler.warnings}');
|
| }
|
| return new TypeEnvironment._(compiler);
|
| });
|
| }
|
|
|
| - TypeEnvironment._(Compiler this.compiler);
|
| + TypeEnvironment._(MockCompiler this.compiler);
|
|
|
| Element getElement(String name) {
|
| - var element = compiler.mainApp.find(name);
|
| + var element = findElement(compiler, name);
|
| Expect.isNotNull(element);
|
| if (element.isClass()) {
|
| element.ensureResolved(compiler);
|
| @@ -117,12 +87,12 @@ class TypeEnvironment {
|
|
|
| FunctionType functionType(DartType returnType,
|
| List<DartType> parameters,
|
| - {List<DartType> optionalParameters,
|
| + {List<DartType> optionalParameter,
|
| Map<String,DartType> namedParameters}) {
|
| Link<DartType> parameterTypes =
|
| new Link<DartType>.fromList(parameters);
|
| - Link<DartType> optionalParameterTypes = optionalParameters != null
|
| - ? new Link<DartType>.fromList(optionalParameters)
|
| + Link<DartType> optionalParameterTypes = optionalParameter != null
|
| + ? new Link<DartType>.fromList(optionalParameter)
|
| : const Link<DartType>();
|
| var namedParameterNames = new LinkBuilder<String>();
|
| var namedParameterTypes = new LinkBuilder<DartType>();
|
|
|