| Index: tests/compiler/dart2js/cpa_inference_test.dart
|
| diff --git a/tests/compiler/dart2js/cpa_inference_test.dart b/tests/compiler/dart2js/cpa_inference_test.dart
|
| index 5d4ffff8cfaa28721076688f3cbffe946b9b3dce..ae905932a7237ccafc2750dfc47561f51a930cfb 100644
|
| --- a/tests/compiler/dart2js/cpa_inference_test.dart
|
| +++ b/tests/compiler/dart2js/cpa_inference_test.dart
|
| @@ -158,7 +158,11 @@ const String CORELIB = r'''
|
| class String {}
|
| class Object {}
|
| class Function {}
|
| - abstract class List {}
|
| + abstract class List<E> {
|
| + factory List([int length]);
|
| + E operator [](int index);
|
| + void operator []=(int index, E value);
|
| + }
|
| abstract class Map {}
|
| class Closure {}
|
| class Null {}
|
| @@ -890,7 +894,7 @@ testInequality() {
|
| result.checkNodeHasType('bar', [result.bool]);
|
| result.checkNodeHasType('baz', []);
|
| // TODO(polux): the following result should be [:[null, string]:], see
|
| - // fieldInitialization().
|
| + // testFieldInitialization().
|
| result.checkFieldHasType('A', 'witness', [result.string]);
|
| }
|
|
|
| @@ -909,6 +913,48 @@ testFieldInitialization() {
|
| result.checkFieldHasType('A', 'y', [result.int]);
|
| }
|
|
|
| +testLists() {
|
| + final String source = r"""
|
| + main() {
|
| + new List();
|
| + var l1 = [1.2];
|
| + var l2 = [];
|
| + l1['a'] = 42; // raises an error, so int should not be recorded
|
| + l1[1] = 'abc';
|
| + "__dynamic_for_test"[1] = true;
|
| + var x = l1[1];
|
| + var y = l2[1];
|
| + var z = l1['foo'];
|
| + x; y; z;
|
| + }""";
|
| + AnalysisResult result = analyze(source);
|
| + result.checkNodeHasType('x', [result.double, result.string, result.bool]);
|
| + result.checkNodeHasType('y', [result.double, result.string, result.bool]);
|
| + result.checkNodeHasType('z', []);
|
| +}
|
| +
|
| +testListWithCapacity() {
|
| + final String source = r"""
|
| + main() {
|
| + var l = new List(10);
|
| + var x = l[0];
|
| + x;
|
| + }""";
|
| + AnalysisResult result = analyze(source);
|
| + result.checkNodeHasType('x', [result.nullType]);
|
| +}
|
| +
|
| +testEmptyList() {
|
| + final String source = r"""
|
| + main() {
|
| + var l = new List();
|
| + var x = l[0];
|
| + x;
|
| + }""";
|
| + AnalysisResult result = analyze(source);
|
| + result.checkNodeHasType('x', []);
|
| +}
|
| +
|
| testSendWithWrongArity() {
|
| final String source = r"""
|
| f(x) { }
|
| @@ -1014,4 +1060,7 @@ void main() {
|
| testBigTypesWidening1();
|
| testBigTypesWidening2();
|
| testDynamicIsAbsorbing();
|
| + testLists();
|
| + testListWithCapacity();
|
| + testEmptyList();
|
| }
|
|
|