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

Unified 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 side-by-side diff with in-line comments
Download patch
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 8e81e93dcc8cf6d1cd5ff10e54eadfbe7cbc434f..94c45e18908082aa5274bcf98e4c33b3e9f00af9 100644
--- a/tests/compiler/dart2js/cpa_inference_test.dart
+++ b/tests/compiler/dart2js/cpa_inference_test.dart
@@ -1069,21 +1069,43 @@ testFieldInitialization3() {
testLists() {
final String source = r"""
+ class A {}
+ class B {}
+ class C {}
+ class D {}
+ class E {}
+ class F {}
+ class G {}
+
main() {
- var l1 = [1.2];
+ var l1 = [new A()];
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;
+ l1['a'] = new B(); // raises an error, so B should not be recorded
+ l1[1] = new C();
+ l1.add(new D());
+ l1.insert('a', new E()); // raises an error, so E should not be recorded
+ l1.insert(1, new F());
+ "__dynamic_for_test"[1] = new G();
+ var x1 = l1[1];
+ var x2 = l2[1];
+ var x3 = l1['foo']; // raises an error, should return empty
+ var x4 = l1.removeAt(1);
+ var x5 = l2.removeAt(1);
+ var x6 = l1.removeAt('a'); // raises an error, should return empty
+ var x7 = l1.removeLast();
+ var x8 = l2.removeLast();
+ x1; x2; x3; x4; x5; x6; x7; x8;
}""";
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', []);
+ final expectedTypes = ['A', 'C', 'D', 'F', 'G'].map(result.base).toList();
+ result.checkNodeHasType('x1', expectedTypes);
+ result.checkNodeHasType('x2', expectedTypes);
+ result.checkNodeHasType('x3', []);
+ result.checkNodeHasType('x4', expectedTypes);
+ result.checkNodeHasType('x5', expectedTypes);
+ result.checkNodeHasType('x6', []);
+ result.checkNodeHasType('x7', expectedTypes);
+ result.checkNodeHasType('x8', expectedTypes);
}
testListWithCapacity() {

Powered by Google App Engine
This is Rietveld 408576698