OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'compiler_helper.dart'; | 6 import 'compiler_helper.dart'; |
7 | 7 |
8 const String SOURCE = """ | 8 const String SOURCE = """ |
9 class Foo { | 9 class Foo { |
10 // Deliberately not const to ensure compile error. | 10 // Deliberately not const to ensure compile error. |
11 Foo(_); | 11 Foo(_); |
12 } | 12 } |
13 | 13 |
14 @Bar() | 14 @Bar() |
15 class Bar { | 15 class Bar { |
16 const Bar(); | 16 const Bar(); |
17 } | 17 } |
18 | 18 |
19 @Foo('x') | 19 @Foo('x') |
20 typedef void VoidFunction(); | 20 typedef void VoidFunction(); |
21 | 21 |
22 @Foo('y') | 22 @Foo('y') |
23 class MyClass {} | 23 class MyClass {} |
24 | 24 |
25 main() { | 25 main() { |
26 } | 26 } |
27 """; | 27 """; |
28 | 28 |
29 main() { | 29 main() { |
30 Uri uri = Uri.parse('test:code'); | 30 Uri uri = Uri.parse('test:code'); |
ahe
2013/08/06 16:29:17
Needs to use dart/tests/async_helper.dart.
Johnni Winther
2013/08/27 11:05:00
Done.
| |
31 var compiler = compilerFor(SOURCE, uri, analyzeAll: false); | 31 var compiler1 = compilerFor(SOURCE, uri, analyzeAll: false); |
32 compiler.runCompiler(uri); | 32 compiler1.runCompiler(uri).then((_) { |
33 Expect.isFalse(compiler.compilationFailed); | 33 Expect.isFalse(compiler1.compilationFailed); |
34 print(compiler.warnings); | 34 print(compiler1.warnings); |
35 Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings'); | 35 Expect.isTrue(compiler1.warnings.isEmpty, 'unexpected warnings'); |
36 Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors'); | 36 Expect.isTrue(compiler1.errors.isEmpty, 'unexpected errors'); |
37 compiler = compilerFor(SOURCE, uri, analyzeAll: true); | 37 }); |
38 compiler.runCompiler(uri); | |
39 Expect.isTrue(compiler.compilationFailed); | |
40 Expect.isTrue(compiler.warnings.isEmpty, 'unexpected warnings'); | |
41 Expect.equals(2, compiler.errors.length, | |
42 'expected exactly two errors, but got ${compiler.errors}'); | |
43 | 38 |
44 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, | 39 var compiler2 = compilerFor(SOURCE, uri, analyzeAll: true); |
45 compiler.errors[0].message.kind); | 40 compiler2.runCompiler(uri).then((_) { |
46 Expect.equals("Foo", compiler.errors[0].node.toString()); | 41 Expect.isTrue(compiler2.compilationFailed); |
42 Expect.isTrue(compiler2.warnings.isEmpty, 'unexpected warnings'); | |
43 Expect.equals(2, compiler2.errors.length, | |
44 'expected exactly two errors, but got ${compiler2.errors}'); | |
47 | 45 |
48 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, | 46 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, |
49 compiler.errors[1].message.kind); | 47 compiler2.errors[0].message.kind); |
50 Expect.equals("Foo", compiler.errors[1].node.toString()); | 48 Expect.equals("Foo", compiler2.errors[0].node.toString()); |
49 | |
50 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, | |
51 compiler2.errors[1].message.kind); | |
52 Expect.equals("Foo", compiler2.errors[1].node.toString()); | |
53 }); | |
51 } | 54 } |
OLD | NEW |