OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "dart:_js_helper"; | 5 import "native_testing.dart"; |
6 import "package:expect/expect.dart"; | |
7 | 6 |
8 // Test that native classes and plain classes can access methods defined only by | 7 // Test that native classes and plain classes can access methods defined only by |
9 // the same mixin. | 8 // the same mixin. |
10 | 9 |
11 class D extends Object with M1, M2, M3 {} | 10 class D extends Object with M1, M2, M3 {} |
12 | 11 |
13 class E extends D { | 12 class E extends D { |
14 foo() => 'E.foo'; | 13 foo() => 'E.foo'; |
15 } | 14 } |
16 | 15 |
(...skipping 22 matching lines...) Expand all Loading... |
39 makeB() native ; | 38 makeB() native ; |
40 makeC() native ; | 39 makeC() native ; |
41 | 40 |
42 void setup() native """ | 41 void setup() native """ |
43 function A() {} | 42 function A() {} |
44 function B() {} | 43 function B() {} |
45 function C() {} | 44 function C() {} |
46 makeA = function(){return new A;}; | 45 makeA = function(){return new A;}; |
47 makeB = function(){return new B;}; | 46 makeB = function(){return new B;}; |
48 makeC = function(){return new C;}; | 47 makeC = function(){return new C;}; |
| 48 |
| 49 self.nativeConstructor(A); |
| 50 self.nativeConstructor(B); |
| 51 self.nativeConstructor(C); |
49 """; | 52 """; |
50 | 53 |
51 var g; | 54 var g; |
52 | 55 |
53 callFoo(x) { | 56 callFoo(x) { |
54 // Dominating getInterceptor call should be shared. | 57 // Dominating getInterceptor call should be shared. |
55 g = x.toString(); | 58 g = x.toString(); |
56 // These call sites are partitioned into pure-dart and native subsets, | 59 // These call sites are partitioned into pure-dart and native subsets, |
57 // allowing differences in getInterceptors. | 60 // allowing differences in getInterceptors. |
58 if (x is D) return x.foo(); | 61 if (x is D) return x.foo(); |
59 if (x is A) return x.foo(); | 62 if (x is A) return x.foo(); |
60 } | 63 } |
61 | 64 |
62 makeAll() => [makeA(), makeB(), makeC(), new D(), new E()]; | 65 makeAll() => [makeA(), makeB(), makeC(), new D(), new E()]; |
63 | 66 |
64 main() { | 67 main() { |
| 68 nativeTesting(); |
65 setup(); | 69 setup(); |
66 /* | 70 /* |
67 var a = makeA(); | 71 var a = makeA(); |
68 var b = makeB(); | 72 var b = makeB(); |
69 var c = makeC(); | 73 var c = makeC(); |
70 var d = new D(); | 74 var d = new D(); |
71 var e = new E(); | 75 var e = new E(); |
72 */ | 76 */ |
73 var x = makeAll(); | 77 var x = makeAll(); |
74 var a = x[0]; | 78 var a = x[0]; |
75 var b = x[1]; | 79 var b = x[1]; |
76 var c = x[2]; | 80 var c = x[2]; |
77 var d = x[3]; | 81 var d = x[3]; |
78 var e = x[4]; | 82 var e = x[4]; |
79 | 83 |
80 var f = callFoo; | 84 var f = callFoo; |
81 | 85 |
82 Expect.equals('A.foo', f(a)); | 86 Expect.equals('A.foo', f(a)); |
83 Expect.equals('M2.foo', f(b)); | 87 Expect.equals('M2.foo', f(b)); |
84 Expect.equals('C.foo', f(c)); | 88 Expect.equals('C.foo', f(c)); |
85 Expect.equals('M2.foo', f(d)); | 89 Expect.equals('M2.foo', f(d)); |
86 Expect.equals('E.foo', f(e)); | 90 Expect.equals('E.foo', f(e)); |
87 } | 91 } |
OLD | NEW |