| 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 // Test that native classes can use ordinary Dart classes with fields |
| 6 // as mixins. |
| 7 |
| 8 class A native "*A" { |
| 9 var foo; |
| 10 } |
| 11 |
| 12 class B extends A with M1, M2 native "*B" { |
| 13 var bar; |
| 14 } |
| 15 |
| 16 class M1 { |
| 17 var baz; |
| 18 } |
| 19 |
| 20 class M2 { |
| 21 var bar; |
| 22 var buz; |
| 23 } |
| 24 |
| 25 A makeA() native; |
| 26 B makeB() native; |
| 27 |
| 28 void setup() native """ |
| 29 function A() {this.foo='A-foo';} |
| 30 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';} |
| 31 makeA = function(){return new A;}; |
| 32 makeB = function(){return new B;}; |
| 33 """; |
| 34 |
| 35 main() { |
| 36 setup(); |
| 37 A a = makeA(); |
| 38 Expect.equals("A-foo", a.foo); |
| 39 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError); |
| 40 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError); |
| 41 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError); |
| 42 |
| 43 B b = makeB(); |
| 44 Expect.equals("A-foo", b.foo); |
| 45 Expect.equals("B-bar", b.bar); |
| 46 Expect.equals("M1-baz", b.baz); |
| 47 Expect.isNull(b.buz); |
| 48 |
| 49 M1 m1 = new M1(); |
| 50 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError); |
| 51 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError); |
| 52 Expect.isNull(m1.baz); |
| 53 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError); |
| 54 |
| 55 M2 m2 = new M2(); |
| 56 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError); |
| 57 Expect.isNull(m2.bar); |
| 58 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError); |
| 59 Expect.isNull(m2.buz); |
| 60 } |
| OLD | NEW |