Documenting the current state of the control flow graph for unreachable static blocks.
Commented the expected behavior for test.
@@ -166,6 +166,27 @@ public final class CheckUnreachableCodeTest extends CompilerTestCase {
assertUnreachable("while(true) {} foo()");
}
+ @Test
+ public void testUnreachableStaticBlocks() {
+ assertUnreachable("class C{ static { function f(){ return; let x; } } }");
+
+ // The statments in the static block are unreachable,but the code in ControlFlowAnalysis doesn't
+ // recognize class bodies yet.
+ // TODO(b/235871861): Update ControlFlowAnalysis so tests are unreachable.
+ testSame("class C{ static{ if(false) { var x; } } }");
+ testSame("class C{ static{ while(false){ let x; } } }");
+ }
+
+ @Test
+ public void testReachableStaticBlocks() {
+ testSame("class C{ static { let x; } }");
+ testSame("class C{ static { function a(){} } }");
+ testSame("class C{ static {} a(){} }");
+ testSame("class C{ static {} static {} }");
+ testSame("class C{ static{} static x; static{} static y;}");
+ testSame("class C{ static [l('l1')] = l('r1'); static{ l('s2');} static[l('l3')] = l('r3');}");
+ }
+
@Test
public void testSuppression() {
assertUnreachable("if(false) { }");
