@Test
public void testInitializersAreInlined() throws Exception {

  final String original = "void main() {"
        + "    float GLF_live3_x = 3.0 + sin(7.0);\n"
        + "    float GLF_live3_y = GLF_live3_x + cos(8.0);\n"
        + "}\n";
  final String expected = "void main() {"
        + "    float GLF_live3_x = 3.0;\n"
        + "    float GLF_live3_y = sin(7.0) + cos(8.0);\n"
        + "}\n";
  final File tempFile = testFolder.newFile("temp.frag");
  final File tempJsonFile = testFolder.newFile("temp.json");
  FileUtils.writeStringToFile(tempFile, original, StandardCharsets.UTF_8);
  FileUtils.writeStringToFile(tempJsonFile, "{ }", StandardCharsets.UTF_8);
  final ShadingLanguageVersion version = ShadingLanguageVersion.ESSL_100;
  final IRandom generator = new RandomWrapper(0);
  final TranslationUnit tu = ParseHelper.parse(tempFile);
  ShaderJob state = new GlslShaderJob(
      Optional.empty(), new PipelineInfo(tempJsonFile), tu);
  IFileJudge referencesSinCosAnd3 = (shaderJobFile, shaderResultFileOutput) -> {
    try {
      final String contents = FileUtils.readFileToString(
          FileHelper.replaceExtension(shaderJobFile, ".frag"), StandardCharsets.UTF_8);
      return contents.contains("float GLF_live3_x = 3.0 + sin(7.0);")
                  && contents.contains("float GLF_live3_y = GLF_live3_x + cos(8.0);")
          || contents.contains("float GLF_live3_x = 3.0 + sin(7.0);")
                  && contents.contains("float GLF_live3_y = (3.0 + sin(7.0)) + cos(8.0);")
          || contents.contains("float GLF_live3_x = 3.0;")
                  && contents.contains("float GLF_live3_y = (3.0 + sin(7.0)) + cos(8.0);")
          || contents.contains("float GLF_live3_x = 3.0;")
                  && contents.contains("float GLF_live3_y = (sin(7.0)) + cos(8.0);")
          || contents.contains("float GLF_live3_x = 3.0;")
                  && contents.contains("float GLF_live3_y = sin(7.0) + cos(8.0);");
    } catch (IOException e) {
      return false;
    }
  };
  final String reducedFilesPrefix = new ReductionDriver(
      new ReducerContext(false, version, generator, new IdGenerator()),
      false, fileOps,
      referencesSinCosAnd3, testFolder.getRoot())
      .doReduction(state, getPrefix(tempFile), 0, -1);
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected)),
        PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(
            new File(testFolder.getRoot(), reducedFilesPrefix + ".frag"))));
}