Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tests/compiler/dart2js_native/native_mixin_with_plain_test.dart

Issue 13685022: Make mixins work on native classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js_native/dart2js_native.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 import "package:expect/expect.dart";
6
7 // Test that native classes and ordinary Dart classes can both use the same
8 // ordinary Dart classes as a mixin.
9
10 class A native "*A" {
11 final String aa;
12 foo() => "A-foo $aa";
13 baz() => "A-baz $aa";
14 }
15
16 class B extends A with M native "*B" {
17 bar() => 'B-bar -> ${baz()}';
18 get mm => 'B.mm($aa)';
19 }
20
21 class M {
22 foo() => "M-foo ${this.mm}";
23 bar() => "M-bar ${this.mm}";
24 get mm => 'M.mm';
25 }
26
27 class C {
28 final String cc = 'cc';
29 foo() => 'C-foo $cc';
30 baz() => 'C-baz $cc';
31 }
32
33 class D extends C with M {
34 bar() => 'D-bar -> ${baz()}';
35 get mm => 'D.mm($cc)';
36 }
37
38
39 makeA() native;
40 makeB() native;
41
42 void setup() native """
43 function A() {this.aa = 'aa'}
44 function B() {this.aa = 'bb'}
45 makeA = function(){return new A;};
46 makeB = function(){return new B;};
47 """;
48
49 main() {
50 setup();
51 var things = [makeA, makeB, () => new C(), () => new D(), () => new M()]
52 .map((f)=>f())
53 .toList();
54 var a = things[0];
55 var b = things[1];
56 var c = things[2];
57 var d = things[3];
58 var m = things[4];
59
60 Expect.equals("M-foo M.mm", m.foo());
61 Expect.equals("M-bar M.mm", m.bar());
62 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError);
63 Expect.isFalse(m is A);
64 Expect.isFalse(m is B);
65 Expect.isFalse(m is C);
66 Expect.isFalse(m is D);
67 Expect.isTrue(m is M);
68
69 Expect.equals("A-foo aa", a.foo());
70 Expect.throws(() => a.bar(), (error) => error is NoSuchMethodError);
71 Expect.equals("A-baz aa", a.baz());
72 Expect.isTrue(a is A);
73 Expect.isFalse(a is B);
74 Expect.isFalse(a is C);
75 Expect.isFalse(a is D);
76 Expect.isFalse(a is M);
77
78 Expect.equals("M-foo B.mm(bb)", b.foo());
79 Expect.equals("B-bar -> A-baz bb", b.bar());
80 Expect.equals("A-baz bb", b.baz());
81 Expect.isTrue(b is A);
82 Expect.isTrue(b is B);
83 Expect.isFalse(b is C);
84 Expect.isFalse(b is D);
85 Expect.isTrue(b is M);
86
87 Expect.equals("C-foo cc", c.foo());
88 Expect.throws(() => c.bar(), (error) => error is NoSuchMethodError);
89 Expect.equals("C-baz cc", c.baz());
90 Expect.isFalse(c is A);
91 Expect.isFalse(c is B);
92 Expect.isTrue(c is C);
93 Expect.isFalse(c is D);
94 Expect.isFalse(c is M);
95
96 Expect.equals("M-foo D.mm(cc)", d.foo());
97 Expect.equals("D-bar -> C-baz cc", d.bar());
98 Expect.equals("C-baz cc", d.baz());
99 Expect.isFalse(d is A);
100 Expect.isFalse(d is B);
101 Expect.isTrue(d is C);
102 Expect.isTrue(d is D);
103 Expect.isTrue(d is M);
104
105 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/dart2js_native.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698