OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, 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 import 'dart:uri'; |
| 6 |
| 7 import 'compiler_helper.dart'; |
| 8 |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 10 show MessageKind; |
| 11 |
| 12 const String SOURCE = """ |
| 13 class Foo { |
| 14 // Deliberately not const to ensure compile error. |
| 15 Foo(_); |
| 16 } |
| 17 |
| 18 @Bar() |
| 19 class Bar { |
| 20 const Bar(); |
| 21 } |
| 22 |
| 23 @Foo('x') |
| 24 typedef void VoidFunction(); |
| 25 |
| 26 @Foo('y') |
| 27 class MyClass {} |
| 28 |
| 29 main() { |
| 30 } |
| 31 """; |
| 32 |
| 33 main() { |
| 34 Uri uri = new Uri('test:code'); |
| 35 var compiler = compilerFor(SOURCE, uri, analyzeAll: false); |
| 36 compiler.runCompiler(uri); |
| 37 Expect.isFalse(compiler.compilationFailed); |
| 38 print(compiler.warnings); |
| 39 Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings'); |
| 40 Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors'); |
| 41 compiler = compilerFor(SOURCE, uri, analyzeAll: true); |
| 42 compiler.runCompiler(uri); |
| 43 Expect.isTrue(compiler.compilationFailed); |
| 44 Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings'); |
| 45 Expect.equals(2, compiler.errors.length, |
| 46 'expected exactly two errors, but got ${compiler.errors}'); |
| 47 |
| 48 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, |
| 49 compiler.errors[0].message.kind); |
| 50 Expect.equals("Foo", compiler.errors[0].node.toString()); |
| 51 |
| 52 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, |
| 53 compiler.errors[1].message.kind); |
| 54 Expect.equals("Foo", compiler.errors[1].node.toString()); |
| 55 } |
OLD | NEW |