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

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

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

Powered by Google App Engine
This is Rietveld 408576698