| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Test that we don't report invalid modifier on error tokens. |
| 6 |
| 7 library dart2js.test.error_token; |
| 8 |
| 9 import 'dart:async'; |
| 10 import 'package:async_helper/async_helper.dart'; |
| 11 import "package:compiler/src/diagnostics/messages.dart"; |
| 12 import 'package:expect/expect.dart'; |
| 13 import 'memory_compiler.dart'; |
| 14 |
| 15 Future runTest(String code, {MessageKind error}) async { |
| 16 DiagnosticCollector diagnostics = new DiagnosticCollector(); |
| 17 OutputCollector output = new OutputCollector(); |
| 18 await runCompiler( |
| 19 entryPoint: Uri.parse('memory:main.dart'), |
| 20 memorySourceFiles: {'main.dart': code}, |
| 21 diagnosticHandler: diagnostics, |
| 22 outputProvider: output); |
| 23 |
| 24 Expect.equals(error != null ? 1 : 0, diagnostics.errors.length); |
| 25 if (error != null) { |
| 26 Expect.equals(error, diagnostics.errors.first.message.kind); |
| 27 } |
| 28 Expect.equals(0, diagnostics.warnings.length); |
| 29 Expect.equals(0, diagnostics.hints.length); |
| 30 Expect.equals(0, diagnostics.infos.length); |
| 31 } |
| 32 |
| 33 void main() { |
| 34 asyncTest(() async { |
| 35 await runTest(''' |
| 36 main() {} |
| 37 class Foo { |
| 38 static void bar() { |
| 39 baz()); |
| 40 } |
| 41 } |
| 42 ''', error: MessageKind.UNMATCHED_TOKEN); |
| 43 |
| 44 await runTest(''' |
| 45 main() {} |
| 46 class C { |
| 47 C(v) { |
| 48 throw ''); |
| 49 } |
| 50 }''', error: MessageKind.UNMATCHED_TOKEN); |
| 51 }); |
| 52 } |
| OLD | NEW |