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