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