| 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 can use ordinary Dart classes as mixins. | 8 // Test that native classes can use ordinary Dart classes as mixins. |
| 9 | 9 |
| 10 @Native("A") | 10 @Native("A") |
| 11 class A { | 11 class A { |
| 12 foo() => "A-foo"; | 12 foo() => "A-foo"; |
| 13 baz() => "A-baz"; | 13 baz() => "A-baz"; |
| 14 } | 14 } |
| 15 | 15 |
| 16 @Native("B") | 16 @Native("B") |
| 17 class B extends A with M { | 17 class B extends A with M { |
| 18 bar() => baz(); | 18 bar() => baz(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 class M { | 21 class M { |
| 22 foo() => "M-foo"; | 22 foo() => "M-foo"; |
| 23 bar() => "M-bar"; | 23 bar() => "M-bar"; |
| 24 } | 24 } |
| 25 | 25 |
| 26 A makeA() native; | 26 A makeA() native ; |
| 27 B makeB() native; | 27 B makeB() native ; |
| 28 | 28 |
| 29 void setup() native """ | 29 void setup() native """ |
| 30 function A() {} | 30 function A() {} |
| 31 function B() {} | 31 function B() {} |
| 32 makeA = function(){return new A;}; | 32 makeA = function(){return new A;}; |
| 33 makeB = function(){return new B;}; | 33 makeB = function(){return new B;}; |
| 34 """; | 34 """; |
| 35 | 35 |
| 36 main() { | 36 main() { |
| 37 setup(); | 37 setup(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 52 Expect.isTrue(b is M); | 52 Expect.isTrue(b is M); |
| 53 | 53 |
| 54 M m = new M(); | 54 M m = new M(); |
| 55 Expect.equals("M-foo", m.foo()); | 55 Expect.equals("M-foo", m.foo()); |
| 56 Expect.equals("M-bar", m.bar()); | 56 Expect.equals("M-bar", m.bar()); |
| 57 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); | 57 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); |
| 58 Expect.isFalse(m is A); | 58 Expect.isFalse(m is A); |
| 59 Expect.isFalse(m is B); | 59 Expect.isFalse(m is B); |
| 60 Expect.isTrue(m is M); | 60 Expect.isTrue(m is M); |
| 61 } | 61 } |
| OLD | NEW |