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

Side by Side Diff: tests/compiler/dart2js/error_token_test.dart

Issue 2981343002: improve fasta closing brace recovery (Closed)
Patch Set: rebase Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « pkg/front_end/test/scanner_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test that we don't report invalid modifier on error tokens. 5 // Test that we don't report invalid modifier on error tokens.
6 6
7 library dart2js.test.error_token; 7 library dart2js.test.error_token;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'package:async_helper/async_helper.dart'; 10 import 'package:async_helper/async_helper.dart';
11 import "package:compiler/src/diagnostics/messages.dart"; 11 import "package:compiler/src/diagnostics/messages.dart";
12 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
13 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
14 14
15 Future runTest(String code, {MessageKind error}) async { 15 Future runTest(String code,
16 {MessageKind error, int expectedWarningCount: 0}) async {
16 DiagnosticCollector diagnostics = new DiagnosticCollector(); 17 DiagnosticCollector diagnostics = new DiagnosticCollector();
17 OutputCollector output = new OutputCollector(); 18 OutputCollector output = new OutputCollector();
18 await runCompiler( 19 await runCompiler(
19 entryPoint: Uri.parse('memory:main.dart'), 20 entryPoint: Uri.parse('memory:main.dart'),
20 memorySourceFiles: {'main.dart': code}, 21 memorySourceFiles: {'main.dart': code},
21 diagnosticHandler: diagnostics, 22 diagnosticHandler: diagnostics,
22 outputProvider: output); 23 outputProvider: output);
23 24
24 Expect.equals(error != null ? 1 : 0, diagnostics.errors.length); 25 Expect.equals(error != null ? 1 : 0, diagnostics.errors.length);
25 if (error != null) { 26 if (error != null)
26 Expect.equals(error, diagnostics.errors.first.message.kind); 27 Expect.equals(error, diagnostics.errors.first.message.kind);
27 } 28 Expect.equals(expectedWarningCount, diagnostics.warnings.length);
28 Expect.equals(0, diagnostics.warnings.length);
29 Expect.equals(0, diagnostics.hints.length); 29 Expect.equals(0, diagnostics.hints.length);
30 Expect.equals(0, diagnostics.infos.length); 30 Expect.equals(0, diagnostics.infos.length);
31 } 31 }
32 32
33 void main() { 33 void main() {
34 asyncTest(() async { 34 asyncTest(() async {
35 await runTest( 35 await runTest(
36 ''' 36 '''
37 main() {} 37 main() {Foo.bar();}
38 class Foo { 38 class Foo {
39 static void bar() { 39 static void bar() {
40 baz()); 40 baz());
41 } 41 }
42 } 42 }
43 ''', 43 ''',
44 error: MessageKind.UNMATCHED_TOKEN); 44 error: MessageKind.MISSING_TOKEN_AFTER_THIS,
45 expectedWarningCount: 1);
45 46
46 await runTest( 47 await runTest(
47 ''' 48 '''
48 main() {} 49 main() {new C(v);}
49 class C { 50 class C {
50 C(v) { 51 C(v) {
51 throw ''); 52 throw '');
52 } 53 }
53 }''', 54 }''',
54 error: MessageKind.UNMATCHED_TOKEN); 55 error: MessageKind.MISSING_TOKEN_AFTER_THIS,
56 expectedWarningCount: 1);
55 }); 57 });
56 } 58 }
OLDNEW
« no previous file with comments | « pkg/front_end/test/scanner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698