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

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

Issue 1870133002: Refactor serialization test files. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 library dart2js.serialization_analysis_test; 5 library dart2js.serialization_test_data;
6
7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/commandline_options.dart';
11 import 'package:compiler/src/common/backend_api.dart';
12 import 'package:compiler/src/common/names.dart';
13 import 'package:compiler/src/compiler.dart';
14 import 'package:compiler/src/filenames.dart';
15 import 'memory_compiler.dart';
16 import 'serialization_helper.dart';
17 6
18 const List<Test> TESTS = const <Test>[ 7 const List<Test> TESTS = const <Test>[
19 const Test(const { 8 const Test(const {
20 'main.dart': 'main() {}' 9 'main.dart': 'main() {}'
21 }), 10 }),
22 11
23 const Test(const { 12 const Test(const {
24 'main.dart': 'main() => print("Hello World");' 13 'main.dart': 'main() => print("Hello World");'
25 }), 14 }),
26 15
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Invocation of `MyRandom.nextInt` is only detected knowing the actual 183 // Invocation of `MyRandom.nextInt` is only detected knowing the actual
195 // implementation class for `List` and the world impact of its `shuffle` 184 // implementation class for `List` and the world impact of its `shuffle`
196 // method. 185 // method.
197 [].shuffle(new MyRandom()); 186 [].shuffle(new MyRandom());
198 }''' 187 }'''
199 }, 188 },
200 expectedWarningCount: 1, 189 expectedWarningCount: 1,
201 expectedInfoCount: 0), 190 expectedInfoCount: 0),
202 ]; 191 ];
203 192
204 main(List<String> arguments) {
205 asyncTest(() async {
206 String serializedData = await serializeDartCore();
207
208 if (arguments.isNotEmpty) {
209 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last));
210 await analyze(serializedData, entryPoint, null);
211 } else {
212 Uri entryPoint = Uri.parse('memory:main.dart');
213 for (Test test in TESTS) {
214 await analyze(serializedData, entryPoint, test);
215 }
216 }
217 });
218 }
219
220 class Test { 193 class Test {
221 final Map sourceFiles; 194 final Map sourceFiles;
222 final int expectedErrorCount; 195 final int expectedErrorCount;
223 final int expectedWarningCount; 196 final int expectedWarningCount;
224 final int expectedHintCount; 197 final int expectedHintCount;
225 final int expectedInfoCount; 198 final int expectedInfoCount;
226 199
227 const Test(this.sourceFiles, { 200 const Test(this.sourceFiles, {
228 this.expectedErrorCount: 0, 201 this.expectedErrorCount: 0,
229 this.expectedWarningCount: 0, 202 this.expectedWarningCount: 0,
230 this.expectedHintCount: 0, 203 this.expectedHintCount: 0,
231 this.expectedInfoCount: 0}); 204 this.expectedInfoCount: 0});
232 } 205 }
233
234 Future analyze(String serializedData, Uri entryPoint, Test test) async {
235 DiagnosticCollector diagnosticCollector = new DiagnosticCollector();
236 await runCompiler(
237 entryPoint: entryPoint,
238 memorySourceFiles: test != null ? test.sourceFiles : const {},
239 options: [Flags.analyzeOnly],
240 diagnosticHandler: diagnosticCollector,
241 beforeRun: (Compiler compiler) {
242 deserialize(compiler, serializedData);
243 });
244 if (test != null) {
245 Expect.equals(test.expectedErrorCount, diagnosticCollector.errors.length,
246 "Unexpected error count.");
247 Expect.equals(
248 test.expectedWarningCount,
249 diagnosticCollector.warnings.length,
250 "Unexpected warning count.");
251 Expect.equals(test.expectedHintCount, diagnosticCollector.hints.length,
252 "Unexpected hint count.");
253 Expect.equals(test.expectedInfoCount, diagnosticCollector.infos.length,
254 "Unexpected info count.");
255 }
256 }
257
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization_test.dart ('k') | tests/compiler/dart2js/serialization_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698