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

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

Issue 1247773002: Add access the Message in CompilerDiagnostics.report. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // Test that the compiler emits a warning on import of 'dart:mirrors' unless 5 // Test that the compiler emits a warning on import of 'dart:mirrors' unless
6 // the flag --enable-experimental-mirrors is used. 6 // the flag --enable-experimental-mirrors is used.
7 7
8 library dart2js.test.import; 8 library dart2js.test.import;
9 9
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 'paths': 335 'paths':
336 "first.dart => package:packagename => dart:mirrors", 336 "first.dart => package:packagename => dart:mirrors",
337 'verbosePaths': 337 'verbosePaths':
338 "main.dart => first.dart => package:packagename/second.dart " 338 "main.dart => first.dart => package:packagename/second.dart "
339 "=> dart:mirrors", 339 "=> dart:mirrors",
340 }; 340 };
341 341
342 Future test(Map sourceFiles, 342 Future test(Map sourceFiles,
343 {expectedPaths, 343 {expectedPaths,
344 bool verbose: false, 344 bool verbose: false,
345 bool enableExperimentalMirrors: false}) { 345 bool enableExperimentalMirrors: false}) async {
346 if (expectedPaths is! List) { 346 if (expectedPaths is! List) {
347 expectedPaths = [expectedPaths]; 347 expectedPaths = [expectedPaths];
348 } 348 }
349 var collector = new DiagnosticCollector(); 349 var collector = new DiagnosticCollector();
350 var options = []; 350 var options = [];
351 if (verbose) { 351 if (verbose) {
352 options.add('--verbose'); 352 options.add('--verbose');
353 } 353 }
354 if (enableExperimentalMirrors) { 354 if (enableExperimentalMirrors) {
355 options.add('--enable-experimental-mirrors'); 355 options.add('--enable-experimental-mirrors');
356 } 356 }
357 var compiler = compilerFor(sourceFiles, diagnosticHandler: collector, 357 CompilationResult result = await runCompiler(
358 packageRoot: Uri.parse('memory:/pkg/'), 358 entryPoint: Uri.parse('memory:/main.dart'),
359 options: options); 359 memorySourceFiles: sourceFiles,
360 return compiler.run(Uri.parse('memory:/main.dart')).then((_) { 360 diagnosticHandler: collector,
361 Expect.equals(0, collector.errors.length, 'Errors: ${collector.errors}'); 361 packageRoot: Uri.parse('memory:/pkg/'),
362 if (enableExperimentalMirrors) { 362 options: options);
363 Expect.equals(0, collector.warnings.length, 363 Expect.equals(0, collector.errors.length, 'Errors: ${collector.errors}');
364 'Warnings: ${collector.errors}'); 364 if (enableExperimentalMirrors) {
365 } else { 365 Expect.equals(0, collector.warnings.length,
366 Expect.equals(1, collector.warnings.length, 366 'Warnings: ${collector.errors}');
367 'Warnings: ${collector.errors}'); 367 } else {
368 Expect.equals( 368 Expect.equals(1, collector.warnings.length,
369 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS.message( 369 'Warnings: ${collector.errors}');
370 {'importChain': expectedPaths.join( 370 Expect.equals(
371 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}).toString(), 371 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS,
372 collector.warnings.first.message); 372 collector.warnings.first.message.kind);
373 } 373 Expect.equals(
374 }); 374 expectedPaths.join(MessageKind.IMPORT_EXPERIMENTAL_MIRRORS_PADDING),
375 collector.warnings.first.message.arguments['importChain']);
376 }
375 } 377 }
376 378
377 Future checkPaths(Map sourceData) { 379 Future checkPaths(Map sourceData) {
378 Map sourceFiles = sourceData; 380 Map sourceFiles = sourceData;
379 var expectedPaths = sourceData['paths']; 381 var expectedPaths = sourceData['paths'];
380 var expectedVerbosePaths = sourceData['verbosePaths']; 382 var expectedVerbosePaths = sourceData['verbosePaths'];
381 if (expectedVerbosePaths == null) { 383 if (expectedVerbosePaths == null) {
382 expectedVerbosePaths = expectedPaths; 384 expectedVerbosePaths = expectedPaths;
383 } 385 }
384 return test(sourceFiles, expectedPaths: expectedPaths).then((_) { 386 return test(sourceFiles, expectedPaths: expectedPaths).then((_) {
(...skipping 19 matching lines...) Expand all
404 DUAL_INDIRECT_IMPORT3, 406 DUAL_INDIRECT_IMPORT3,
405 DUAL_INDIRECT_PACKAGE_IMPORT1, 407 DUAL_INDIRECT_PACKAGE_IMPORT1,
406 DIRECT_EXPORT, 408 DIRECT_EXPORT,
407 INDIRECT_EXPORT1, 409 INDIRECT_EXPORT1,
408 INDIRECT_EXPORT2, 410 INDIRECT_EXPORT2,
409 INDIRECT_PACKAGE_EXPORT1, 411 INDIRECT_PACKAGE_EXPORT1,
410 INDIRECT_PACKAGE_EXPORT2], 412 INDIRECT_PACKAGE_EXPORT2],
411 (map) => checkPaths(map) 413 (map) => checkPaths(map)
412 )); 414 ));
413 } 415 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/duplicate_library_test.dart ('k') | tests/compiler/dart2js/memory_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698