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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
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")
11 class A { 11 class A {
12 var foo; 12 var foo;
13 } 13 }
14 14
15 @Native("B") 15 @Native("B")
16 class B extends A with M1, M2 { 16 class B extends A with M1, M2 {
17 var bar; 17 var bar;
18 } 18 }
19 19
20 class M1 { 20 class M1 {
21 var baz; // This field is not a native field, even when mixed in. 21 var baz; // This field is not a native field, even when mixed in.
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() native """
33 function A() {this.foo='A-foo';} 33 function A() {this.foo='A-foo';}
34 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';} 34 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
35 makeA = function(){return new A;}; 35 makeA = function(){return new A;};
36 makeB = function(){return new B;}; 36 makeB = function(){return new B;};
37 37
38 self.nativeConstructor(A); 38 self.nativeConstructor(A);
39 self.nativeConstructor(B); 39 self.nativeConstructor(B);
40 """; 40 """;
41 41
42
43 main() { 42 main() {
44 nativeTesting(); 43 nativeTesting();
45 setup(); 44 setup();
46 A a = makeA(); 45 A a = makeA();
47 Expect.equals("A-foo", a.foo); 46 Expect.equals("A-foo", a.foo);
48 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError); 47 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError);
49 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError); 48 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError);
50 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError); 49 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError);
51 50
52 B b = makeB(); 51 B b = makeB();
53 Expect.equals("A-foo", b.foo); 52 Expect.equals("A-foo", b.foo);
54 Expect.equals("B-bar", b.bar); 53 Expect.equals("B-bar", b.bar);
55 // Expect.equals("M1-baz", b.baz); // not true, see M1. 54 // Expect.equals("M1-baz", b.baz); // not true, see M1.
56 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz. 55 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz.
57 Expect.isNull(b.buz); 56 Expect.isNull(b.buz);
58 57
59 M1 m1 = new M1(); 58 M1 m1 = new M1();
60 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError); 59 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError);
61 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError); 60 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError);
62 Expect.isNull(m1.baz); 61 Expect.isNull(m1.baz);
63 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError); 62 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError);
64 63
65 M2 m2 = new M2(); 64 M2 m2 = new M2();
66 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError); 65 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError);
67 Expect.isNull(m2.bar); 66 Expect.isNull(m2.bar);
68 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError); 67 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError);
69 Expect.isNull(m2.buz); 68 Expect.isNull(m2.buz);
70 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698