OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 // Test that the hint on empty combinators works as intended. |
| 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 'memory_compiler.dart'; |
| 12 |
| 13 const SOURCE = const { |
| 14 'show_local.dart': """ |
| 15 import 'lib.dart' show Foo; |
| 16 """, |
| 17 |
| 18 'hide_local.dart': """ |
| 19 import 'lib.dart' hide Foo; |
| 20 """, |
| 21 |
| 22 'show_package.dart': """ |
| 23 import 'package:pkg/pkg.dart' show Foo; |
| 24 """, |
| 25 |
| 26 'hide_package.dart': """ |
| 27 import 'package:pkg/pkg.dart' hide Foo; |
| 28 """, |
| 29 |
| 30 'lib.dart': '', |
| 31 |
| 32 'pkg/pkg/pkg.dart': '', |
| 33 }; |
| 34 |
| 35 Future test(Uri entryPoint, |
| 36 {bool showPackageWarnings: false, |
| 37 bool suppressHints: false, |
| 38 int hints: 0}) async { |
| 39 print('=================================================================='); |
| 40 print('test: $entryPoint showPackageWarnings=$showPackageWarnings ' |
| 41 'suppressHints=$suppressHints'); |
| 42 var options = [Flags.analyzeOnly, Flags.analyzeAll]; |
| 43 if (showPackageWarnings) { |
| 44 options.add(Flags.showPackageWarnings); |
| 45 } |
| 46 if (suppressHints) { |
| 47 options.add(Flags.suppressHints); |
| 48 } |
| 49 var collector = new DiagnosticCollector(); |
| 50 await runCompiler( |
| 51 entryPoint: entryPoint, |
| 52 memorySourceFiles: SOURCE, |
| 53 options: options, |
| 54 packageRoot: Uri.parse('memory:pkg/'), |
| 55 diagnosticHandler: collector); |
| 56 Expect.equals(0, collector.errors.length, |
| 57 'Unexpected errors: ${collector.errors}'); |
| 58 Expect.equals(0, collector.warnings.length, |
| 59 'Unexpected warnings: ${collector.warnings}'); |
| 60 Expect.equals(hints, collector.hints.length, |
| 61 'Unexpected hints: ${collector.hints}'); |
| 62 Expect.equals(0, collector.infos.length, |
| 63 'Unexpected infos: ${collector.infos}'); |
| 64 print('=================================================================='); |
| 65 } |
| 66 |
| 67 Future testUri(Uri entrypoint, {bool suppressed: false}) async { |
| 68 await test( |
| 69 entrypoint, |
| 70 showPackageWarnings: true, |
| 71 suppressHints: false, |
| 72 hints: 1); |
| 73 await test( |
| 74 entrypoint, |
| 75 showPackageWarnings: false, |
| 76 suppressHints: false, |
| 77 hints: suppressed ? 0 : 1); |
| 78 await test( |
| 79 entrypoint, |
| 80 showPackageWarnings: true, |
| 81 suppressHints: true, |
| 82 hints: 0); |
| 83 await test( |
| 84 entrypoint, |
| 85 showPackageWarnings: false, |
| 86 suppressHints: true, |
| 87 hints: 0); |
| 88 } |
| 89 |
| 90 void main() { |
| 91 asyncTest(() async { |
| 92 await testUri(Uri.parse('memory:show_local.dart')); |
| 93 await testUri(Uri.parse('memory:hide_local.dart')); |
| 94 await testUri(Uri.parse('memory:show_package.dart')); |
| 95 await testUri(Uri.parse('memory:hide_package.dart'), suppressed: true); |
| 96 }); |
| 97 } |
| 98 |
OLD | NEW |