private static void ta( boolean tkiontki, String input, String[] expectedResult, String... validResults) { String result; try { GeoCasCell f = new GeoCasCell(kernel.getConstruction()); kernel.getConstruction().addToConstructionList(f, false); f.setInput(input); if (tkiontki) { f.setEvalCommand("KeepInput"); } f.computeOutput(); boolean includesNumericCommand = false; HashSet<Command> commands = new HashSet<Command>(); if (f.getInputVE() == null) { Assert.assertEquals("Input should be parsed", "GEOGEBRAERROR", expectedResult[0]); return; } f.getInputVE().traverse(CommandCollector.getCollector(commands)); if (!commands.isEmpty()) { for (Command cmd : commands) { String cmdName = cmd.getName(); // Numeric used includesNumericCommand = includesNumericCommand || ("Numeric".equals(cmdName) && cmd.getArgumentNumber() > 1); } } if (f.getOutputValidExpression().unwrap() instanceof GeoElement) { result = f.getOutputValidExpression().toValueString(StringTemplate.testTemplateJSON); } else { result = f.getOutputValidExpression() != null ? f.getOutputValidExpression() .traverse(getGGBVectAdder()) .toString( includesNumericCommand ? StringTemplate.testNumeric : StringTemplate.testTemplateJSON) : f.getOutput(StringTemplate.testTemplate); } } catch (Throwable t) { String sts = ""; StackTraceElement[] st = t.getStackTrace(); for (int i = 0; i < 10 && i < st.length; i++) { StackTraceElement stElement = st[i]; sts += stElement.getClassName() + ":" + stElement.getMethodName() + stElement.getLineNumber() + "\n"; } result = t.getClass().getName() + ":" + t.getMessage() + sts; } for (int i = 0; i < expectedResult.length; i++) { if ("RANDOM".equals(expectedResult[i])) { return; } try { result = result .replaceAll("c_[0-9]", "c_0") .replaceAll("c_\\{[0-9]+\\}", "c_0") .replace("arccos", "acos") .replace("arctan", "atan") .replace("Wenn[", "If[") .replace("arcsin", "asin") .replace("NteWurzel", "nroot"); assertThat( result, equalToIgnoreWhitespaces( logger, input, expectedResult[i].replaceAll("c_[0-9]", "c_0"), validResults)); return; } catch (Throwable t) { // if (!(t instanceof AssertionError)) { t.printStackTrace(); // } if (i == expectedResult.length - 1) { Assert.assertEquals( result, (expectedResult[0] == null ? "null" : expectedResult[0].replaceAll("c_[0-9]", "c_0")) + " input:" + input); } } } }