Index: tests/compiler/dart2js/compiler_test.dart |
diff --git a/tests/compiler/dart2js/compiler_test.dart b/tests/compiler/dart2js/compiler_test.dart |
index 691b86bd6253f1fa8fc0eec757947f470e1443b7..3e595c8343104137f4cb7161e1650c291ea72d7c 100644 |
--- a/tests/compiler/dart2js/compiler_test.dart |
+++ b/tests/compiler/dart2js/compiler_test.dart |
@@ -3,64 +3,27 @@ |
// BSD-style license that can be found in the LICENSE file. |
import "dart:async"; |
-import "package:expect/expect.dart"; |
+ |
import "package:async_helper/async_helper.dart"; |
+import 'package:compiler/compiler.dart'; |
import "package:compiler/src/elements/elements.dart"; |
-import "package:compiler/src/resolution/members.dart"; |
-import "package:compiler/src/diagnostics/diagnostic_listener.dart"; |
-import "mock_compiler.dart"; |
-import "diagnostic_reporter_helper.dart"; |
- |
- |
-class CallbackMockCompiler extends MockCompiler { |
- CallbackReporter reporter; |
- |
- CallbackMockCompiler() : super.internal() { |
- reporter = new CallbackReporter(super.reporter); |
- } |
- |
-} |
- |
-class CallbackReporter extends DiagnosticReporterWrapper { |
- final DiagnosticReporter reporter; |
- |
- CallbackReporter(this.reporter); |
- |
- var onError; |
- var onWarning; |
- |
- setOnError(var f) => onError = f; |
- setOnWarning(var f) => onWarning = f; |
- |
- void reportWarning( |
- DiagnosticMessage message, |
- [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { |
- if (onWarning != null) { |
- onWarning(this, message.spannable, message.message); |
- } |
- super.reportWarning(message, infos); |
- } |
+import "package:expect/expect.dart"; |
- void reportError( |
- DiagnosticMessage message, |
- [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]) { |
- if (onError != null) { |
- onError(this, message.spannable, message.message); |
- } |
- super.reportError(message, infos); |
- } |
-} |
+import "mock_compiler.dart"; |
Future testErrorHandling() { |
// Test that compiler.currentElement is set correctly when |
// reporting errors/warnings. |
- CallbackMockCompiler compiler = new CallbackMockCompiler(); |
+ MockCompiler compiler = new MockCompiler.internal(); |
return compiler.init().then((_) { |
- ResolverVisitor visitor = compiler.resolverVisitor(); |
compiler.parseScript('NoSuchPrefix.NoSuchType foo() {}'); |
FunctionElement foo = compiler.mainApp.find('foo'); |
- compiler.reporter.setOnWarning( |
- (c, n, m) => Expect.equals(foo, compiler.currentElement)); |
+ compiler.diagnosticHandler = |
+ (Uri uri, int begin, int end, String message, Diagnostic kind) { |
+ if (kind == Diagnostic.WARNING) { |
+ Expect.equals(foo, compiler.currentElement); |
+ } |
+ }; |
foo.computeType(compiler.resolution); |
Expect.equals(1, compiler.diagnosticCollector.warnings.length); |
}); |