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

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

Issue 1943723003: Report UNMATCHED_TOKEN instead of EXTRANEOUS_MODIFIER (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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 | « pkg/compiler/lib/src/parser/listener.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/error_token_test.dart
diff --git a/tests/compiler/dart2js/error_token_test.dart b/tests/compiler/dart2js/error_token_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2000f1a1fabd3c77f05c2a5d65ac7ac0f308c3a3
--- /dev/null
+++ b/tests/compiler/dart2js/error_token_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that we don't report invalid modifier on error tokens.
+
+library dart2js.test.error_token;
+
+import 'dart:async';
+import 'package:async_helper/async_helper.dart';
+import "package:compiler/src/diagnostics/messages.dart";
+import 'package:expect/expect.dart';
+import 'memory_compiler.dart';
+
+Future runTest(String code, {MessageKind error}) async {
+ DiagnosticCollector diagnostics = new DiagnosticCollector();
+ OutputCollector output = new OutputCollector();
+ await runCompiler(
+ entryPoint: Uri.parse('memory:main.dart'),
+ memorySourceFiles: {'main.dart': code},
+ diagnosticHandler: diagnostics,
+ outputProvider: output);
+
+ Expect.equals(error != null ? 1 : 0, diagnostics.errors.length);
+ if (error != null) {
+ Expect.equals(error, diagnostics.errors.first.message.kind);
+ }
+ Expect.equals(0, diagnostics.warnings.length);
+ Expect.equals(0, diagnostics.hints.length);
+ Expect.equals(0, diagnostics.infos.length);
+}
+
+void main() {
+ asyncTest(() async {
+ await runTest('''
+main() {}
+class Foo {
+ static void bar() {
+ baz());
+ }
+}
+''', error: MessageKind.UNMATCHED_TOKEN);
+
+ await runTest('''
+main() {}
+class C {
+ C(v) {
+ throw '');
+ }
+}''', error: MessageKind.UNMATCHED_TOKEN);
+ });
+}
« no previous file with comments | « pkg/compiler/lib/src/parser/listener.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698