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

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

Issue 582753002: dart2js: add --preserve-uris flag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update tests. Created 6 years, 2 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/pub_generated/lib/src/dart.dart ('k') | tests/compiler/dart2js/uri_retention_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/preserve_uris_test.dart
diff --git a/tests/compiler/dart2js/preserve_uris_test.dart b/tests/compiler/dart2js/preserve_uris_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e0b8f1f02ce014c67c70abf34614eb7f0488fafe
--- /dev/null
+++ b/tests/compiler/dart2js/preserve_uris_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2014, 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.
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'memory_compiler.dart' show compilerFor, OutputCollector;
+
+const MEMORY_SOURCE_FILES = const <String, String> {
+ 'main.dart': """
+library main;
+
+@MirrorsUsed(targets: const ['main', 'lib'])
+import 'dart:mirrors';
+import 'lib.dart';
+
+
+class Subclass extends Super {
+ int _private;
+
+ int magic() => _private++;
+}
+
+main() {
+ var objects = [new Super(), new Subclass()];
+ print(currentMirrorSystem().findLibrary(#main).uri);
+}
+""",
+ 'lib.dart': """
+library lib;
+
+class Super {
+ int _private;
+
+ int magic() => _private++;
+}
+"""
+};
+
+runTest(bool preserveUris) {
+ OutputCollector collector = new OutputCollector();
+ var options = ["--minify"];
+ if (preserveUris) options.add("--preserve-uris");
+ var compiler = compilerFor(MEMORY_SOURCE_FILES,
+ outputProvider: collector,
+ options: options);
+ return compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) {
+ String jsOutput = collector.getOutput('', 'js');
+ Expect.equals(preserveUris, jsOutput.contains("main.dart"));
+ Expect.equals(preserveUris, jsOutput.contains("lib.dart"));
+ });
+}
+
+void main() {
+ asyncStart();
+ new Future.value()
+ .then((_) => runTest(true))
+ .then((_) => runTest(false))
+ .whenComplete(asyncEnd);
+}
« no previous file with comments | « sdk/lib/_internal/pub_generated/lib/src/dart.dart ('k') | tests/compiler/dart2js/uri_retention_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698