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

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

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

Powered by Google App Engine
This is Rietveld 408576698