| 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 hidden native class when abstract class has same name. | 5 // Test for correct hidden native class when abstract class has same name. |
| 6 | 6 |
| 7 library main; | 7 library main; |
| 8 | 8 |
| 9 import 'native_testing.dart'; | 9 import "package:expect/expect.dart"; |
| 10 import 'native_library_same_name_used_lib1.dart'; | 10 import 'native_library_same_name_used_lib1.dart'; |
| 11 | 11 |
| 12 void setup() native """ | 12 void setup() native """ |
| 13 // This code is all inside 'setup' and so not accesible from the global scope. | 13 // This code is all inside 'setup' and so not accesible from the global scope. |
| 14 function I(){} | 14 function I(){} |
| 15 I.prototype.read = function() { return this._x; }; | 15 I.prototype.read = function() { return this._x; }; |
| 16 I.prototype.write = function(x) { this._x = x; }; | 16 I.prototype.write = function(x) { this._x = x; }; |
| 17 makeI = function(){return new I}; | 17 makeI = function(){return new I}; |
| 18 self.nativeConstructor(I); | |
| 19 """; | 18 """; |
| 20 | 19 |
| 21 // A pure Dart implementation of I. | 20 // A pure Dart implementation of I. |
| 22 | 21 |
| 23 class ProxyI implements I { | 22 class ProxyI implements I { |
| 24 ProxyI b; | 23 ProxyI b; |
| 25 ProxyI read() { | 24 ProxyI read() { |
| 26 return b; | 25 return b; |
| 27 } | 26 } |
| 28 | 27 |
| 29 write(ProxyI x) { | 28 write(ProxyI x) { |
| 30 b = x; | 29 b = x; |
| 31 } | 30 } |
| 32 } | 31 } |
| 33 | 32 |
| 34 main() { | 33 main() { |
| 35 nativeTesting(); | |
| 36 setup(); | 34 setup(); |
| 37 | 35 |
| 38 var a1 = makeI(); | 36 var a1 = makeI(); |
| 39 var a2 = makeI(); | 37 var a2 = makeI(); |
| 40 var b1 = new ProxyI(); | 38 var b1 = new ProxyI(); |
| 41 var b2 = new ProxyI(); | 39 var b2 = new ProxyI(); |
| 42 var ob = new Object(); | 40 var ob = new Object(); |
| 43 | 41 |
| 44 Expect.isFalse(ob is I, 'ob is I'); | 42 Expect.isFalse(ob is I, 'ob is I'); |
| 45 Expect.isFalse(ob is ProxyI, 'ob is ProxyI'); | 43 Expect.isFalse(ob is ProxyI, 'ob is ProxyI'); |
| 46 | 44 |
| 47 Expect.isTrue(b1 is I, 'b1 is I'); | 45 Expect.isTrue(b1 is I, 'b1 is I'); |
| 48 Expect.isTrue(b1 is ProxyI, 'b1 is ProxyI'); | 46 Expect.isTrue(b1 is ProxyI, 'b1 is ProxyI'); |
| 49 | 47 |
| 50 Expect.isTrue(a1 is I, 'a1 is I'); | 48 Expect.isTrue(a1 is I, 'a1 is I'); |
| 51 Expect.isFalse(a1 is ProxyI, 'a1 is ProxyI'); | 49 Expect.isFalse(a1 is ProxyI, 'a1 is ProxyI'); |
| 52 | |
| 53 Expect.isTrue(confuse(a1) is I, 'a1 is I'); | |
| 54 Expect.isFalse(confuse(a1) is ProxyI, 'a1 is ProxyI'); | |
| 55 } | 50 } |
| OLD | NEW |