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

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

Issue 1892183002: Refactor Parsing to remove compiler dependency (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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);
});
« no previous file with comments | « pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart ('k') | tests/compiler/dart2js/exit_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698