Expression implements Cloneable { public static Expression compile(String expression, String... variableNames) throws ExpressionException { return new Expression(expression, variableNames); } private  Expression(String expression, String... variableNames); private  Expression(String expression, Set<String> variableNames); static Expression compile(String expression, String... variableNames); double evaluate(double... values); double evaluate(double[] values, int timeout); void optimize(); @Override String toString(); SlotTable getSlots(); ExpressionEnvironment getEnvironment(); void setEnvironment(ExpressionEnvironment environment); Expression clone();  }
@Test public void testErrors() { { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("#")); assertEquals(0, e.getPosition(), "Error position"); } { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("x")); assertEquals(0, e.getPosition(), "Error position"); } { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("x()")); assertEquals(0, e.getPosition(), "Error position"); } { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("return")); assertEquals(6, e.getPosition(), "Error position"); } assertThrows(ExpressionException.class, () -> compile("(")); assertThrows(ExpressionException.class, () -> compile("x(")); { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("atan2(1)")); assertEquals(0, e.getPosition(), "Error position"); } { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("atan2(1, 2, 3)")); assertEquals(0, e.getPosition(), "Error position"); } { ExpressionException e = assertThrows(ExpressionException.class, () -> compile("rotate(1, 2, 3)")); assertEquals(7, e.getPosition(), "Error position"); } }