Index: tests/compiler/dart2js_native/multiscript_part1_test.dart |
diff --git a/tests/compiler/dart2js_native/multiscript_part1_test.dart b/tests/compiler/dart2js_native/multiscript_part1_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7be9c6e2efa7c9d0f20b48848e2890ad88d7968b |
--- /dev/null |
+++ b/tests/compiler/dart2js_native/multiscript_part1_test.dart |
@@ -0,0 +1,34 @@ |
+// 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 "package:expect/expect.dart"; |
+ |
+// Methods on (shared) native classes should have DOM isolate affinity. |
+// Test that part1 and part2 can be loaded into the same JavaScript context |
+// without conflicts. |
+ |
+class A native "AA" { |
+ // [foo] is the same in both isolates but optimized differently. |
+ foo(x) => x is String; |
+ |
+ // [bar] has different definitions in the two isolates. |
+ bar(x) => 'one:$x'; |
+} |
+ |
+makeA() native; |
+ |
+void setup() native """ |
+// Use existing definition if present to force sharing. |
+if (typeof AA == "undefined") { |
+ AA = function AA() {}; |
+} |
+makeA = function(){return new AA;}; |
+"""; |
+ |
+main() { |
+ setup(); |
+ |
+ Expect.equals(true, makeA().foo('hi')); |
+ Expect.equals('one:hi', makeA().bar('hi')); |
+} |