OLD | NEW |
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 "package:expect/expect.dart"; |
6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; | 6 import 'dart:_js_helper' show Native, Creates, 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 Loading... |
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 |
124 main() { | 126 main() { |
125 nativeTesting(); | |
126 setup(); | 127 setup(); |
| 128 inscrutable = (x) => x; |
127 | 129 |
128 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); | 130 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
129 | 131 |
130 var b = confuse(makeB()); | 132 var b = inscrutable(makeB()); |
131 | 133 |
132 confuse(testIsB)(b); | 134 inscrutable(testIsB)(b); |
133 confuse(testIsA)(b); | 135 inscrutable(testIsA)(b); |
134 confuse(testIsN)(b); | 136 inscrutable(testIsN)(b); |
135 confuse(testIsM)(b); | 137 inscrutable(testIsM)(b); |
136 confuse(testIsI)(b); | 138 inscrutable(testIsI)(b); |
137 | 139 |
138 confuse(new Checks<B>().isCheck)(b); | 140 inscrutable(new Checks<B>().isCheck)(b); |
139 confuse(new Checks<A>().isCheck)(b); | 141 inscrutable(new Checks<A>().isCheck)(b); |
140 confuse(new Checks<N>().isCheck)(b); | 142 inscrutable(new Checks<N>().isCheck)(b); |
141 confuse(new Checks<M>().isCheck)(b); | 143 inscrutable(new Checks<M>().isCheck)(b); |
142 confuse(new Checks<I>().isCheck)(b); | 144 inscrutable(new Checks<I>().isCheck)(b); |
143 | 145 |
144 if (isCheckedMode()) { | 146 if (isCheckedMode()) { |
145 confuse(testAssignB)(b); | 147 inscrutable(testAssignB)(b); |
146 confuse(testAssignA)(b); | 148 inscrutable(testAssignA)(b); |
147 confuse(testAssignN)(b); | 149 inscrutable(testAssignN)(b); |
148 confuse(testAssignM)(b); | 150 inscrutable(testAssignM)(b); |
149 confuse(testAssignI)(b); | 151 inscrutable(testAssignI)(b); |
150 | 152 |
151 confuse(testCastB)(b); | 153 inscrutable(testCastB)(b); |
152 confuse(testCastA)(b); | 154 inscrutable(testCastA)(b); |
153 confuse(testCastN)(b); | 155 inscrutable(testCastN)(b); |
154 confuse(testCastM)(b); | 156 inscrutable(testCastM)(b); |
155 confuse(testCastI)(b); | 157 inscrutable(testCastI)(b); |
156 | 158 |
157 confuse(new Checks<B>().assignCheck)(b); | 159 inscrutable(new Checks<B>().assignCheck)(b); |
158 confuse(new Checks<A>().assignCheck)(b); | 160 inscrutable(new Checks<A>().assignCheck)(b); |
159 confuse(new Checks<N>().assignCheck)(b); | 161 inscrutable(new Checks<N>().assignCheck)(b); |
160 confuse(new Checks<M>().assignCheck)(b); | 162 inscrutable(new Checks<M>().assignCheck)(b); |
161 confuse(new Checks<I>().assignCheck)(b); | 163 inscrutable(new Checks<I>().assignCheck)(b); |
162 | 164 |
163 confuse(new Checks<B>().castCheck)(b); | 165 inscrutable(new Checks<B>().castCheck)(b); |
164 confuse(new Checks<A>().castCheck)(b); | 166 inscrutable(new Checks<A>().castCheck)(b); |
165 confuse(new Checks<N>().castCheck)(b); | 167 inscrutable(new Checks<N>().castCheck)(b); |
166 confuse(new Checks<M>().castCheck)(b); | 168 inscrutable(new Checks<M>().castCheck)(b); |
167 confuse(new Checks<I>().castCheck)(b); | 169 inscrutable(new Checks<I>().castCheck)(b); |
168 } | 170 } |
169 } | 171 } |
OLD | NEW |