@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException,
ErroneousExerciseVariableException {
deriveFillInVariableMap.put(1, ExpressionParser.parse("x", null, null));
deriveFillInVariableMap.put(2, ExpressionParser.parse("0.5", null, null));
deriveExerciseVariableMap.put("a", ExpressionParser.parse("x", null, null));
deriveExerciseVariableMap.put("b", ExpressionParser.parse("0.5", null, null));
}
@Test
public void testDerive1() {
assertEquals(ExpressionParser.parse("2*x", null, null),
Evaluator.evaluate("derive('x^2','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive2() {
assertEquals(ExpressionParser.parse("0", null, null),
Evaluator.evaluate("derive('x^2','y')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive3() {
assertEquals(ExpressionParser.parse("2*x+2", null, null),
Evaluator.evaluate("derive('x^2 + 2x','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive4() {
assertEquals(ExpressionParser.parse("x", null, null),
Evaluator.evaluate("derive('0.5*x^2','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive5() {
assertEquals(ExpressionParser.parse("x", null, null),
Evaluator.evaluate("derive('.5*x^2','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive6() {
assertEquals(ExpressionParser.parse("2*x+1", null, null),
Evaluator.evaluate("derive('x^2+x+3','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDerive7() {
OMOBJ expected = ExpressionParser.parse("2*(y^2*x)", null, null);
assertEquals(expected.getOMA(), Evaluator
.evaluate("derive('(x*y)^2','x')", deriveExerciseVariableMap, deriveFillInVariableMap).getOMA());
}
@Test
public void testDeriveWithInput1() {
assertEquals(ExpressionParser.parse("x", null, null),
Evaluator.evaluate("derive('0.5*x^2 + 3','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDeriveWithInput2() {
assertEquals(ExpressionParser.parse("2*x+2", null, null), Evaluator.evaluate(
"derive('[pos=1]^2 + 2*[pos=1] + 4','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDeriveWithExpressions() {
assertEquals(ExpressionParser.parse("x", null, null), Evaluator.evaluate("derive(derive('(1/6)*x^3', 'x'),'x')",
deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDeriveWithVariables1() {
assertEquals(ExpressionParser.parse("x", null, null),
Evaluator.evaluate("derive('0.5*x^2 + 3','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDeriveWithVariables2() {
assertEquals(ExpressionParser.parse("2*x+2", null, null), Evaluator.evaluate(
"derive('[var=a]^2 + 2*[var=a] + 4','x')", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test
public void testDeriveWithONECharacter() {
assertEquals(ExpressionParser.parse("1", null, null),
Evaluator.evaluate("derive(a, a)", deriveExerciseVariableMap, deriveFillInVariableMap));
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testDeriveWithEmptyStringArguments() {
Evaluator.evaluate("derive('', '')", deriveExerciseVariableMap, deriveFillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testDeriveWithEmptyArgument() {
Evaluator.evaluate("derive()", deriveExerciseVariableMap, deriveFillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testDeriveWithoutExerciseVariable() {
Evaluator.evaluate("derive([var=j], [var=j])", deriveExerciseVariableMap, deriveFillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testDeriveWithoutInput() {
Evaluator.evaluate("derive([pos=42], [pos=42])", deriveExerciseVariableMap, deriveFillInVariableMap);
fail();
}