OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:async'; |
| 6 |
| 7 import 'package:expect/expect.dart'; |
| 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'memory_compiler.dart' show compilerFor, OutputCollector; |
| 10 |
| 11 const MEMORY_SOURCE_FILES = const <String, String> { |
| 12 'main.dart': """ |
| 13 library main; |
| 14 |
| 15 @MirrorsUsed(targets: const ['main', 'lib']) |
| 16 import 'dart:mirrors'; |
| 17 import 'lib.dart'; |
| 18 |
| 19 |
| 20 class Subclass extends Super { |
| 21 int _private; |
| 22 |
| 23 int magic() => _private++; |
| 24 } |
| 25 |
| 26 main() { |
| 27 var objects = [new Super(), new Subclass()]; |
| 28 print(currentMirrorSystem().findLibrary(#main).uri); |
| 29 } |
| 30 """, |
| 31 'lib.dart': """ |
| 32 library lib; |
| 33 |
| 34 class Super { |
| 35 int _private; |
| 36 |
| 37 int magic() => _private++; |
| 38 } |
| 39 """ |
| 40 }; |
| 41 |
| 42 runTest(bool preserveUris) { |
| 43 OutputCollector collector = new OutputCollector(); |
| 44 var options = ["--minify"]; |
| 45 if (preserveUris) options.add("--preserve-uris"); |
| 46 var compiler = compilerFor(MEMORY_SOURCE_FILES, |
| 47 outputProvider: collector, |
| 48 options: options); |
| 49 return compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) { |
| 50 String jsOutput = collector.getOutput('', 'js'); |
| 51 Expect.equals(preserveUris, jsOutput.contains("main.dart")); |
| 52 Expect.equals(preserveUris, jsOutput.contains("lib.dart")); |
| 53 }); |
| 54 } |
| 55 |
| 56 void main() { |
| 57 asyncStart(); |
| 58 new Future.value() |
| 59 .then((_) => runTest(true)) |
| 60 .then((_) => runTest(false)) |
| 61 .whenComplete(asyncEnd); |
| 62 } |
OLD | NEW |