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 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
9 import 'native_library_same_name_used_lib1.dart'; | 10 import 'native_library_same_name_used_lib1.dart'; |
10 | 11 |
11 void setup() native """ | 12 void setup() native """ |
12 // 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. |
13 function I(){} | 14 function I(){} |
14 I.prototype.read = function() { return this._x; }; | 15 I.prototype.read = function() { return this._x; }; |
15 I.prototype.write = function(x) { this._x = x; }; | 16 I.prototype.write = function(x) { this._x = x; }; |
16 makeI = function(){return new I}; | 17 makeI = function(){return new I}; |
17 """; | 18 """; |
18 | 19 |
19 // A pure Dart implementation of I. | 20 // A pure Dart implementation of I. |
20 | 21 |
21 class ProxyI implements I { | 22 class ProxyI implements I { |
22 ProxyI b; | 23 ProxyI b; |
23 ProxyI read() { return b; } | 24 ProxyI read() { |
24 write(ProxyI x) { b = x; } | 25 return b; |
| 26 } |
| 27 |
| 28 write(ProxyI x) { |
| 29 b = x; |
| 30 } |
25 } | 31 } |
26 | 32 |
27 main() { | 33 main() { |
28 setup(); | 34 setup(); |
29 | 35 |
30 var a1 = makeI(); | 36 var a1 = makeI(); |
31 var a2 = makeI(); | 37 var a2 = makeI(); |
32 var b1 = new ProxyI(); | 38 var b1 = new ProxyI(); |
33 var b2 = new ProxyI(); | 39 var b2 = new ProxyI(); |
34 var ob = new Object(); | 40 var ob = new Object(); |
35 | 41 |
36 Expect.isFalse(ob is I, 'ob is I'); | 42 Expect.isFalse(ob is I, 'ob is I'); |
37 Expect.isFalse(ob is ProxyI, 'ob is ProxyI'); | 43 Expect.isFalse(ob is ProxyI, 'ob is ProxyI'); |
38 | 44 |
39 Expect.isTrue(b1 is I, 'b1 is I'); | 45 Expect.isTrue(b1 is I, 'b1 is I'); |
40 Expect.isTrue(b1 is ProxyI, 'b1 is ProxyI'); | 46 Expect.isTrue(b1 is ProxyI, 'b1 is ProxyI'); |
41 | 47 |
42 Expect.isTrue(a1 is I, 'a1 is I'); | 48 Expect.isTrue(a1 is I, 'a1 is I'); |
43 Expect.isFalse(a1 is ProxyI, 'a1 is ProxyI'); | 49 Expect.isFalse(a1 is ProxyI, 'a1 is ProxyI'); |
44 } | 50 } |
OLD | NEW |