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 library test.library_imports_deferred; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 import 'package:expect/expect.dart'; |
| 9 import 'stringify.dart'; |
| 10 |
| 11 import 'dart:collection' as eagercollection; |
| 12 import 'dart:collection' deferred as lazycollection; |
| 13 |
| 14 test(MirrorSystem mirrors) { |
| 15 LibraryMirror thisLibrary = |
| 16 mirrors.findLibrary(#test.library_imports_deferred); |
| 17 LibraryMirror collection = |
| 18 mirrors.findLibrary(#dart.collection); |
| 19 |
| 20 var importsOfCollection = thisLibrary.libraryDependencies.where( |
| 21 (dep) => dep.targetLibrary == collection).toList(); |
| 22 Expect.equals(2, importsOfCollection.length); |
| 23 Expect.notEquals(importsOfCollection[0].isDeferred, |
| 24 importsOfCollection[1].isDeferred); // One deferred, one not
. |
| 25 |
| 26 // Only collection is defer-imported. |
| 27 LibraryDependencyMirror dep = |
| 28 thisLibrary.libraryDependencies.singleWhere((dep) => dep.isDeferred); |
| 29 Expect.equals(collection, dep.targetLibrary); |
| 30 |
| 31 Expect.stringEquals( |
| 32 'import dart.collection as eagercollection\n' |
| 33 'import dart.collection deferred as lazycollection\n' |
| 34 ' hide loadLibrary\n' |
| 35 'import dart.core\n' |
| 36 'import dart.mirrors\n' |
| 37 'import expect\n' |
| 38 'import test.stringify\n', |
| 39 stringifyDependencies(thisLibrary)); |
| 40 } |
| 41 |
| 42 main() { |
| 43 test(currentMirrorSystem()); |
| 44 } |
OLD | NEW |