| 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 and ordinary Dart classes can both use the same | 8 // Test that native classes and ordinary Dart classes can both use the same |
| 9 // ordinary Dart classes as a mixin. | 9 // ordinary Dart classes as a mixin. |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 final String cc = 'cc'; | 31 final String cc = 'cc'; |
| 32 foo() => 'C-foo $cc'; | 32 foo() => 'C-foo $cc'; |
| 33 baz() => 'C-baz $cc'; | 33 baz() => 'C-baz $cc'; |
| 34 } | 34 } |
| 35 | 35 |
| 36 class D extends C with M { | 36 class D extends C with M { |
| 37 bar() => 'D-bar -> ${baz()}'; | 37 bar() => 'D-bar -> ${baz()}'; |
| 38 get mm => 'D.mm($cc)'; | 38 get mm => 'D.mm($cc)'; |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 makeA() native ; |
| 42 makeA() native; | 42 makeB() native ; |
| 43 makeB() native; | |
| 44 | 43 |
| 45 void setup() native """ | 44 void setup() native """ |
| 46 function A() {this.aa = 'aa'} | 45 function A() {this.aa = 'aa'} |
| 47 function B() {this.aa = 'bb'} | 46 function B() {this.aa = 'bb'} |
| 48 makeA = function(){return new A;}; | 47 makeA = function(){return new A;}; |
| 49 makeB = function(){return new B;}; | 48 makeB = function(){return new B;}; |
| 50 """; | 49 """; |
| 51 | 50 |
| 52 main() { | 51 main() { |
| 53 setup(); | 52 setup(); |
| 54 var things = [makeA, makeB, () => new C(), () => new D(), () => new M()] | 53 var things = [makeA, makeB, () => new C(), () => new D(), () => new M()] |
| 55 .map((f)=>f()) | 54 .map((f) => f()) |
| 56 .toList(); | 55 .toList(); |
| 57 var a = things[0]; | 56 var a = things[0]; |
| 58 var b = things[1]; | 57 var b = things[1]; |
| 59 var c = things[2]; | 58 var c = things[2]; |
| 60 var d = things[3]; | 59 var d = things[3]; |
| 61 var m = things[4]; | 60 var m = things[4]; |
| 62 | 61 |
| 63 Expect.equals("M-foo M.mm", m.foo()); | 62 Expect.equals("M-foo M.mm", m.foo()); |
| 64 Expect.equals("M-bar M.mm", m.bar()); | 63 Expect.equals("M-bar M.mm", m.bar()); |
| 65 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); | 64 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 Expect.isFalse(c is M); | 96 Expect.isFalse(c is M); |
| 98 | 97 |
| 99 Expect.equals("M-foo D.mm(cc)", d.foo()); | 98 Expect.equals("M-foo D.mm(cc)", d.foo()); |
| 100 Expect.equals("D-bar -> C-baz cc", d.bar()); | 99 Expect.equals("D-bar -> C-baz cc", d.bar()); |
| 101 Expect.equals("C-baz cc", d.baz()); | 100 Expect.equals("C-baz cc", d.baz()); |
| 102 Expect.isFalse(d is A); | 101 Expect.isFalse(d is A); |
| 103 Expect.isFalse(d is B); | 102 Expect.isFalse(d is B); |
| 104 Expect.isTrue(d is C); | 103 Expect.isTrue(d is C); |
| 105 Expect.isTrue(d is D); | 104 Expect.isTrue(d is D); |
| 106 Expect.isTrue(d is M); | 105 Expect.isTrue(d is M); |
| 107 | |
| 108 } | 106 } |
| OLD | NEW |