Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: tests/compiler/dart2js/uri_retention_test.dart

Issue 371553002: Hide the URIs in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment and remove type annotation that wasn't imported. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/lib/js_mirrors.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/uri_retention_test.dart
diff --git a/tests/compiler/dart2js/uri_retention_test.dart b/tests/compiler/dart2js/uri_retention_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fcdcdcc0409a5554a2d77db20f3d4965bb95287a
--- /dev/null
+++ b/tests/compiler/dart2js/uri_retention_test.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2013, the Dart 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 file.
+
+library dart2js.test.uri_retention_test;
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+
+import 'memory_compiler.dart' show
+ compilerFor;
+
+Future<String> compileSources(sources, {bool minify}) {
+ var compiler = compilerFor(sources, options: minify ? ['--minify'] : []);
+ return compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) {
+ return compiler.assembledCode;
+ });
+}
+
+Future test(sources, { bool libName, bool fileName }) {
+ return compileSources(sources, minify: false).then((output) {
+ // Unminified the sources should always contain the library name and the
+ // file name.
+ Expect.isTrue(output.contains("main_lib"));
+ Expect.isTrue(output.contains("main.dart"));
+ }).then((_) {
+ compileSources(sources, minify: true).then((output) {
+ Expect.equals(libName, output.contains("main_lib"));
+ Expect.equals(fileName, output.contains("main.dart"));
+ });
+ });
+}
+
+void main() {
+ asyncTest(() {
+ return new Future.value()
+ .then((_) => test(MEMORY_SOURCE_FILES1, libName: false, fileName: false))
+ .then((_) => test(MEMORY_SOURCE_FILES2, libName: true, fileName: false))
+ .then((_) => test(MEMORY_SOURCE_FILES3, libName: true, fileName: true));
+ });
+}
+
+const MEMORY_SOURCE_FILES1 = const <String, String> {
+ 'main.dart': """
+library main_lib;
+
+class A {
+ final uri = "foo";
+}
+
+main() {
+ print(Uri.base);
+ print(new A().uri);
+}
+""",
+};
+
+
+// Requires the library name, but not the URIs.
+const MEMORY_SOURCE_FILES2 = const <String, String> {
+ 'main.dart': """
+library main_lib;
+
+@MirrorsUsed(targets: 'main_lib')
+import 'dart:mirrors';
+import 'file2.dart';
+
+class A {
+}
+
+main() {
+ print(Uri.base);
+ // Unfortunately we can't use new B().uri yet, because that would require
+ // some type-feedback to know that the '.uri' is not the one from the library.
+ print(new B());
+ print(reflectClass(A).declarations.length);
+}
+""",
+ 'file2.dart': """
+library other_lib;
+
+class B {
+ final uri = "xyz";
+}
+""",
+};
+
+// Requires the uri (and will contain the library-name, too).
+const MEMORY_SOURCE_FILES3 = const <String, String> {
+ 'main.dart': """
+library main_lib;
+
+@MirrorsUsed(targets: 'main_lib')
+import 'dart:mirrors';
+
+main() {
+ print(currentMirrorSystem().findLibrary(#main_lib).uri);
+}
+""",
+};
« no previous file with comments | « sdk/lib/_internal/lib/js_mirrors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698