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 "native_testing.dart"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // 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 |
8 // ordinary Dart classes as a mixin. | 9 // ordinary Dart classes as a mixin. |
9 | 10 |
10 @Native("A") | 11 @Native("A") |
11 class A { | 12 class A { |
12 final String aa; | 13 final String aa; |
13 foo() => "A-foo $aa"; | 14 foo() => "A-foo $aa"; |
14 baz() => "A-baz $aa"; | 15 baz() => "A-baz $aa"; |
15 } | 16 } |
(...skipping 22 matching lines...) Expand all Loading... |
38 } | 39 } |
39 | 40 |
40 makeA() native ; | 41 makeA() native ; |
41 makeB() native ; | 42 makeB() native ; |
42 | 43 |
43 void setup() native """ | 44 void setup() native """ |
44 function A() {this.aa = 'aa'} | 45 function A() {this.aa = 'aa'} |
45 function B() {this.aa = 'bb'} | 46 function B() {this.aa = 'bb'} |
46 makeA = function(){return new A;}; | 47 makeA = function(){return new A;}; |
47 makeB = function(){return new B;}; | 48 makeB = function(){return new B;}; |
48 | |
49 self.nativeConstructor(A); | |
50 self.nativeConstructor(B); | |
51 """; | 49 """; |
52 | 50 |
53 main() { | 51 main() { |
54 nativeTesting(); | |
55 setup(); | 52 setup(); |
56 var things = [makeA, makeB, () => new C(), () => new D(), () => new M()] | 53 var things = [makeA, makeB, () => new C(), () => new D(), () => new M()] |
57 .map((f) => f()) | 54 .map((f) => f()) |
58 .toList(); | 55 .toList(); |
59 var a = things[0]; | 56 var a = things[0]; |
60 var b = things[1]; | 57 var b = things[1]; |
61 var c = things[2]; | 58 var c = things[2]; |
62 var d = things[3]; | 59 var d = things[3]; |
63 var m = things[4]; | 60 var m = things[4]; |
64 | 61 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 97 |
101 Expect.equals("M-foo D.mm(cc)", d.foo()); | 98 Expect.equals("M-foo D.mm(cc)", d.foo()); |
102 Expect.equals("D-bar -> C-baz cc", d.bar()); | 99 Expect.equals("D-bar -> C-baz cc", d.bar()); |
103 Expect.equals("C-baz cc", d.baz()); | 100 Expect.equals("C-baz cc", d.baz()); |
104 Expect.isFalse(d is A); | 101 Expect.isFalse(d is A); |
105 Expect.isFalse(d is B); | 102 Expect.isFalse(d is B); |
106 Expect.isTrue(d is C); | 103 Expect.isTrue(d is C); |
107 Expect.isTrue(d is D); | 104 Expect.isTrue(d is D); |
108 Expect.isTrue(d is M); | 105 Expect.isTrue(d is M); |
109 } | 106 } |
OLD | NEW |