Index: tests/compiler/dart2js/field_type_simple_inferer_test.dart |
diff --git a/tests/compiler/dart2js/field_type_simple_inferer_test.dart b/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
index 2d64709223787e86e1f04ed3b55dae3c4a90aa86..2eaf8085a537a9c24e5e39bc820136d0747bcde9 100644 |
--- a/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
+++ b/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
@@ -470,6 +470,63 @@ const String TEST_27 = r""" |
} |
"""; |
+const String TEST_28 = r""" |
+ class A { |
+ var f1; |
+ var f2; |
+ A(x) { |
+ this.f1 = x; |
+ if (x == 0) return; |
+ this.f2 = x; |
+ } |
+ } |
+ main() { |
+ new A(0); |
+ new A(1); |
+ } |
+"""; |
+ |
+const String TEST_29 = r""" |
+ class A { |
+ var f1; |
+ var f2; |
+ A(x) { |
+ this.f1 = x; |
+ if (x == 0) { |
+ } else { |
+ return; |
+ } |
+ this.f2 = x; |
+ } |
+ } |
+ main() { |
+ new A(0); |
+ new A(1); |
+ } |
+"""; |
+ |
+const String TEST_30 = r""" |
+ class A { |
+ var f1; |
+ var f2; |
+ var f3; |
+ A(x) { |
+ this.f1 = x; |
+ if (x == 0) { |
+ this.f2 = 1; |
+ } else { |
+ this.f2 = x; |
+ return; |
+ } |
+ this.f3 = x; |
+ } |
+ } |
+ main() { |
+ new A(0); |
+ new A(1); |
+ } |
+"""; |
+ |
typedef TypeMask TestCallback(ClosedWorld closedWorld); |
void doTest( |
@@ -481,7 +538,7 @@ void doTest( |
TypeMask type = f(closedWorld); |
TypeMask inferredType = |
simplify(inferrer.getTypeOfElement(field), closedWorld); |
- Expect.equals(type, inferredType, test); |
+ Expect.equals(type, inferredType, '$name of:\n$test'); |
}); |
}); |
} |
@@ -609,6 +666,19 @@ void test() { |
'f1': (closedWorld) => closedWorld.commonMasks.uint31Type, |
'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable() |
}); |
+ runTest(TEST_28, <String, TestCallback>{ |
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type, |
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable() |
+ }); |
+ runTest(TEST_29, <String, TestCallback>{ |
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type, |
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable() |
+ }); |
+ runTest(TEST_30, <String, TestCallback>{ |
+ 'f1': (closedWorld) => closedWorld.commonMasks.uint31Type, |
+ 'f2': (closedWorld) => closedWorld.commonMasks.uint31Type, |
+ 'f3': (closedWorld) => closedWorld.commonMasks.uint31Type.nullable() |
+ }); |
} |
void main() { |