| Index: tests/compiler/dart2js/embedded_category_api_boundary_test.dart
|
| diff --git a/tests/compiler/dart2js/embedded_category_api_boundary_test.dart b/tests/compiler/dart2js/embedded_category_api_boundary_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cbd973e2a499b57f0c6bf2a42c89fc0e7348cc0d
|
| --- /dev/null
|
| +++ b/tests/compiler/dart2js/embedded_category_api_boundary_test.dart
|
| @@ -0,0 +1,48 @@
|
| +// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE.md file.
|
| +
|
| +/// Tests that analyzing everything from the libraries that are public from the
|
| +/// embedded category does not cause elements from other libraries to be
|
| +/// processed.
|
| +library embedded_category_boundary_test;
|
| +
|
| +import 'package:expect/expect.dart';
|
| +import 'package:async_helper/async_helper.dart';
|
| +import 'package:compiler/src/compiler.dart';
|
| +import 'package:compiler/src/elements/elements.dart';
|
| +import 'package:sdk_library_metadata/libraries.dart';
|
| +
|
| +import 'analyze_helper.dart';
|
| +
|
| +main() async {
|
| + List<Uri> uriList = new List<Uri>();
|
| + libraries.forEach((String name, LibraryInfo info) {
|
| + if (info.categories.contains(Category.embedded)) {
|
| + uriList.add(new Uri(scheme: 'dart', path: name));
|
| + }
|
| + });
|
| + asyncTest(() async {
|
| + analyze(uriList, {},
|
| + checkResults: checkResults, analyzeMain: true, analyzeAll: false);
|
| + });
|
| +}
|
| +
|
| +/// These elements are currently escaping from dart:async via
|
| +/// `core._Resource#_readAsStream`.
|
| +Set<String> whiteList = new Set.from([
|
| + "function(StreamController#addError)",
|
| + "getter(StreamController#stream)",
|
| + "setter(StreamController#onListen)"
|
| +]);
|
| +
|
| +bool checkResults(Compiler compiler, CollectingDiagnosticHandler handler) {
|
| + return compiler.enqueuer.resolution.processedElements
|
| + .every((Element element) {
|
| + if (whiteList.contains("$element")) return true;
|
| + LibraryInfo info = libraries[element.library.canonicalUri.path];
|
| + bool isAllowedInEmbedded =
|
| + info.isInternal || info.categories.contains(Category.embedded);
|
| + return isAllowedInEmbedded;
|
| + });
|
| +}
|
|
|