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