@Test public void executablesCompilationTest_whenEndTerminatedLoopIsUsedInside() { final RobotFile model = ModelBuilder.modelForFile(new RobotVersion(3,1)) .withTestCasesTable() .withTestCase("test") .executable("log", "10") .executable("FOR", "${x}", "IN", "1", "2", "3") .executableEndTerminatedLoop("write", "${x}") .executable("END") .executable("log", "end") .build(); final List<RobotExecutableRow<TestCase>> rows = model.getTestCaseTable() .getTestCases() .get(0) .getExecutionContext(); final List<ExecutableWithDescriptor> descriptors = ExecutablesCompiler.compileExecutables(rows, null); assertThat(descriptors).hasSize(3); assertThat(descriptors.get(0).getCalledKeywordName()).isEqualTo("log"); assertThat(descriptors.get(0).isLoopExecutable()).isFalse(); assertThat(descriptors.get(0).isLastExecutable()).isFalse(); assertThat(descriptors.get(1).getCalledKeywordName()).isEqualTo("FOR"); assertThat(descriptors.get(1).isLoopExecutable()).isTrue(); assertThat(descriptors.get(1).isLastExecutable()).isFalse(); assertThat(descriptors.get(1).getLoopExecutable()).isNotNull(); assertThat(descriptors.get(1).getLoopExecutable().getInnerExecutables()).hasSize(1); assertThat(descriptors.get(1).getLoopExecutable().getInnerExecutables().get(0).getCalledKeywordName()) .isEqualTo("write"); assertThat(descriptors.get(2).getCalledKeywordName()).isEqualTo("log"); assertThat(descriptors.get(2).isLoopExecutable()).isFalse(); assertThat(descriptors.get(2).isLastExecutable()).isTrue(); }
static List<ExecutableWithDescriptor> compileExecutables(final List<? extends RobotExecutableRow<?>> executables, final String template) { final List<ExecutableWithDescriptor> elements = new ArrayList<>(); final List<ExecutableWithDescriptor> loopElements = new ArrayList<>(); ExecutableWithDescriptor loopHeader = null; for (final RobotExecutableRow<?> executableRow : executables) { final IExecutableRowDescriptor<?> descriptor = executableRow.buildLineDescription(); if (descriptor.getRowType() == RowType.FOR) { loopHeader = new ExecutableWithDescriptor(executableRow, descriptor, template); } else if (descriptor.getRowType() == RowType.FOR_CONTINUE && loopHeader != null) { loopElements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } else { if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } if (descriptor.getRowType() != RowType.FOR_END) { elements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } loopElements.clear(); loopHeader = null; } } if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } return elements; }
ExecutablesCompiler { static List<ExecutableWithDescriptor> compileExecutables(final List<? extends RobotExecutableRow<?>> executables, final String template) { final List<ExecutableWithDescriptor> elements = new ArrayList<>(); final List<ExecutableWithDescriptor> loopElements = new ArrayList<>(); ExecutableWithDescriptor loopHeader = null; for (final RobotExecutableRow<?> executableRow : executables) { final IExecutableRowDescriptor<?> descriptor = executableRow.buildLineDescription(); if (descriptor.getRowType() == RowType.FOR) { loopHeader = new ExecutableWithDescriptor(executableRow, descriptor, template); } else if (descriptor.getRowType() == RowType.FOR_CONTINUE && loopHeader != null) { loopElements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } else { if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } if (descriptor.getRowType() != RowType.FOR_END) { elements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } loopElements.clear(); loopHeader = null; } } if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } return elements; } }
ExecutablesCompiler { static List<ExecutableWithDescriptor> compileExecutables(final List<? extends RobotExecutableRow<?>> executables, final String template) { final List<ExecutableWithDescriptor> elements = new ArrayList<>(); final List<ExecutableWithDescriptor> loopElements = new ArrayList<>(); ExecutableWithDescriptor loopHeader = null; for (final RobotExecutableRow<?> executableRow : executables) { final IExecutableRowDescriptor<?> descriptor = executableRow.buildLineDescription(); if (descriptor.getRowType() == RowType.FOR) { loopHeader = new ExecutableWithDescriptor(executableRow, descriptor, template); } else if (descriptor.getRowType() == RowType.FOR_CONTINUE && loopHeader != null) { loopElements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } else { if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } if (descriptor.getRowType() != RowType.FOR_END) { elements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } loopElements.clear(); loopHeader = null; } } if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } return elements; }  }
ExecutablesCompiler { static List<ExecutableWithDescriptor> compileExecutables(final List<? extends RobotExecutableRow<?>> executables, final String template) { final List<ExecutableWithDescriptor> elements = new ArrayList<>(); final List<ExecutableWithDescriptor> loopElements = new ArrayList<>(); ExecutableWithDescriptor loopHeader = null; for (final RobotExecutableRow<?> executableRow : executables) { final IExecutableRowDescriptor<?> descriptor = executableRow.buildLineDescription(); if (descriptor.getRowType() == RowType.FOR) { loopHeader = new ExecutableWithDescriptor(executableRow, descriptor, template); } else if (descriptor.getRowType() == RowType.FOR_CONTINUE && loopHeader != null) { loopElements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } else { if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } if (descriptor.getRowType() != RowType.FOR_END) { elements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } loopElements.clear(); loopHeader = null; } } if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } return elements; }   }
ExecutablesCompiler { static List<ExecutableWithDescriptor> compileExecutables(final List<? extends RobotExecutableRow<?>> executables, final String template) { final List<ExecutableWithDescriptor> elements = new ArrayList<>(); final List<ExecutableWithDescriptor> loopElements = new ArrayList<>(); ExecutableWithDescriptor loopHeader = null; for (final RobotExecutableRow<?> executableRow : executables) { final IExecutableRowDescriptor<?> descriptor = executableRow.buildLineDescription(); if (descriptor.getRowType() == RowType.FOR) { loopHeader = new ExecutableWithDescriptor(executableRow, descriptor, template); } else if (descriptor.getRowType() == RowType.FOR_CONTINUE && loopHeader != null) { loopElements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } else { if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } if (descriptor.getRowType() != RowType.FOR_END) { elements.add(new ExecutableWithDescriptor(executableRow, descriptor, template)); } loopElements.clear(); loopHeader = null; } } if (loopHeader != null) { elements.add(new ExecutableWithDescriptor(new ForLoop(loopHeader, newArrayList(loopElements)), template)); } return elements; }    }