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

Side by Side Diff: tests/compiler/dart2js_native/subclassing_5_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 "package:expect/expect.dart"; 5 import 'native_testing.dart';
6 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; 6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' show Interceptor, findInterceptorForType; 7 import 'dart:_interceptors' show Interceptor, findInterceptorForType;
8 8
9 // Test type checks. 9 // Test type checks.
10 10
11 class I {} 11 class I {}
12 12
13 class M implements I { 13 class M implements I {
14 miz() => 'M'; 14 miz() => 'M';
15 } 15 }
16 16
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 testCastA(x) { 114 testCastA(x) {
115 var z = x as A; 115 var z = x as A;
116 Expect.identical(x, z); 116 Expect.identical(x, z);
117 } 117 }
118 118
119 testCastB(x) { 119 testCastB(x) {
120 var z = x as B; 120 var z = x as B;
121 Expect.identical(x, z); 121 Expect.identical(x, z);
122 } 122 }
123 123
124 var inscrutable;
125
126 main() { 124 main() {
125 nativeTesting();
127 setup(); 126 setup();
128 inscrutable = (x) => x;
129 127
130 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); 128 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B));
131 129
132 var b = inscrutable(makeB()); 130 var b = confuse(makeB());
133 131
134 inscrutable(testIsB)(b); 132 confuse(testIsB)(b);
135 inscrutable(testIsA)(b); 133 confuse(testIsA)(b);
136 inscrutable(testIsN)(b); 134 confuse(testIsN)(b);
137 inscrutable(testIsM)(b); 135 confuse(testIsM)(b);
138 inscrutable(testIsI)(b); 136 confuse(testIsI)(b);
139 137
140 inscrutable(new Checks<B>().isCheck)(b); 138 confuse(new Checks<B>().isCheck)(b);
141 inscrutable(new Checks<A>().isCheck)(b); 139 confuse(new Checks<A>().isCheck)(b);
142 inscrutable(new Checks<N>().isCheck)(b); 140 confuse(new Checks<N>().isCheck)(b);
143 inscrutable(new Checks<M>().isCheck)(b); 141 confuse(new Checks<M>().isCheck)(b);
144 inscrutable(new Checks<I>().isCheck)(b); 142 confuse(new Checks<I>().isCheck)(b);
145 143
146 if (isCheckedMode()) { 144 if (isCheckedMode()) {
147 inscrutable(testAssignB)(b); 145 confuse(testAssignB)(b);
148 inscrutable(testAssignA)(b); 146 confuse(testAssignA)(b);
149 inscrutable(testAssignN)(b); 147 confuse(testAssignN)(b);
150 inscrutable(testAssignM)(b); 148 confuse(testAssignM)(b);
151 inscrutable(testAssignI)(b); 149 confuse(testAssignI)(b);
152 150
153 inscrutable(testCastB)(b); 151 confuse(testCastB)(b);
154 inscrutable(testCastA)(b); 152 confuse(testCastA)(b);
155 inscrutable(testCastN)(b); 153 confuse(testCastN)(b);
156 inscrutable(testCastM)(b); 154 confuse(testCastM)(b);
157 inscrutable(testCastI)(b); 155 confuse(testCastI)(b);
158 156
159 inscrutable(new Checks<B>().assignCheck)(b); 157 confuse(new Checks<B>().assignCheck)(b);
160 inscrutable(new Checks<A>().assignCheck)(b); 158 confuse(new Checks<A>().assignCheck)(b);
161 inscrutable(new Checks<N>().assignCheck)(b); 159 confuse(new Checks<N>().assignCheck)(b);
162 inscrutable(new Checks<M>().assignCheck)(b); 160 confuse(new Checks<M>().assignCheck)(b);
163 inscrutable(new Checks<I>().assignCheck)(b); 161 confuse(new Checks<I>().assignCheck)(b);
164 162
165 inscrutable(new Checks<B>().castCheck)(b); 163 confuse(new Checks<B>().castCheck)(b);
166 inscrutable(new Checks<A>().castCheck)(b); 164 confuse(new Checks<A>().castCheck)(b);
167 inscrutable(new Checks<N>().castCheck)(b); 165 confuse(new Checks<N>().castCheck)(b);
168 inscrutable(new Checks<M>().castCheck)(b); 166 confuse(new Checks<M>().castCheck)(b);
169 inscrutable(new Checks<I>().castCheck)(b); 167 confuse(new Checks<I>().castCheck)(b);
170 } 168 }
171 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698