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

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

Issue 141023007: Emit the type test support code to the right output unit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 6 years, 11 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/compiler/implementation/js_emitter/type_test_emitter.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/deferred_emit_type_checks_test.dart
diff --git a/tests/compiler/dart2js/deferred_emit_type_checks_test.dart b/tests/compiler/dart2js/deferred_emit_type_checks_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..890397ab8f23d29c823ea561c3953c11b0e47143
--- /dev/null
+++ b/tests/compiler/dart2js/deferred_emit_type_checks_test.dart
@@ -0,0 +1,83 @@
+// 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.
+
+// Test that the additional runtime type support is output to the right
+// Files when using deferred loading.
+
+import 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+import 'memory_source_file_helper.dart';
+import "dart:async";
+
+import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
+ as dart2js;
+
+class MemoryOutputSink<T> extends EventSink<T> {
+ List<T> mem = new List<T>();
+ void add(T event) {
+ mem.add(event);
+ }
+ void addError(T event, [StackTrace stackTrace]) {}
+ void close() {}
+}
+
+void main() {
+ Uri script = currentDirectory.resolveUri(Platform.script);
+ Uri libraryRoot = script.resolve('../../../sdk/');
+ Uri packageRoot = script.resolve('./packages/');
+
+ var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
+ var handler = new FormattingDiagnosticHandler(provider);
+
+ Map<String, MemoryOutputSink> outputs = new Map<String, MemoryOutputSink>();
+
+ MemoryOutputSink outputSaver(name, extension) {
+ if (name == '') {
+ name = 'main';
+ extension ='js';
+ }
+ return outputs.putIfAbsent("$name.$extension", () {
+ return new MemoryOutputSink();
+ });
+ }
+
+ Compiler compiler = new Compiler(provider.readStringFromUri,
+ outputSaver,
+ handler.diagnosticHandler,
+ libraryRoot,
+ packageRoot,
+ [],
+ {});
+ asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
+ String mainOutput = outputs['main.js'].mem[0];
+ String deferredOutput = outputs['deferred.js'].mem[0];
+ RegExp re = new RegExp(r"\n.\.A\.\$isA = true;");
+ print(deferredOutput);
+ Expect.isTrue(re.hasMatch(deferredOutput));
+ Expect.isFalse(re.hasMatch(mainOutput));
+ }));
+}
+
+// We force additional runtime type support to be output for A by instantiating
+// it with a type argument, and testing for the type. The extra support should
+// go to the deferred hunk.
+const Map MEMORY_SOURCE_FILES = const {"main.dart": """
+import "dart:async";
+
+@def import 'lib.dart' show f, A;
+
+const def = const DeferredLibrary("deferred");
+
+void main() {
+ def.load().then((_) {
+ print(f(new A<A>()));
+ });
+}
+""", "lib.dart": """
+class A<T> {}
+
+bool f (Object o) {
+ return o is A<A>;
+}
+""",};
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_emitter/type_test_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698