@Test
public void testInsertAsFirstStatement() throws Exception {

  final String program = ""
      + "int a = 1;"
      + "void main() {"
      + " int b = a; "
      + "}";
  // We have to ensure that the new assignment statements is inserted
  // as the first statement in main() function.
  final String expected = ""
      + "int a;"
      + "void main() {"
      + " a = 1;"
      + " int b = a;"
      + "}";
  final TranslationUnit tu = ParseHelper.parse(program);
  final List<GlobalVariableDeclToExprReductionOpportunity> ops =
      GlobalVariableDeclToExprReductionOpportunities
      .findOpportunities(MakeShaderJobFromFragmentShader.make(tu), new ReducerContext(true,
          ShadingLanguageVersion.ESSL_100,
          new RandomWrapper(0), new IdGenerator()));
  assertEquals(1, ops.size());
  ops.forEach(GlobalVariableDeclToExprReductionOpportunity::applyReductionImpl);
  CompareAsts.assertEqualAsts(expected, tu);
}