Tan
Zur Navigation springen
Zur Suche springen
Beschreibung
Der Tangens wird durch die Funktion tan beschrieben. Sie erwartet einen Parameter und gibt einen Wert zurück.
Syntax
tan(String zeichenkette)
Parameter
- zeichenkette - ein Wert im Bogenmaß
Return Value
- Gibt den Wert des Tangens an der Stelle zurück.
Beispiele
tan('Pi/4') --> returns 1
tan('0') --> 0
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
fillInVariableMap.put(2, OMCreator.createOMOBJ(OMSymbol.NUMS1_PI));
}
@Test
public void testTan1() {
assertEquals(0, Evaluator.getNumberResult("tan('0')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTan2() {
assertEquals(0, Evaluator.getNumberResult("tan('[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTan3() {
assertEquals(0, Evaluator.getNumberResult("tan('-[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTan4() {
assertEquals(1, Evaluator.getNumberResult("tan('[var=PI]/4')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTan5() {
assertEquals(-1, Evaluator.getNumberResult("tan('-[var=PI]/4')", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testTanWithInput1() {
assertEquals(0, Evaluator.getNumberResult("tan('[pos=1]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTanWithInput2() {
assertEquals(1, Evaluator.getNumberResult("tan('[pos=2]/4')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTanWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("tan('[var=a]')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTanWithVariables2() {
assertEquals(1, Evaluator.getNumberResult("tan('[var=PI]/4')", exerciseVariableMap, fillInVariableMap), 0.0001); // Rounding
// Error
}
@Test
public void testTanWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("tan(tan(0))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testTanWithExpressions2() {
assertEquals(0, Evaluator.getNumberResult("tan(tan(tan(0)))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testTanWithONECharacter() {
Evaluator.getNumberResult("tan(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testTanWithEmptyStringArgument() {
Evaluator.getNumberResult("tan('')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testTanWithEmptyArgument() {
Evaluator.getNumberResult("tan()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testTanWithoutExerciseVariable() {
Evaluator.getNumberResult("tan('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testTanWithoutInput() {
Evaluator.getNumberResult("tan('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}
Hinweise
- Berechnet nur den Tangens mit Werten im Bogenmaß. Der Gradmaß muss ggf. vorher umgewandelt werden.