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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "dart:_js_helper";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 // Additional Dart code may be 'placed on' hidden native classes. With 8 // Additional Dart code may be 'placed on' hidden native classes. With
9 // inheritance, the superclass method must not be reached by a call on the 9 // inheritance, the superclass method must not be reached by a call on the
10 // subclass. 10 // subclass.
11 11
12 @Native("A") 12 @Native("A")
13 class A { 13 class A {
14 var _field; 14 var _field;
15 15
16 int get X => _field; 16 int get X => _field;
17 void set X(int x) { _field = x; } 17 void set X(int x) {
18 _field = x;
19 }
18 20
19 int method(int z) => _field + z; 21 int method(int z) => _field + z;
20 } 22 }
21 23
22 @Native("B") 24 @Native("B")
23 class B extends A { 25 class B extends A {
24 var _field2; 26 var _field2;
25 27
26 int get X => _field2; 28 int get X => _field2;
27 void set X(int x) { _field2 = x; } 29 void set X(int x) {
30 _field2 = x;
31 }
28 32
29 int method(int z) => _field2 + z; 33 int method(int z) => _field2 + z;
30 } 34 }
31 35
32 A makeA() native; 36 A makeA() native ;
33 B makeB() native; 37 B makeB() native ;
34 38
35 void setup() native r""" 39 void setup() native r"""
36 function inherits(child, parent) { 40 function inherits(child, parent) {
37 if (child.prototype.__proto__) { 41 if (child.prototype.__proto__) {
38 child.prototype.__proto__ = parent.prototype; 42 child.prototype.__proto__ = parent.prototype;
39 } else { 43 } else {
40 function tmp() {}; 44 function tmp() {};
41 tmp.prototype = parent.prototype; 45 tmp.prototype = parent.prototype;
42 child.prototype = new tmp(); 46 child.prototype = new tmp();
43 child.prototype.constructor = child; 47 child.prototype.constructor = child;
44 } 48 }
45 } 49 }
46 50
47 function A(){} 51 function A(){}
48 function B(){} 52 function B(){}
49 inherits(B, A); 53 inherits(B, A);
50 makeA = function(){return new A;}; 54 makeA = function(){return new A;};
51 makeB = function(){return new B;}; 55 makeB = function(){return new B;};
52 """; 56 """;
53 57
54 testBasicA_dynamic() { 58 testBasicA_dynamic() {
55 setup(); // Fresh constructors. 59 setup(); // Fresh constructors.
56 60
57 var a = [makeA()][0]; 61 var a = [makeA()][0];
58 62
59 a.X = 100; 63 a.X = 100;
60 Expect.equals(100, a._field); 64 Expect.equals(100, a._field);
61 Expect.equals(100, a.X); 65 Expect.equals(100, a.X);
62 Expect.equals(150, a.method(50)); 66 Expect.equals(150, a.method(50));
63 } 67 }
64 68
65 testBasicA_typed() { 69 testBasicA_typed() {
66 setup(); // Fresh constructors. 70 setup(); // Fresh constructors.
67 71
68 A a = makeA(); 72 A a = makeA();
69 73
70 a.X = 100; 74 a.X = 100;
71 Expect.equals(100, a._field); 75 Expect.equals(100, a._field);
72 Expect.equals(100, a.X); 76 Expect.equals(100, a.X);
73 Expect.equals(150, a.method(50)); 77 Expect.equals(150, a.method(50));
74 } 78 }
75 79
76 testBasicB_dynamic() { 80 testBasicB_dynamic() {
77 setup(); // Fresh constructors. 81 setup(); // Fresh constructors.
78 82
79 var b = [makeB()][0]; 83 var b = [makeB()][0];
80 84
81 b._field = 1; 85 b._field = 1;
82 b.X = 123; 86 b.X = 123;
83 Expect.equals(1, b._field); 87 Expect.equals(1, b._field);
84 Expect.equals(123, b._field2); 88 Expect.equals(123, b._field2);
85 Expect.equals(123, b.X); 89 Expect.equals(123, b.X);
86 Expect.equals(200, b.method(77)); 90 Expect.equals(200, b.method(77));
87 } 91 }
88 92
89 testBasicB_typed() { 93 testBasicB_typed() {
90 setup(); // Fresh constructors. 94 setup(); // Fresh constructors.
91 95
92 B b = makeB(); 96 B b = makeB();
93 97
94 b._field = 1; 98 b._field = 1;
95 b.X = 123; 99 b.X = 123;
96 Expect.equals(1, b._field); 100 Expect.equals(1, b._field);
97 Expect.equals(123, b._field2); 101 Expect.equals(123, b._field2);
98 Expect.equals(123, b.X); 102 Expect.equals(123, b.X);
99 Expect.equals(200, b.method(77)); 103 Expect.equals(200, b.method(77));
100 } 104 }
101 105
102 testAB_dynamic() { 106 testAB_dynamic() {
103 setup(); // Fresh constructors. 107 setup(); // Fresh constructors.
104 108
105 var things = [makeA(), makeB()]; 109 var things = [makeA(), makeB()];
106 var a = things[0]; 110 var a = things[0];
107 var b = things[1]; 111 var b = things[1];
108 112
109 a.X = 100; 113 a.X = 100;
110 Expect.equals(100, a._field); 114 Expect.equals(100, a._field);
111 Expect.equals(100, a.X); 115 Expect.equals(100, a.X);
112 Expect.equals(150, a.method(50)); 116 Expect.equals(150, a.method(50));
113 117
114 b._field = 1; 118 b._field = 1;
115 b._field2 = 2; 119 b._field2 = 2;
116 b.X = 123; 120 b.X = 123;
117 Expect.equals(1, b._field); 121 Expect.equals(1, b._field);
118 Expect.equals(123, b._field2); 122 Expect.equals(123, b._field2);
119 Expect.equals(123, b.X); 123 Expect.equals(123, b.X);
120 Expect.equals(200, b.method(77)); 124 Expect.equals(200, b.method(77));
121 } 125 }
122 126
123 testAB_typed() { 127 testAB_typed() {
124 setup(); // Fresh constructors. 128 setup(); // Fresh constructors.
125 129
126 A a = makeA(); 130 A a = makeA();
127 B b = makeB(); 131 B b = makeB();
128 132
129 a.X = 100; 133 a.X = 100;
130 Expect.equals(100, a._field); 134 Expect.equals(100, a._field);
131 Expect.equals(100, a.X); 135 Expect.equals(100, a.X);
132 Expect.equals(150, a.method(50)); 136 Expect.equals(150, a.method(50));
133 137
134 b._field = 1; 138 b._field = 1;
135 b._field2 = 2; 139 b._field2 = 2;
136 b.X = 123; 140 b.X = 123;
137 Expect.equals(1, b._field); 141 Expect.equals(1, b._field);
138 Expect.equals(123, b._field2); 142 Expect.equals(123, b._field2);
139 Expect.equals(123, b.X); 143 Expect.equals(123, b.X);
140 Expect.equals(200, b.method(77)); 144 Expect.equals(200, b.method(77));
141 } 145 }
142 146
143 main() { 147 main() {
144 testBasicA_dynamic(); 148 testBasicA_dynamic();
145 testBasicA_typed(); 149 testBasicA_typed();
146 testBasicB_dynamic(); 150 testBasicB_dynamic();
147 testBasicB_typed(); 151 testBasicB_typed();
148 testAB_dynamic(); 152 testAB_dynamic();
149 testAB_typed(); 153 testAB_typed();
150 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698