@Test
public void testReturnsRemovedVoid() throws Exception {

  final String program = "void foo() {"
        + "  int x = 2;"
        + "  int y = 3;"
        + "  x = y;"
        + "  if (x == y) {"
        + "    return;"
        + "  } else {"
        + "    for (int i = 0; i < 100; i++) {"
        + "      if (i > x) {"
        + "        return;"
        + "      }"
        + "      y += i;"
        + "    }"
        + "  }"
        + "  x++;"
        + "}";
  final String expected = "void foo() {"
        + "  bool foo_has_returned = false;"
        + "  int x = 2;"
        + "  int y = 3;"
        + "  x = y;"
        + "  if (x == y) {"
        + "    foo_has_returned = true;"
        + "  } else {"
        + "    for (int i = 0; (!foo_has_returned) && i < 100; i++) {"
        + "      if (i > x) {"
        + "        foo_has_returned = true;"
        + "      }"
        + "      if (!foo_has_returned) {"
        + "        y += i;"
        + "      }"
        + "    }"
        + "  }"
        + "  if(!foo_has_returned) {"
        + "    x++;"
        + "  }"
        + "}";
  final TranslationUnit tu = ParseHelper.parse(program);
  final FunctionDefinition fd = findFunctionDefinition(tu, "foo");
  ReturnRemover.removeReturns(fd, ShadingLanguageVersion.ESSL_300);
  CompareAstsDuplicate.assertEqualAsts(expected, tu);
}