| 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 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'package:compiler/src/types/types.dart' show ContainerTypeMask, TypeMask; | 7 import 'package:compiler/src/types/types.dart' show ContainerTypeMask, TypeMask; |
| 8 | 8 |
| 9 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 10 import 'type_mask_test_helper.dart'; | 10 import 'type_mask_test_helper.dart'; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 doTest('new List(1)', nullify: true); // Test fixed list. | 191 doTest('new List(1)', nullify: true); // Test fixed list. |
| 192 doTest('new List.filled(1, 0)', nullify: false); // Test List.filled. | 192 doTest('new List.filled(1, 0)', nullify: false); // Test List.filled. |
| 193 doTest('new List.filled(1, null)', nullify: true); // Test List.filled. | 193 doTest('new List.filled(1, null)', nullify: true); // Test List.filled. |
| 194 } | 194 } |
| 195 | 195 |
| 196 void doTest(String allocation, {bool nullify}) { | 196 void doTest(String allocation, {bool nullify}) { |
| 197 Uri uri = new Uri(scheme: 'source'); | 197 Uri uri = new Uri(scheme: 'source'); |
| 198 var compiler = compilerFor(generateTest(allocation), uri, | 198 var compiler = compilerFor(generateTest(allocation), uri, |
| 199 expectedErrors: 0, expectedWarnings: 1); | 199 expectedErrors: 0, expectedWarnings: 1); |
| 200 asyncTest(() => compiler.run(uri).then((_) { | 200 asyncTest(() => compiler.run(uri).then((_) { |
| 201 var commonMasks = compiler.commonMasks; | 201 var commonMasks = compiler.closedWorld.commonMasks; |
| 202 var typesInferrer = compiler.globalInference.typesInferrer; | 202 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
| 203 | 203 |
| 204 checkType(String name, type) { | 204 checkType(String name, type) { |
| 205 var element = findElement(compiler, name); | 205 var element = findElement(compiler, name); |
| 206 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); | 206 ContainerTypeMask mask = typesInferrer.getTypeOfElement(element); |
| 207 if (nullify) type = type.nullable(); | 207 if (nullify) type = type.nullable(); |
| 208 Expect.equals(type, simplify(mask.elementType, compiler), name); | 208 Expect.equals(type, simplify(mask.elementType, compiler), name); |
| 209 } | 209 } |
| 210 | 210 |
| 211 checkType('listInField', commonMasks.numType); | 211 checkType('listInField', commonMasks.numType); |
| 212 checkType('listPassedToMethod', commonMasks.numType); | 212 checkType('listPassedToMethod', commonMasks.numType); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 233 checkType('listPassedAsNamedParameter', commonMasks.numType); | 233 checkType('listPassedAsNamedParameter', commonMasks.numType); |
| 234 checkType('listStoredInList', commonMasks.uint31Type); | 234 checkType('listStoredInList', commonMasks.uint31Type); |
| 235 checkType('listStoredInListButEscapes', commonMasks.dynamicType); | 235 checkType('listStoredInListButEscapes', commonMasks.dynamicType); |
| 236 | 236 |
| 237 if (!allocation.contains('filled')) { | 237 if (!allocation.contains('filled')) { |
| 238 checkType('listUnset', new TypeMask.nonNullEmpty()); | 238 checkType('listUnset', new TypeMask.nonNullEmpty()); |
| 239 checkType('listOnlySetWithConstraint', new TypeMask.nonNullEmpty()); | 239 checkType('listOnlySetWithConstraint', new TypeMask.nonNullEmpty()); |
| 240 } | 240 } |
| 241 })); | 241 })); |
| 242 } | 242 } |
| OLD | NEW |