| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test for correct simple is-checks on hidden native classes. | 5 // Test for correct simple is-checks on hidden native classes. |
| 6 | 6 |
| 7 import 'native_metadata.dart'; |
| 8 |
| 7 interface J { | 9 interface J { |
| 8 } | 10 } |
| 9 | 11 |
| 10 interface I extends J { | 12 interface I extends J { |
| 11 I read(); | 13 I read(); |
| 12 write(I x); | 14 write(I x); |
| 13 } | 15 } |
| 14 | 16 |
| 15 // Native implementation. | 17 // Native implementation. |
| 16 | 18 |
| 17 @native("*A") | 19 @Native("*A") |
| 18 class A implements I { | 20 class A implements I { |
| 19 // The native class accepts only other native instances. | 21 // The native class accepts only other native instances. |
| 20 @native A read(); | 22 @native A read(); |
| 21 @native write(A x); | 23 @native write(A x); |
| 22 } | 24 } |
| 23 | 25 |
| 24 @native("*B") | 26 @Native("*B") |
| 25 class B extends A { | 27 class B extends A { |
| 26 } | 28 } |
| 27 | 29 |
| 28 @native makeA(); | 30 @native makeA(); |
| 29 @native makeB(); | 31 @native makeB(); |
| 30 | 32 |
| 31 @native(""" | 33 @Native(""" |
| 32 // This code is all inside 'setup' and so not accesible from the global scope. | 34 // This code is all inside 'setup' and so not accesible from the global scope. |
| 33 function inherits(child, parent) { | 35 function inherits(child, parent) { |
| 34 if (child.prototype.__proto__) { | 36 if (child.prototype.__proto__) { |
| 35 child.prototype.__proto__ = parent.prototype; | 37 child.prototype.__proto__ = parent.prototype; |
| 36 } else { | 38 } else { |
| 37 function tmp() {}; | 39 function tmp() {}; |
| 38 tmp.prototype = parent.prototype; | 40 tmp.prototype = parent.prototype; |
| 39 child.prototype = new tmp(); | 41 child.prototype = new tmp(); |
| 40 child.prototype.constructor = child; | 42 child.prototype.constructor = child; |
| 41 } | 43 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 71 Expect.isTrue(b1 is A); | 73 Expect.isTrue(b1 is A); |
| 72 Expect.isTrue(b1 is B); | 74 Expect.isTrue(b1 is B); |
| 73 Expect.isTrue(b1 is !C); | 75 Expect.isTrue(b1 is !C); |
| 74 | 76 |
| 75 Expect.isTrue(a1 is J); | 77 Expect.isTrue(a1 is J); |
| 76 Expect.isTrue(a1 is I); | 78 Expect.isTrue(a1 is I); |
| 77 Expect.isTrue(a1 is A); | 79 Expect.isTrue(a1 is A); |
| 78 Expect.isTrue(a1 is !B); | 80 Expect.isTrue(a1 is !B); |
| 79 Expect.isTrue(a1 is !C); | 81 Expect.isTrue(a1 is !C); |
| 80 } | 82 } |
| OLD | NEW |