| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "package:expect/expect.dart"; |
| 6 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; | 6 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; | 7 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; |
| 9 | 9 |
| 10 import "parser_helper.dart"; | 10 import "parser_helper.dart"; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool get isEven; | 152 bool get isEven; |
| 153 } | 153 } |
| 154 abstract class double extends num { | 154 abstract class double extends num { |
| 155 bool get isNaN; | 155 bool get isNaN; |
| 156 } | 156 } |
| 157 class bool {} | 157 class bool {} |
| 158 class String {} | 158 class String {} |
| 159 class Object {} | 159 class Object {} |
| 160 class Function {} | 160 class Function {} |
| 161 abstract class List<E> { | 161 abstract class List<E> { |
| 162 factory List([int length]) {} | 162 factory List([int length]) => JS('=List', r'new Array(#)', length); |
| 163 E operator [](int index); | |
| 164 void operator []=(int index, E value); | |
| 165 } | 163 } |
| 166 abstract class Map<K, V> {} | 164 abstract class Map<K, V> {} |
| 167 class Closure {} | 165 class Closure {} |
| 168 class Null {} | 166 class Null {} |
| 169 class Type {} | 167 class Type {} |
| 170 class StackTrace {} | 168 class StackTrace {} |
| 171 class Dynamic_ {} | 169 class Dynamic_ {} |
| 172 bool identical(Object a, Object b) {}'''; | 170 bool identical(Object a, Object b) {}'''; |
| 173 | 171 |
| 174 AnalysisResult analyze(String code, {int maxConcreteTypeSize: 1000}) { | 172 AnalysisResult analyze(String code, {int maxConcreteTypeSize: 1000}) { |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 new BFactory(); | 1194 new BFactory(); |
| 1197 // should be of type {int} and not {int, String} since B is unreachable | 1195 // should be of type {int} and not {int, String} since B is unreachable |
| 1198 var foo = "__dynamic_for_test".witness(); | 1196 var foo = "__dynamic_for_test".witness(); |
| 1199 foo; | 1197 foo; |
| 1200 } | 1198 } |
| 1201 """; | 1199 """; |
| 1202 AnalysisResult result = analyze(source); | 1200 AnalysisResult result = analyze(source); |
| 1203 result.checkNodeHasType('foo', [result.int]); | 1201 result.checkNodeHasType('foo', [result.int]); |
| 1204 } | 1202 } |
| 1205 | 1203 |
| 1206 testGoodGuys() { | |
| 1207 final String source = r""" | |
| 1208 main() { | |
| 1209 var a = 1.isEven; | |
| 1210 var b = 3.14.isNaN; | |
| 1211 var c = 1.floor(); | |
| 1212 var d = 3.14.floor(); | |
| 1213 a; b; c; d; | |
| 1214 } | |
| 1215 """; | |
| 1216 AnalysisResult result = analyze(source); | |
| 1217 result.checkNodeHasType('a', [result.bool]); | |
| 1218 result.checkNodeHasType('b', [result.bool]); | |
| 1219 result.checkNodeHasType('c', [result.num]); | |
| 1220 result.checkNodeHasType('d', [result.num]); | |
| 1221 } | |
| 1222 | |
| 1223 testIntDoubleNum() { | 1204 testIntDoubleNum() { |
| 1224 final String source = r""" | 1205 final String source = r""" |
| 1225 main() { | 1206 main() { |
| 1226 var a = 1; | 1207 var a = 1; |
| 1227 var b = 1.0; | 1208 var b = 1.0; |
| 1228 var c = true ? 1 : 1.0; | 1209 var c = true ? 1 : 1.0; |
| 1229 a; b; c; | 1210 a; b; c; |
| 1230 } | 1211 } |
| 1231 """; | 1212 """; |
| 1232 AnalysisResult result = analyze(source); | 1213 AnalysisResult result = analyze(source); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 testSendWithWrongArity(); | 1376 testSendWithWrongArity(); |
| 1396 testBigTypesWidening1(); | 1377 testBigTypesWidening1(); |
| 1397 testBigTypesWidening2(); | 1378 testBigTypesWidening2(); |
| 1398 testDynamicIsAbsorbing(); | 1379 testDynamicIsAbsorbing(); |
| 1399 testLists(); | 1380 testLists(); |
| 1400 testListWithCapacity(); | 1381 testListWithCapacity(); |
| 1401 testEmptyList(); | 1382 testEmptyList(); |
| 1402 testJsCall(); | 1383 testJsCall(); |
| 1403 testIsCheck(); | 1384 testIsCheck(); |
| 1404 testSeenClasses(); | 1385 testSeenClasses(); |
| 1405 testGoodGuys(); | |
| 1406 testIntDoubleNum(); | 1386 testIntDoubleNum(); |
| 1407 testConcreteTypeToTypeMask(); | 1387 testConcreteTypeToTypeMask(); |
| 1408 testSelectors(); | 1388 testSelectors(); |
| 1409 } | 1389 } |
| OLD | NEW |