SplitForLoopTransformation implements ITransformation { @Override public boolean apply(TranslationUnit tu, TransformationProbabilities probabilities, IRandom generator, GenerationParams generationParams) { List<SplitForLoopMutation> splitForLoopMutations = new SplitForLoopMutationFinder(tu, generator) .findMutations(probabilities::splitLoops, generator); for (SplitForLoopMutation mutation : splitForLoopMutations) { mutation.apply(); } return !splitForLoopMutations.isEmpty(); }  @Override boolean apply(TranslationUnit tu,
                       TransformationProbabilities probabilities,
                       IRandom generator,
                       GenerationParams generationParams); @Override String getName(); static final String NAME; }
@Test public void testSplitShouldBePossible() throws Exception { final String program = "#version 100\nvoid main() { for(int i = 0; i < 10; i++) { } }"; final TranslationUnit tu = ParseHelper.parse(program); assertEquals(1, countForLoops(tu)); new SplitForLoopTransformation().apply(tu, TransformationProbabilities.onlySplitLoops(), new RandomWrapper(0), GenerationParams.normal(ShaderKind.FRAGMENT, true)); assertEquals(2, countForLoops(tu)); }
@Test public void testSplitShouldNotBePossible() throws Exception { final String program = "#version 100\nvoid main() { for(int i = 0; i < 10; i++) { if(true) " + "break; } }"; final TranslationUnit tu = ParseHelper.parse(program); assertEquals(1, countForLoops(tu)); new SplitForLoopTransformation().apply(tu, TransformationProbabilities.onlySplitLoops(), new RandomWrapper(0), GenerationParams.normal(ShaderKind.FRAGMENT, true)); assertEquals(1, countForLoops(tu)); }