| 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 M1, M2 { | 17 class B extends A with M1, M2 { |
| 18 bar() => baz(); | 18 bar() => baz(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 class M1 { | 21 class M1 { |
| 22 foo() => "M1-foo"; | 22 foo() => "M1-foo"; |
| 23 baz() => "M1-baz"; | 23 baz() => "M1-baz"; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class M2 { | 26 class M2 { |
| 27 foo() => "M2-foo"; | 27 foo() => "M2-foo"; |
| 28 } | 28 } |
| 29 | 29 |
| 30 A makeA() native; | 30 A makeA() native ; |
| 31 B makeB() native; | 31 B makeB() native ; |
| 32 | 32 |
| 33 void setup() native """ | 33 void setup() native """ |
| 34 function A() {} | 34 function A() {} |
| 35 function B() {} | 35 function B() {} |
| 36 makeA = function(){return new A;}; | 36 makeA = function(){return new A;}; |
| 37 makeB = function(){return new B;}; | 37 makeB = function(){return new B;}; |
| 38 """; | 38 """; |
| 39 | 39 |
| 40 main() { | 40 main() { |
| 41 setup(); | 41 setup(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 | 68 |
| 69 M2 m2 = new M2(); | 69 M2 m2 = new M2(); |
| 70 Expect.equals("M2-foo", m2.foo()); | 70 Expect.equals("M2-foo", m2.foo()); |
| 71 Expect.throws(() => m2.bar(), (error) => error is NoSuchMethodError); | 71 Expect.throws(() => m2.bar(), (error) => error is NoSuchMethodError); |
| 72 Expect.throws(() => m2.baz(), (error) => error is NoSuchMethodError); | 72 Expect.throws(() => m2.baz(), (error) => error is NoSuchMethodError); |
| 73 Expect.isFalse(m2 is A); | 73 Expect.isFalse(m2 is A); |
| 74 Expect.isFalse(m2 is B); | 74 Expect.isFalse(m2 is B); |
| 75 Expect.isFalse(m2 is M1); | 75 Expect.isFalse(m2 is M1); |
| 76 Expect.isTrue(m2 is M2); | 76 Expect.isTrue(m2 is M2); |
| 77 } | 77 } |
| OLD | NEW |