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 "dart:_js_helper"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // 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 |
9 // the same mixin. | 9 // the same mixin. |
10 | 10 |
11 | 11 class D extends Object with M1, M2, M3 {} |
12 class D extends Object with M1, M2, M3 { | |
13 } | |
14 | 12 |
15 class E extends D { | 13 class E extends D { |
16 foo() => 'E.foo'; | 14 foo() => 'E.foo'; |
17 } | 15 } |
18 | 16 |
19 class M1 { } | 17 class M1 {} |
20 | 18 |
21 class M2 { | 19 class M2 { |
22 foo() => 'M2.foo'; | 20 foo() => 'M2.foo'; |
23 } | 21 } |
24 | 22 |
25 class M3 { } | 23 class M3 {} |
26 | 24 |
27 @Native("A") | 25 @Native("A") |
28 class A { | 26 class A { |
29 foo() => 'A.foo'; | 27 foo() => 'A.foo'; |
30 } | 28 } |
31 | 29 |
32 @Native("B") | 30 @Native("B") |
33 class B extends A with M1, M2, M3 {} | 31 class B extends A with M1, M2, M3 {} |
34 | 32 |
35 @Native("C") | 33 @Native("C") |
36 class C extends B { | 34 class C extends B { |
37 foo() => 'C.foo'; | 35 foo() => 'C.foo'; |
38 } | 36 } |
39 | 37 |
40 makeA() native; | 38 makeA() native ; |
41 makeB() native; | 39 makeB() native ; |
42 makeC() native; | 40 makeC() native ; |
43 | 41 |
44 void setup() native """ | 42 void setup() native """ |
45 function A() {} | 43 function A() {} |
46 function B() {} | 44 function B() {} |
47 function C() {} | 45 function C() {} |
48 makeA = function(){return new A;}; | 46 makeA = function(){return new A;}; |
49 makeB = function(){return new B;}; | 47 makeB = function(){return new B;}; |
50 makeC = function(){return new C;}; | 48 makeC = function(){return new C;}; |
51 """; | 49 """; |
52 | 50 |
(...skipping 27 matching lines...) Expand all Loading... |
80 var e = x[4]; | 78 var e = x[4]; |
81 | 79 |
82 var f = callFoo; | 80 var f = callFoo; |
83 | 81 |
84 Expect.equals('A.foo', f(a)); | 82 Expect.equals('A.foo', f(a)); |
85 Expect.equals('M2.foo', f(b)); | 83 Expect.equals('M2.foo', f(b)); |
86 Expect.equals('C.foo', f(c)); | 84 Expect.equals('C.foo', f(c)); |
87 Expect.equals('M2.foo', f(d)); | 85 Expect.equals('M2.foo', f(d)); |
88 Expect.equals('E.foo', f(e)); | 86 Expect.equals('E.foo', f(e)); |
89 } | 87 } |
OLD | NEW |