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

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

Issue 1248483008: Split MessageKind into a MessageKind key and a MessageTemplate. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 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/compiler/lib/src/warnings.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | 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) 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 // Smoke test of the dart2js compiler API. 5 // Smoke test of the dart2js compiler API.
6 library analyze_only; 6 library analyze_only;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
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 11
12 import '../../utils/dummy_compiler_test.dart' as dummy; 12 import '../../utils/dummy_compiler_test.dart' as dummy;
13 import 'package:compiler/compiler.dart'; 13 import 'package:compiler/compiler.dart';
14 14
15 import 'package:compiler/src/dart2jslib.dart' show 15 import 'package:compiler/src/warnings.dart' show
16 MessageKind; 16 MessageKind, MessageTemplate;
17 17
18 import 'output_collector.dart'; 18 import 'output_collector.dart';
19 19
20 runCompiler(String main, List<String> options, 20 runCompiler(String main, List<String> options,
21 onValue(String code, List errors, List warnings)) { 21 onValue(String code, List errors, List warnings)) {
22 List errors = new List(); 22 List errors = new List();
23 List warnings = new List(); 23 List warnings = new List();
24 24
25 Future<String> localProvider(Uri uri) { 25 Future<String> localProvider(Uri uri) {
26 if (uri.scheme != 'main') return dummy.provider(uri); 26 if (uri.scheme != 'main') return dummy.provider(uri);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }); 61 });
62 } 62 }
63 63
64 main() { 64 main() {
65 runCompiler( 65 runCompiler(
66 "", 66 "",
67 ['--generate-code-with-compile-time-errors'], 67 ['--generate-code-with-compile-time-errors'],
68 (String code, List errors, List warnings) { 68 (String code, List errors, List warnings) {
69 Expect.isNotNull(code); 69 Expect.isNotNull(code);
70 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors'); 70 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
71 MessageTemplate template =
72 MessageTemplate.TEMPLATES[MessageKind.MISSING_MAIN];
71 Expect.equals( 73 Expect.equals(
72 "${MessageKind.MISSING_MAIN.message({'main': 'main'})}", 74 "${template.message({'main': 'main'})}",
73 warnings.single); 75 warnings.single);
74 }); 76 });
75 77
76 runCompiler( 78 runCompiler(
77 "main() {}", 79 "main() {}",
78 ['--generate-code-with-compile-time-errors'], 80 ['--generate-code-with-compile-time-errors'],
79 (String code, List errors, List warnings) { 81 (String code, List errors, List warnings) {
80 Expect.isNotNull(code); 82 Expect.isNotNull(code);
81 Expect.isTrue(errors.isEmpty); 83 Expect.isTrue(errors.isEmpty);
82 Expect.isTrue(warnings.isEmpty); 84 Expect.isTrue(warnings.isEmpty);
83 }); 85 });
84 86
85 runCompiler( 87 runCompiler(
86 "", 88 "",
87 ['--analyze-only'], 89 ['--analyze-only'],
88 (String code, List errors, List warnings) { 90 (String code, List errors, List warnings) {
89 Expect.isNull(code); 91 Expect.isNull(code);
90 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors'); 92 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
93 MessageTemplate template =
94 MessageTemplate.TEMPLATES[MessageKind.CONSIDER_ANALYZE_ALL];
91 Expect.equals( 95 Expect.equals(
92 "${MessageKind.CONSIDER_ANALYZE_ALL.message({'main': 'main'})}", 96 "${template.message({'main': 'main'})}",
93 warnings.single); 97 warnings.single);
94 }); 98 });
95 99
96 runCompiler( 100 runCompiler(
97 "main() {}", 101 "main() {}",
98 ['--analyze-only'], 102 ['--analyze-only'],
99 (String code, List errors, List warnings) { 103 (String code, List errors, List warnings) {
100 Expect.isNull(code); 104 Expect.isNull(code);
101 Expect.isTrue(errors.isEmpty); 105 Expect.isTrue(errors.isEmpty);
102 Expect.isTrue(warnings.isEmpty); 106 Expect.isTrue(warnings.isEmpty);
103 }); 107 });
104 108
105 runCompiler( 109 runCompiler(
106 "Foo foo; // Unresolved but not analyzed.", 110 "Foo foo; // Unresolved but not analyzed.",
107 ['--analyze-only'], 111 ['--analyze-only'],
108 (String code, List errors, List warnings) { 112 (String code, List errors, List warnings) {
109 Expect.isNull(code); 113 Expect.isNull(code);
110 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors'); 114 Expect.isTrue(errors.isEmpty, 'errors is not empty: $errors');
115 MessageTemplate template =
116 MessageTemplate.TEMPLATES[MessageKind.CONSIDER_ANALYZE_ALL];
111 Expect.equals( 117 Expect.equals(
112 "${MessageKind.CONSIDER_ANALYZE_ALL.message({'main': 'main'})}", 118 "${template.message({'main': 'main'})}",
113 warnings.single); 119 warnings.single);
114 }); 120 });
115 121
116 runCompiler( 122 runCompiler(
117 """main() { 123 """main() {
118 Foo foo; // Unresolved and analyzed. 124 Foo foo; // Unresolved and analyzed.
119 }""", 125 }""",
120 ['--analyze-only'], 126 ['--analyze-only'],
121 (String code, List errors, List warnings) { 127 (String code, List errors, List warnings) {
122 Expect.isNull(code); 128 Expect.isNull(code);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // --analyze-signatures-only implies --analyze-only 177 // --analyze-signatures-only implies --analyze-only
172 runCompiler( 178 runCompiler(
173 "", 179 "",
174 ['--analyze-signatures-only', '--analyze-all'], 180 ['--analyze-signatures-only', '--analyze-all'],
175 (String code, List errors, List warnings) { 181 (String code, List errors, List warnings) {
176 Expect.isNull(code); 182 Expect.isNull(code);
177 Expect.isTrue(errors.isEmpty); 183 Expect.isTrue(errors.isEmpty);
178 Expect.isTrue(warnings.isEmpty); 184 Expect.isTrue(warnings.isEmpty);
179 }); 185 });
180 } 186 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698