@Test
public void checkMutateSpecialCase() throws Exception {

  // This test aimed to expose an issue, but did not succeed.  It's been left
  // here in the spirit of "why delete a test?"
  final String reference = "#version 300 es\n"
      + "void main() {\n"
      + "  int t;\n"
      + "  {\n"
      + "  }\n"
      + "  gl_FragColor = vec4(float(t));\n"
      + "}\n";
  final IRandom generator = new RandomWrapper(0);
  for (int i = 0; i < 10; i++) {
    final DonateLiveCodeTransformation donateLiveCode =
        new DonateLiveCodeTransformation(item -> true, testFolder.getRoot(),
            GenerationParams.normal(ShaderKind.FRAGMENT, true),
            false);
    final TranslationUnit referenceTu = ParseHelper.parse(reference);
    BlockInjectionPoint blockInjectionPoint =
        new ScopeTrackingVisitor() {
          BlockInjectionPoint blockInjectionPoint;
          @Override
          public void visitBlockStmt(BlockStmt stmt) {
            super.visitBlockStmt(stmt);
            if (stmt.getNumStmts() == 0) {
              blockInjectionPoint = new BlockInjectionPoint(stmt, null, getEnclosingFunction(),
                  false, false, getCurrentScope());
            }
          }
          BlockInjectionPoint getBlockInjectionPoint(TranslationUnit tu) {
            visit(tu);
            return blockInjectionPoint;
          }
        }.getBlockInjectionPoint(referenceTu);
    final DeclarationStmt declarationStmt = new DeclarationStmt(
        new VariablesDeclaration(
            BasicType.INT,
            new VariableDeclInfo("a", null,
                new Initializer(
                    new BinaryExpr(
                        new BinaryExpr(
                            new BinaryExpr(
                                new BinaryExpr(
                                    new VariableIdentifierExpr("x1"),
                                    new VariableIdentifierExpr("x2"),
                                    BinOp.ADD
                                ),
                                new VariableIdentifierExpr("x3"),
                                BinOp.ADD
                            ),
                            new VariableIdentifierExpr("x4"),
                            BinOp.ADD
                        ),
                        new VariableIdentifierExpr("x5"),
                        BinOp.ADD
                    )
                )
            )));
    final Map<String, Type> freeVariables = new HashMap<>();
    freeVariables.put("x1", BasicType.INT);
    freeVariables.put("x2", BasicType.INT);
    freeVariables.put("x3", BasicType.INT);
    freeVariables.put("x4", BasicType.INT);
    freeVariables.put("x5", BasicType.INT);
    Stmt toDonate = donateLiveCode.prepareStatementToDonate(blockInjectionPoint,
        new DonationContext(
            declarationStmt,
            freeVariables,
            new ArrayList<>(),
            new FunctionDefinition(new FunctionPrototype("foo", VoidType.VOID,
                new ArrayList<>()), null)),
        TransformationProbabilities.onlyLiveCodeAlwaysSubstitute(),
        generator,
        referenceTu.getShadingLanguageVersion());
    blockInjectionPoint.inject(toDonate);
    final IdentityTransformation identityTransformation =
        new IdentityTransformation();
    identityTransformation.apply(referenceTu, TransformationProbabilities.onlyMutateExpressions(),
        generator,
        GenerationParams.large(ShaderKind.FRAGMENT, true)
    );
  }
}