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 "native_testing.dart"; |
6 | 6 |
7 // Test that native classes can use ordinary Dart classes as mixins. | 7 // Test that native classes can use ordinary Dart classes as mixins. |
8 | 8 |
9 @Native("A") | 9 @Native("A") |
10 class A { | 10 class A { |
11 foo() => "A-foo"; | 11 foo() => "A-foo"; |
12 baz() => "A-baz"; | 12 baz() => "A-baz"; |
13 } | 13 } |
14 | 14 |
15 @Native("B") | 15 @Native("B") |
16 class B extends A with M1, M2 { | 16 class B extends A with M1, M2 { |
17 bar() => baz(); | 17 bar() => baz(); |
18 } | 18 } |
19 | 19 |
20 class M1 { | 20 class M1 { |
21 foo() => "M1-foo"; | 21 foo() => "M1-foo"; |
22 baz() => "M1-baz"; | 22 baz() => "M1-baz"; |
23 } | 23 } |
24 | 24 |
25 class M2 { | 25 class M2 { |
26 foo() => "M2-foo"; | 26 foo() => "M2-foo"; |
27 } | 27 } |
28 | 28 |
29 A makeA() native ; | 29 A makeA() native; |
30 B makeB() native ; | 30 B makeB() native; |
31 | 31 |
32 void setup() native """ | 32 void setup() native """ |
33 function A() {} | 33 function A() {} |
34 function B() {} | 34 function B() {} |
35 makeA = function(){return new A;}; | 35 makeA = function(){return new A;}; |
36 makeB = function(){return new B;}; | 36 makeB = function(){return new B;}; |
37 | 37 |
38 self.nativeConstructor(A); | 38 self.nativeConstructor(A); |
39 self.nativeConstructor(B); | 39 self.nativeConstructor(B); |
40 """; | 40 """; |
(...skipping 30 matching lines...) Expand all Loading... |
71 | 71 |
72 M2 m2 = new M2(); | 72 M2 m2 = new M2(); |
73 Expect.equals("M2-foo", m2.foo()); | 73 Expect.equals("M2-foo", m2.foo()); |
74 Expect.throws(() => m2.bar(), (error) => error is NoSuchMethodError); | 74 Expect.throws(() => m2.bar(), (error) => error is NoSuchMethodError); |
75 Expect.throws(() => m2.baz(), (error) => error is NoSuchMethodError); | 75 Expect.throws(() => m2.baz(), (error) => error is NoSuchMethodError); |
76 Expect.isFalse(m2 is A); | 76 Expect.isFalse(m2 is A); |
77 Expect.isFalse(m2 is B); | 77 Expect.isFalse(m2 is B); |
78 Expect.isFalse(m2 is M1); | 78 Expect.isFalse(m2 is M1); |
79 Expect.isTrue(m2 is M2); | 79 Expect.isTrue(m2 is M2); |
80 } | 80 } |
OLD | NEW |