Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: tests/compiler/dart2js/cpa_inference_test.dart

Issue 18429011: Capture and handle properly every call to JSArray that read or writes elements via a native call (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Karl's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // checks that B.B is set as a caller of f 1062 // checks that B.B is set as a caller of f
1063 result.checkFieldHasType('B', 'y', [result.nullType, result.string]); 1063 result.checkFieldHasType('B', 'y', [result.nullType, result.string]);
1064 // checks that readers of x are notified by changes in x's type 1064 // checks that readers of x are notified by changes in x's type
1065 result.checkNodeHasType('foo', [result.nullType, result.string]); 1065 result.checkNodeHasType('foo', [result.nullType, result.string]);
1066 // checks that readers of y are notified by changes in y's type 1066 // checks that readers of y are notified by changes in y's type
1067 result.checkNodeHasType('bar', [result.nullType, result.string]); 1067 result.checkNodeHasType('bar', [result.nullType, result.string]);
1068 } 1068 }
1069 1069
1070 testLists() { 1070 testLists() {
1071 final String source = r""" 1071 final String source = r"""
1072 class A {}
1073 class B {}
1074 class C {}
1075 class D {}
1076 class E {}
1077 class F {}
1078 class G {}
1079
1072 main() { 1080 main() {
1073 var l1 = [1.2]; 1081 var l1 = [new A()];
1074 var l2 = []; 1082 var l2 = [];
1075 l1['a'] = 42; // raises an error, so int should not be recorded 1083 l1['a'] = new B(); // raises an error, so B should not be recorded
1076 l1[1] = 'abc'; 1084 l1[1] = new C();
1077 "__dynamic_for_test"[1] = true; 1085 l1.add(new D());
1078 var x = l1[1]; 1086 l1.insert('a', new E()); // raises an error, so E should not be recorded
1079 var y = l2[1]; 1087 l1.insert(1, new F());
1080 var z = l1['foo']; 1088 "__dynamic_for_test"[1] = new G();
1081 x; y; z; 1089 var x1 = l1[1];
1090 var x2 = l2[1];
1091 var x3 = l1['foo']; // raises an error, should return empty
1092 var x4 = l1.removeAt(1);
1093 var x5 = l2.removeAt(1);
1094 var x6 = l1.removeAt('a'); // raises an error, should return empty
1095 var x7 = l1.removeLast();
1096 var x8 = l2.removeLast();
1097 x1; x2; x3; x4; x5; x6; x7; x8;
1082 }"""; 1098 }""";
1083 AnalysisResult result = analyze(source); 1099 AnalysisResult result = analyze(source);
1084 result.checkNodeHasType('x', [result.double, result.string, result.bool]); 1100 final expectedTypes = ['A', 'C', 'D', 'F', 'G'].map(result.base).toList();
1085 result.checkNodeHasType('y', [result.double, result.string, result.bool]); 1101 result.checkNodeHasType('x1', expectedTypes);
1086 result.checkNodeHasType('z', []); 1102 result.checkNodeHasType('x2', expectedTypes);
1103 result.checkNodeHasType('x3', []);
1104 result.checkNodeHasType('x4', expectedTypes);
1105 result.checkNodeHasType('x5', expectedTypes);
1106 result.checkNodeHasType('x6', []);
1107 result.checkNodeHasType('x7', expectedTypes);
1108 result.checkNodeHasType('x8', expectedTypes);
1087 } 1109 }
1088 1110
1089 testListWithCapacity() { 1111 testListWithCapacity() {
1090 final String source = r""" 1112 final String source = r"""
1091 main() { 1113 main() {
1092 var l = new List(10); 1114 var l = new List(10);
1093 var x = [][0]; 1115 var x = [][0];
1094 x; 1116 x;
1095 }"""; 1117 }""";
1096 AnalysisResult result = analyze(source); 1118 AnalysisResult result = analyze(source);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 testJsCallAugmentsSeenClasses(); 1623 testJsCallAugmentsSeenClasses();
1602 testIsCheck(); 1624 testIsCheck();
1603 testSeenClasses(); 1625 testSeenClasses();
1604 testIntDoubleNum(); 1626 testIntDoubleNum();
1605 testConcreteTypeToTypeMask(); 1627 testConcreteTypeToTypeMask();
1606 testSelectors(); 1628 testSelectors();
1607 testMixins(); 1629 testMixins();
1608 testClosures(); 1630 testClosures();
1609 testNestedFunctions(); 1631 testNestedFunctions();
1610 } 1632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698