| 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 M { | 16 class B extends A with M { |
| 17 bar() => baz(); | 17 bar() => baz(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 class M { | 20 class M { |
| 21 foo() => "M-foo"; | 21 foo() => "M-foo"; |
| 22 bar() => "M-bar"; | 22 bar() => "M-bar"; |
| 23 } | 23 } |
| 24 | 24 |
| 25 A makeA() native ; | 25 A makeA() native; |
| 26 B makeB() native ; | 26 B makeB() native; |
| 27 | 27 |
| 28 void setup() native """ | 28 void setup() native """ |
| 29 function A() {} | 29 function A() {} |
| 30 function B() {} | 30 function B() {} |
| 31 makeA = function(){return new A;}; | 31 makeA = function(){return new A;}; |
| 32 makeB = function(){return new B;}; | 32 makeB = function(){return new B;}; |
| 33 | 33 |
| 34 self.nativeConstructor(A); | 34 self.nativeConstructor(A); |
| 35 self.nativeConstructor(B); | 35 self.nativeConstructor(B); |
| 36 """; | 36 """; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 55 Expect.isTrue(b is M); | 55 Expect.isTrue(b is M); |
| 56 | 56 |
| 57 M m = new M(); | 57 M m = new M(); |
| 58 Expect.equals("M-foo", m.foo()); | 58 Expect.equals("M-foo", m.foo()); |
| 59 Expect.equals("M-bar", m.bar()); | 59 Expect.equals("M-bar", m.bar()); |
| 60 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); | 60 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); |
| 61 Expect.isFalse(m is A); | 61 Expect.isFalse(m is A); |
| 62 Expect.isFalse(m is B); | 62 Expect.isFalse(m is B); |
| 63 Expect.isTrue(m is M); | 63 Expect.isTrue(m is M); |
| 64 } | 64 } |
| OLD | NEW |