@Test
public void testRemoveIfOrLoopButKeepGuard() throws Exception {

  final String shaderIf = "#version 310 es\n"
      + "void main() {\n"
      + "  if(1 > 0) {\n"
      + "  }\n"
      + "}\n";
  final String shaderWhile = "#version 310 es\n"
      + "void main() {\n"
      + "  while(1 > 0) {\n"
      + "  }\n"
      + "}\n";
  final String shaderDoWhile = "#version 310 es\n"
      + "void main() {\n"
      + "  do {\n"
      + "  } while(1 > 0);\n"
      + "}\n";
  final String shaderFor = "#version 310 es\n"
      + "void main() {\n"
      + "  for (; 1 > 0; ) {\n"
      + "  }\n"
      + "}\n";
  final String expected = "#version 310 es\n"
      + "void main() {\n"
      + "  1 > 0;\n"
      + "}\n";
  final IFileJudge customFileJudge =
      new CheckAstFeaturesFileJudge(Collections.singletonList(
          () -> new CheckAstFeatureVisitor() {
            @Override
            public void visitBinaryExpr(BinaryExpr binaryExpr) {
              super.visitBinaryExpr(binaryExpr);
              if (binaryExpr.getOp() == BinOp.GT
                  && binaryExpr.getLhs() instanceof IntConstantExpr
                  && ((IntConstantExpr) binaryExpr.getLhs()).getNumericValue() == 1
                  && binaryExpr.getRhs() instanceof IntConstantExpr
                  && ((IntConstantExpr) binaryExpr.getRhs()).getNumericValue() == 0) {
                trigger();
              }
            }
          }),
          ShaderKind.FRAGMENT,
          fileOps);
  for (String shader : Arrays.asList(shaderIf, shaderWhile, shaderDoWhile, shaderFor)) {
    final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(),
        new PipelineInfo(),
        ParseHelper.parse(shader));
    final File workDir = testFolder.getRoot();
    final File tempShaderJobFile = new File(workDir, "temp.json");
    fileOps.writeShaderJobFile(shaderJob, tempShaderJobFile);
    final String resultsPrefix = new ReductionDriver(new ReducerContext(true,
        ShadingLanguageVersion.ESSL_310,
        new RandomWrapper(0),
        new IdGenerator()),
        false,
        fileOps,
        customFileJudge,
        workDir)
        .doReduction(shaderJob, "temp", 0, 100);
    CompareAsts.assertEqualAsts(expected, ParseHelper.parse(new File(testFolder.getRoot(),
        resultsPrefix + ".frag")));
  }
}