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

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

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files Created 3 years, 4 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
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 "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 // Test that native classes can use ordinary Dart classes with fields 7 // Test that native classes can use ordinary Dart classes with fields
8 // as mixins. 8 // as mixins.
9 9
10 @Native("A") 10 @Native("A")
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 class M2 { 24 class M2 {
25 var bar; 25 var bar;
26 var buz; 26 var buz;
27 } 27 }
28 28
29 A makeA() native; 29 A makeA() native;
30 B makeB() native; 30 B makeB() native;
31 31
32 void setup() native """ 32 void setup() {
33 function A() {this.foo='A-foo';} 33 JS('', r"""
34 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';} 34 (function(){
35 makeA = function(){return new A;}; 35 function A() {this.foo='A-foo';}
36 makeB = function(){return new B;}; 36 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
37 makeA = function(){return new A()};
38 makeB = function(){return new B()};
37 39
38 self.nativeConstructor(A); 40 self.nativeConstructor(A);
39 self.nativeConstructor(B); 41 self.nativeConstructor(B);
40 """; 42 })()""");
43 }
41 44
42 main() { 45 main() {
43 nativeTesting(); 46 nativeTesting();
44 setup(); 47 setup();
45 A a = makeA(); 48 A a = makeA();
46 Expect.equals("A-foo", a.foo); 49 Expect.equals("A-foo", a.foo);
47 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError); 50 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError);
48 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError); 51 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError);
49 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError); 52 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError);
50 53
51 B b = makeB(); 54 B b = makeB();
52 Expect.equals("A-foo", b.foo); 55 Expect.equals("A-foo", b.foo);
53 Expect.equals("B-bar", b.bar); 56 Expect.equals("B-bar", b.bar);
54 // Expect.equals("M1-baz", b.baz); // not true, see M1. 57 // Expect.equals("M1-baz", b.baz); // not true, see M1.
55 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz. 58 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz.
56 Expect.isNull(b.buz); 59 Expect.isNull(b.buz);
57 60
58 M1 m1 = new M1(); 61 M1 m1 = new M1();
59 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError); 62 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError);
60 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError); 63 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError);
61 Expect.isNull(m1.baz); 64 Expect.isNull(m1.baz);
62 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError); 65 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError);
63 66
64 M2 m2 = new M2(); 67 M2 m2 = new M2();
65 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError); 68 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError);
66 Expect.isNull(m2.bar); 69 Expect.isNull(m2.bar);
67 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError); 70 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError);
68 Expect.isNull(m2.buz); 71 Expect.isNull(m2.buz);
69 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698