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

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

Issue 12051056: Allow native classes to mixin behavior from an ordinary Dart class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactor. Created 7 years, 11 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
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 // Test that native classes can use ordinary Dart classes as mixins.
6
7 class A native "*A" {
8 foo() => 42;
9 baz() => 99;
10 }
11
12 class B extends A with M native "*B" {
13 bar() => baz();
14 }
15
16 class M {
17 foo() => 87;
18 bar() => 101;
19 }
20
21 A makeA() native;
22 B makeB() native;
23
24 void setup() native """
25 function A() {}
26 function B() {}
27 makeA = function(){return new A;};
28 makeB = function(){return new B;};
29 """;
30
31 main() {
32 setup();
33 A a = makeA();
34 Expect.equals(42, a.foo());
35 Expect.throws(() => a.bar(), (error) => error is NoSuchMethodError);
36 Expect.equals(99, a.baz());
37 Expect.isTrue(a is A);
38 Expect.isFalse(a is B);
39 Expect.isFalse(a is M);
40
41 B b = makeB();
42 Expect.equals(87, b.foo());
43 Expect.equals(99, b.bar());
44 Expect.equals(99, b.baz());
45 Expect.isTrue(b is A);
46 Expect.isTrue(b is B);
47 Expect.isTrue(b is M);
48
49 M m = new M();
50 Expect.equals(87, m.foo());
51 Expect.equals(101, m.bar());
52 Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError);
53 Expect.isFalse(m is A);
54 Expect.isFalse(m is B);
55 Expect.isTrue(m is M);
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698