!7 sS testCases = [[ if i make a list of 3 elements and add one more - how long is the new list? => 4 elements if i have a list of 10 elements - how long is it? => 10 elements ]]; p { L lines = lines(testCases); L l = indexesOfLinesBeginningWithDoubleArrow(lines); int i = 0, cases = 0; for (int line : l) { S question = lines(subList(lines, i, line)); S answer = trimDropPrefixTrim("=>", lines.get(line)); i = line+1; assertContainsCodeTokensIC(answer, callAnswerFunctionVerbose(question)); ++cases; } print("OK (" + n2(cases, 'case) + ")"); } answer { new L parts; L l = tok_splitAtSpacedDashes(s); parts.addAll(tok_splitAtAndFromMiddle(l.get(0))); parts.add(l.get(1)); pnl(parts); S answer = null; new Executor e; for (S part : parts) { print(part); e.process(part); L out = cloneAndClearList(e.output); printLinesWithIndent(" => ", out); if (nempty(out)) answer = last(out); } try answer answer; } sclass Executor { int length = -1; // unknown new L output; void say(S s) { output.add(s); } void process(S s) { L tok = javaTok(s); int i = findCodeTokensIC(tok, "", "elements"); if (i >= 0) ret with length = parseInt(tok.get(i)); if (hasCodeTokensIC(tok, "add", "one")) ret with ++length; if (hasCodeTokensIC(tok, "how", "long")) say("The list is " + n2(length, "element") + " long"); } }