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

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

Issue 1415463022: Use DiagnosticMessage in MockCompiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
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 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 const String SOURCE = """ 9 const String SOURCE = """
10 class Foo { 10 class Foo {
(...skipping 13 matching lines...) Expand all
24 class MyClass {} 24 class MyClass {}
25 25
26 main() { 26 main() {
27 } 27 }
28 """; 28 """;
29 29
30 main() { 30 main() {
31 Uri uri = Uri.parse('test:code'); 31 Uri uri = Uri.parse('test:code');
32 var compiler1 = compilerFor(SOURCE, uri, analyzeAll: false); 32 var compiler1 = compilerFor(SOURCE, uri, analyzeAll: false);
33 asyncTest(() => compiler1.run(uri).then((compilationSucceded) { 33 asyncTest(() => compiler1.run(uri).then((compilationSucceded) {
34 DiagnosticCollector collector = compiler1.diagnosticCollector;
34 Expect.isTrue(compilationSucceded); 35 Expect.isTrue(compilationSucceded);
35 print(compiler1.warnings); 36 print(collector.warnings);
36 Expect.isTrue(compiler1.warnings.isEmpty, 'unexpected warnings'); 37 Expect.isTrue(collector.warnings.isEmpty, 'unexpected warnings');
37 Expect.isTrue(compiler1.errors.isEmpty, 'unexpected errors'); 38 Expect.isTrue(collector.errors.isEmpty, 'unexpected errors');
38 })); 39 }));
39 40
40 var compiler2 = compilerFor(SOURCE, uri, analyzeAll: true); 41 var compiler2 = compilerFor(SOURCE, uri, analyzeAll: true);
41 asyncTest(() => compiler2.run(uri).then((compilationSucceded) { 42 asyncTest(() => compiler2.run(uri).then((compilationSucceded) {
43 DiagnosticCollector collector = compiler2.diagnosticCollector;
42 Expect.isFalse(compilationSucceded); 44 Expect.isFalse(compilationSucceded);
43 Expect.isTrue(compiler2.warnings.isEmpty, 45 Expect.isTrue(collector.warnings.isEmpty,
44 'unexpected warnings: ${compiler2.warnings}'); 46 'unexpected warnings: ${collector.warnings}');
45 Expect.equals(2, compiler2.errors.length, 47 Expect.equals(2, collector.errors.length,
46 'expected exactly two errors, but got ${compiler2.errors}'); 48 'expected exactly two errors, but got ${collector.errors}');
47 49
48 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, 50 CollectedMessage first = collector.errors.first;
49 compiler2.errors[0].message.kind); 51 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, first.message.kind);
50 Expect.equals("Foo", compiler2.errors[0].node.toString()); 52 Expect.equals("Foo", SOURCE.substring(first.begin, first.end));
51 53
52 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, 54 CollectedMessage second = collector.errors.elementAt(1);
53 compiler2.errors[1].message.kind); 55 Expect.equals(MessageKind.CONSTRUCTOR_IS_NOT_CONST, second.message.kind);
54 Expect.equals("Foo", compiler2.errors[1].node.toString()); 56 Expect.equals("Foo", SOURCE.substring(second.begin, second.end));
55 })); 57 }));
56 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698