| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 | |
| 7 // Test that native classes and plain classes can access methods defined only by | |
| 8 // the same mixin. | |
| 9 | |
| 10 | |
| 11 class D extends Object with M1, M2, M3 { | |
| 12 } | |
| 13 | |
| 14 class E extends D { | |
| 15 foo() => 'E.foo'; | |
| 16 } | |
| 17 | |
| 18 class M1 { } | |
| 19 | |
| 20 class M2 { | |
| 21 foo() => 'M2.foo'; | |
| 22 } | |
| 23 | |
| 24 class M3 { } | |
| 25 | |
| 26 class A native "A" { | |
| 27 foo() => 'A.foo'; | |
| 28 } | |
| 29 | |
| 30 class B extends A with M1, M2, M3 native "B" {} | |
| 31 | |
| 32 class C extends B native "C" { | |
| 33 foo() => 'C.foo'; | |
| 34 } | |
| 35 | |
| 36 makeA() native; | |
| 37 makeB() native; | |
| 38 makeC() native; | |
| 39 | |
| 40 void setup() native """ | |
| 41 function A() {} | |
| 42 function B() {} | |
| 43 function C() {} | |
| 44 makeA = function(){return new A;}; | |
| 45 makeB = function(){return new B;}; | |
| 46 makeC = function(){return new C;}; | |
| 47 """; | |
| 48 | |
| 49 var g; | |
| 50 | |
| 51 callFoo(x) { | |
| 52 // Dominating getInterceptor call should be shared. | |
| 53 g = x.toString(); | |
| 54 // These call sites are partitioned into pure-dart and native subsets, | |
| 55 // allowing differences in getInterceptors. | |
| 56 if (x is D) return x.foo(); | |
| 57 if (x is A) return x.foo(); | |
| 58 } | |
| 59 | |
| 60 makeAll() => [makeA(), makeB(), makeC(), new D(), new E()]; | |
| 61 | |
| 62 main() { | |
| 63 setup(); | |
| 64 /* | |
| 65 var a = makeA(); | |
| 66 var b = makeB(); | |
| 67 var c = makeC(); | |
| 68 var d = new D(); | |
| 69 var e = new E(); | |
| 70 */ | |
| 71 var x = makeAll(); | |
| 72 var a = x[0]; | |
| 73 var b = x[1]; | |
| 74 var c = x[2]; | |
| 75 var d = x[3]; | |
| 76 var e = x[4]; | |
| 77 | |
| 78 var f = callFoo; | |
| 79 | |
| 80 Expect.equals('A.foo', f(a)); | |
| 81 Expect.equals('M2.foo', f(b)); | |
| 82 Expect.equals('C.foo', f(c)); | |
| 83 Expect.equals('M2.foo', f(d)); | |
| 84 Expect.equals('E.foo', f(e)); | |
| 85 } | |
| OLD | NEW |