Commit a2e6d05e authored by Martti Käärik's avatar Martti Käärik
Browse files

Need to redeclare datause variables for TimeConstraint blocks + don't...

Need to redeclare datause variables for TimeConstraint blocks + don't auto-execute time constraint callables.
parent 5ef626b7
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1670,20 +1670,20 @@ public class JUnitTestGenerator extends Renderer {
	private FutureInfo declareFuture(Behaviour b, TimeConstraint tc, Map<DataUse, String> dataUseVariables) {
		String futureName = "timeConstraint_" + getElementName(tc) + "_" + getElementName(b);

		line("Future<ExecutionResult> " + futureName + " = " + COMPONENT_FIELD + ".timeConstraint(() -> ");
		line("ExecutionCallable " + futureName + " = " + COMPONENT_FIELD + ".timeConstraint(() -> ");
		blockOpen();

		DataUse exp = tc.getTimeConstraintExpression();
		// TODO some data use variables may not be available in the callback scope
//		lineComment("TODO some data use variables may not be usable in the callback scope");
		declareDataUses(tc, dataUseVariables, "");
		initializeDataUse(exp, dataUseVariables);
		// Need to redeclare datause variables
		Map<DataUse, String> localDataUseVariables = new Hashtable<DataUse, String>();
		declareDataUses(tc, localDataUseVariables, "");
		initializeDataUse(exp, localDataUseVariables);
		append("return ");
		write(exp, dataUseVariables);
		write(exp, localDataUseVariables);
		line(";");

		blockClose();
		line(").execute();");
		line(");");

		return new FutureInfo(futureName, "TimeoutResult", b);
	}