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 81046f292fe36fe3852753c10708b30145aabd8f..b6f2e9c38219c60060538b914c3164d3a19c6879 100644 |
--- a/tests/compiler/dart2js/cpa_inference_test.dart |
+++ b/tests/compiler/dart2js/cpa_inference_test.dart |
@@ -520,6 +520,67 @@ testOperators() { |
result.checkNodeHasType('y', [result.string]); |
} |
+testCompoundOperators1() { |
+ final String source = r""" |
+ class A { |
+ operator +(x) => "foo"; |
+ } |
+ main() { |
+ var x1 = 1; x1++; |
+ var x2 = 1; ++x2; |
+ var x3 = new A(); x3++; |
+ var x4 = new A(); ++x4; |
+ |
+ x1; x2; x3; x4; |
+ } |
+ """; |
+ AnalysisResult result = analyze(source); |
+ result.checkNodeHasType('x1', [result.int]); |
+ result.checkNodeHasType('x2', [result.int]); |
+ result.checkNodeHasType('x3', [result.string]); |
+ result.checkNodeHasType('x4', [result.string]); |
+} |
+ |
+ |
+testCompoundOperators2() { |
+ final String source = r""" |
+ class A { |
+ var _x; |
karlklose
2012/11/08 10:45:31
It is unnecessary to use privacy here; using a nor
polux
2012/11/08 14:04:50
Done.
|
+ var witness1; |
+ var witness2; |
karlklose
2012/11/08 10:45:31
witness2 is unused. Did you want to use it in the
polux
2012/11/08 14:04:50
Done.
|
+ |
+ A(this._x); |
+ get x { witness1 = "foo"; return _x; } |
+ set x(y) { witness1 = "foo"; _x = y; } |
+ } |
+ main () { |
+ var a = new A(1); |
+ a.x++; |
+ } |
+ """; |
+ AnalysisResult result = analyze(source); |
+ result.checkFieldHasType('A', '_x', [result.int]); |
+ // TODO(polux): the two following results should be {null, string}, see |
+ // fieldInitialization(). |
+ result.checkFieldHasType('A', 'witness1', [result.string]); |
+ result.checkFieldHasType('A', 'witness1', [result.string]); |
karlklose
2012/11/08 10:45:31
witness2?
polux
2012/11/08 14:04:50
Done.
|
+} |
+ |
+testFieldInitialization() { |
+ final String source = r""" |
+ class A { |
+ var x; |
+ var y = 1; |
+ } |
+ main () { |
+ new A(); |
+ } |
+ """; |
+ AnalysisResult result = analyze(source); |
+ result.checkFieldHasType('A', 'x', [result.nullType]); |
+ result.checkFieldHasType('A', 'y', [result.int]); |
+} |
+ |
void main() { |
testLiterals(); |
testRedefinition(); |
@@ -543,4 +604,7 @@ void main() { |
// testNoReturn(); // right now we infer the empty type instead of null |
testArithmeticOperators(); |
testOperators(); |
+ testCompoundOperators1(); |
+ testCompoundOperators2(); |
+ // testFieldInitialization(); // TODO(polux) |
} |