@Test
public void prepareStatementToDonateTopLevelBreakRemoved() throws Exception {

  // Checks that a top-level 'break' gets removed, even when injecting into a loop or
  // switch.
  final DonateLiveCodeTransformation dlc = getDummyTransformationObject();
  final TranslationUnit donor = ParseHelper.parse("#version 310 es\n"
      + "void main() {\n"
      + "  for (int i = 0; i < 10; i ++)\n"
      + "     if (i > 5) break;\n"
      + "}\n");
  final TranslationUnit reference = ParseHelper.parse("#version 310 es\n"
      + "void main() {\n"
      + "  for(int i = 0; i < 100; i++) {\n"
      + "    switch (i) {\n"
      + "      case 0:\n"
      + "        i++;\n"
      + "      default:\n"
      + "        i++;\n"
      + "    }\n"
      + "  }\n"
      + "}\n");
  for (IInjectionPoint injectionPoint : new InjectionPoints(reference, new RandomWrapper(0),
      item -> true).getAllInjectionPoints()) {
    final Stmt toDonate = ((ForStmt) donor.getMainFunction().getBody().getStmt(0)).getBody()
        .clone();
    assert toDonate instanceof IfStmt;
    final DonationContext dc = new DonationContext(toDonate, new HashMap<>(),
        new ArrayList<>(), donor.getMainFunction());
    final Stmt donated = dlc.prepareStatementToDonate(injectionPoint, dc,
        TransformationProbabilities.DEFAULT_PROBABILITIES, new RandomWrapper(0),
        ShadingLanguageVersion.ESSL_310);
    assertEquals("{\n"
        + " if(i > 5)\n"
        + "  1;\n"
        + "}\n", donated.getText());
  }
}