OLD | NEW |
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 /// Tests that analyzing everything from the libraries that are public from the | 5 /// Tests that analyzing everything from the libraries that are public from the |
6 /// embedded category does not cause elements from other libraries to be | 6 /// embedded category does not cause elements from other libraries to be |
7 /// processed. | 7 /// processed. |
8 library embedded_category_boundary_test; | 8 library embedded_category_boundary_test; |
9 | 9 |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 import 'package:async_helper/async_helper.dart'; | 11 import 'package:async_helper/async_helper.dart'; |
12 import 'package:compiler/src/compiler.dart'; | 12 import 'package:compiler/src/compiler.dart'; |
13 import 'package:compiler/src/elements/elements.dart'; | 13 import 'package:compiler/src/elements/elements.dart'; |
14 import 'package:sdk_library_metadata/libraries.dart'; | 14 import 'package:sdk_library_metadata/libraries.dart'; |
15 | 15 |
16 import 'analyze_helper.dart'; | 16 import 'analyze_helper.dart'; |
17 | 17 |
18 main() async { | 18 main() async { |
19 List<Uri> uriList = new List<Uri>(); | 19 List<Uri> uriList = new List<Uri>(); |
20 libraries.forEach((String name, LibraryInfo info) { | 20 libraries.forEach((String name, LibraryInfo info) { |
21 if (info.categories.contains(Category.embedded)) { | 21 if (info.categories.contains(Category.embedded)) { |
22 uriList.add(new Uri(scheme: 'dart', path: name)); | 22 uriList.add(new Uri(scheme: 'dart', path: name)); |
23 } | 23 } |
24 }); | 24 }); |
25 asyncTest(() async { | 25 asyncTest(() async { |
26 analyze(uriList, {}, | 26 analyze(uriList, {}, checkResults: checkResults, mode: AnalysisMode.MAIN); |
27 checkResults: checkResults, | |
28 mode: AnalysisMode.MAIN); | |
29 }); | 27 }); |
30 } | 28 } |
31 | 29 |
32 /// These elements are currently escaping from dart:async via | 30 /// These elements are currently escaping from dart:async via |
33 /// `core._Resource#_readAsStream`. | 31 /// `core._Resource#_readAsStream`. |
34 Set<String> whiteList = new Set.from([ | 32 Set<String> whiteList = new Set.from([ |
35 "function(StreamController#addError)", | 33 "function(StreamController#addError)", |
36 "getter(StreamController#stream)", | 34 "getter(StreamController#stream)", |
37 "setter(StreamController#onListen)" | 35 "setter(StreamController#onListen)" |
38 ]); | 36 ]); |
39 | 37 |
40 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { | 38 bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) { |
41 return compiler.enqueuer.resolution.processedElements | 39 return compiler.enqueuer.resolution.processedElements |
42 .every((Element element) { | 40 .every((Element element) { |
43 if (whiteList.contains("$element")) return true; | 41 if (whiteList.contains("$element")) return true; |
44 LibraryInfo info = libraries[element.library.canonicalUri.path]; | 42 LibraryInfo info = libraries[element.library.canonicalUri.path]; |
45 bool isAllowedInEmbedded = | 43 bool isAllowedInEmbedded = |
46 info.isInternal || info.categories.contains(Category.embedded); | 44 info.isInternal || info.categories.contains(Category.embedded); |
47 return isAllowedInEmbedded; | 45 return isAllowedInEmbedded; |
48 }); | 46 }); |
49 } | 47 } |
OLD | NEW |