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