OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 |
| 7 // Methods on (shared) native classes should have DOM isolate affinity. |
| 8 // Test that part1 and part2 can be loaded into the same JavaScript context |
| 9 // without conflicts. |
| 10 |
| 11 class A native "AA" { |
| 12 // [foo] is the same in both isolates but optimized differently. |
| 13 foo(x) => x is String; |
| 14 |
| 15 // [bar] has different definitions in the two isolates. |
| 16 bar(x) => 'two:$x'; |
| 17 } |
| 18 |
| 19 makeA() native; |
| 20 |
| 21 void setup() native """ |
| 22 // Use existing definition if present to force sharing. |
| 23 if (typeof AA == "undefined") { |
| 24 AA = function AA() {}; |
| 25 } |
| 26 makeA = function(){return new AA;}; |
| 27 """; |
| 28 |
| 29 main() { |
| 30 setup(); |
| 31 |
| 32 Expect.equals(false, makeA().foo(123)); |
| 33 Expect.equals('two:hi', makeA().bar('hi')); |
| 34 } |
OLD | NEW |