| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, 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 // Native classes can have subclasses that are not declared to the program. The |
| 8 // subclasses are indistinguishable from the base class. This means that |
| 9 // abstract native classes can appear to have instances. |
| 10 |
| 11 abstract class A native "A" { |
| 12 } |
| 13 |
| 14 abstract class B native "B" { |
| 15 foo() native; |
| 16 } |
| 17 |
| 18 class C {} |
| 19 |
| 20 makeA() native; |
| 21 makeB() native; |
| 22 |
| 23 void setup() native """ |
| 24 // This code is all inside 'setup' and so not accesible from the global scope. |
| 25 function A(){} |
| 26 function B(){} |
| 27 B.prototype.foo = function() { return 'B.foo'; }; |
| 28 makeA = function(){return new A}; |
| 29 makeB = function(){return new B}; |
| 30 """; |
| 31 |
| 32 var inscrutable; |
| 33 main() { |
| 34 setup(); |
| 35 inscrutable = (x) => x; |
| 36 inscrutable = inscrutable(inscrutable); |
| 37 |
| 38 var a = makeA(); |
| 39 var b = makeB(); |
| 40 var c = inscrutable(new C()); |
| 41 |
| 42 Expect.isTrue(a is A); |
| 43 Expect.isFalse(b is A); |
| 44 Expect.isFalse(c is A); |
| 45 |
| 46 Expect.isFalse(a is B); |
| 47 Expect.isTrue(b is B); |
| 48 Expect.isFalse(c is B); |
| 49 |
| 50 Expect.isFalse(a is C); |
| 51 Expect.isFalse(b is C); |
| 52 Expect.isTrue(c is C); |
| 53 |
| 54 Expect.equals('B.foo', b.foo()); |
| 55 } |
| OLD | NEW |