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

Unified Diff: tests/compiler/dart2js/type_test_helper.dart

Issue 141753002: Reapply "Implement new model for class members." and "Implement new model for interface members." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dart2dart bug. Created 6 years, 11 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/package_root_test.dart ('k') | tests/language/cyclic_metadata_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 01e8c16fad5869ffd0075d015e758555509aa74a..b64cecbe782b8b13c2fd8976cf03222cf149a004 100644
--- a/tests/compiler/dart2js/type_test_helper.dart
+++ b/tests/compiler/dart2js/type_test_helper.dart
@@ -5,9 +5,18 @@
library type_test_helper;
import 'dart:async';
-import "package:expect/expect.dart";
+import 'package:expect/expect.dart';
+import 'compiler_helper.dart' as mock;
+import 'memory_compiler.dart' as memory;
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
-import "compiler_helper.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;
GenericType instantiate(TypeDeclarationElement element,
List<DartType> arguments) {
@@ -20,35 +29,56 @@ GenericType instantiate(TypeDeclarationElement element,
}
class TypeEnvironment {
- final MockCompiler compiler;
+ final Compiler compiler;
static Future<TypeEnvironment> create(
- String source, {bool expectNoErrors: false,
+ String source, {bool useMockCompiler: true,
+ bool expectNoErrors: false,
bool expectNoWarningsOrErrors: false}) {
- var uri = new Uri(scheme: 'source');
- MockCompiler compiler = compilerFor('''
- main() {}
- $source''',
- uri,
- analyzeAll: true,
- analyzeOnly: true);
+ 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;
+ }
return compiler.runCompiler(uri).then((_) {
if (expectNoErrors || expectNoWarningsOrErrors) {
- Expect.isTrue(compiler.errors.isEmpty,
- 'Unexpected errors: ${compiler.errors}');
+ var errors = getErrors();
+ Expect.isTrue(errors.isEmpty,
+ 'Unexpected errors: ${errors}');
}
if (expectNoWarningsOrErrors) {
- Expect.isTrue(compiler.warnings.isEmpty,
- 'Unexpected warnings: ${compiler.warnings}');
+ var warnings = getWarnings();
+ Expect.isTrue(warnings.isEmpty,
+ 'Unexpected warnings: ${warnings}');
}
return new TypeEnvironment._(compiler);
});
}
- TypeEnvironment._(MockCompiler this.compiler);
+ TypeEnvironment._(Compiler this.compiler);
Element getElement(String name) {
- var element = findElement(compiler, name);
+ var element = compiler.mainApp.find(name);
Expect.isNotNull(element);
if (element.isClass()) {
element.ensureResolved(compiler);
@@ -87,12 +117,12 @@ class TypeEnvironment {
FunctionType functionType(DartType returnType,
List<DartType> parameters,
- {List<DartType> optionalParameter,
+ {List<DartType> optionalParameters,
Map<String,DartType> namedParameters}) {
Link<DartType> parameterTypes =
new Link<DartType>.fromList(parameters);
- Link<DartType> optionalParameterTypes = optionalParameter != null
- ? new Link<DartType>.fromList(optionalParameter)
+ Link<DartType> optionalParameterTypes = optionalParameters != null
+ ? new Link<DartType>.fromList(optionalParameters)
: const Link<DartType>();
var namedParameterNames = new LinkBuilder<String>();
var namedParameterTypes = new LinkBuilder<DartType>();
« no previous file with comments | « tests/compiler/dart2js/package_root_test.dart ('k') | tests/language/cyclic_metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698