| OLD | NEW |
| 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'; |
| 11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 12 import 'package:async_helper/async_helper.dart'; | 12 import 'package:async_helper/async_helper.dart'; |
| 13 import 'package:compiler/src/dart2jslib.dart' show MessageKind; | 13 import 'package:compiler/src/warnings.dart' show MessageKind, MessageTemplate; |
| 14 import 'memory_compiler.dart'; | 14 import 'memory_compiler.dart'; |
| 15 | 15 |
| 16 const DIRECT_IMPORT = const { | 16 const DIRECT_IMPORT = const { |
| 17 '/main.dart': ''' | 17 '/main.dart': ''' |
| 18 import 'dart:mirrors'; | 18 import 'dart:mirrors'; |
| 19 | 19 |
| 20 main() {} | 20 main() {} |
| 21 ''', | 21 ''', |
| 22 | 22 |
| 23 'paths': | 23 'paths': |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (enableExperimentalMirrors) { | 364 if (enableExperimentalMirrors) { |
| 365 Expect.equals(0, collector.warnings.length, | 365 Expect.equals(0, collector.warnings.length, |
| 366 'Warnings: ${collector.errors}'); | 366 'Warnings: ${collector.errors}'); |
| 367 } else { | 367 } else { |
| 368 Expect.equals(1, collector.warnings.length, | 368 Expect.equals(1, collector.warnings.length, |
| 369 'Warnings: ${collector.errors}'); | 369 'Warnings: ${collector.errors}'); |
| 370 Expect.equals( | 370 Expect.equals( |
| 371 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, | 371 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, |
| 372 collector.warnings.first.message.kind); | 372 collector.warnings.first.message.kind); |
| 373 Expect.equals( | 373 Expect.equals( |
| 374 expectedPaths.join(MessageKind.IMPORT_EXPERIMENTAL_MIRRORS_PADDING), | 374 expectedPaths.join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING), |
| 375 collector.warnings.first.message.arguments['importChain']); | 375 collector.warnings.first.message.arguments['importChain']); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 Future checkPaths(Map sourceData) { | 379 Future checkPaths(Map sourceData) { |
| 380 Map sourceFiles = sourceData; | 380 Map sourceFiles = sourceData; |
| 381 var expectedPaths = sourceData['paths']; | 381 var expectedPaths = sourceData['paths']; |
| 382 var expectedVerbosePaths = sourceData['verbosePaths']; | 382 var expectedVerbosePaths = sourceData['verbosePaths']; |
| 383 if (expectedVerbosePaths == null) { | 383 if (expectedVerbosePaths == null) { |
| 384 expectedVerbosePaths = expectedPaths; | 384 expectedVerbosePaths = expectedPaths; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 406 DUAL_INDIRECT_IMPORT3, | 406 DUAL_INDIRECT_IMPORT3, |
| 407 DUAL_INDIRECT_PACKAGE_IMPORT1, | 407 DUAL_INDIRECT_PACKAGE_IMPORT1, |
| 408 DIRECT_EXPORT, | 408 DIRECT_EXPORT, |
| 409 INDIRECT_EXPORT1, | 409 INDIRECT_EXPORT1, |
| 410 INDIRECT_EXPORT2, | 410 INDIRECT_EXPORT2, |
| 411 INDIRECT_PACKAGE_EXPORT1, | 411 INDIRECT_PACKAGE_EXPORT1, |
| 412 INDIRECT_PACKAGE_EXPORT2], | 412 INDIRECT_PACKAGE_EXPORT2], |
| 413 (map) => checkPaths(map) | 413 (map) => checkPaths(map) |
| 414 )); | 414 )); |
| 415 } | 415 } |
| OLD | NEW |