Tan: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 19: | Zeile 19: | ||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
@ | @BeforeClass | ||
public void beforeTest() { | 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 | @Test | ||
public void | public void testTan2() { | ||
assertEquals(0, Evaluator.getNumberResult("tan('[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testTan3() { | ||
assertEquals(0, Evaluator.getNumberResult("tan('-[var=PI]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testTan4() { | ||
assertEquals(1, Evaluator.getNumberResult("tan('[var=PI]/4')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testTan5() { | ||
assertEquals(-1, Evaluator.getNumberResult("tan('-[var=PI]/4')", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testTanWithInput1() { | ||
assertEquals(0, Evaluator.getNumberResult("tan('[pos=1]')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test(expected= | @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() { | public void testTanWithEmptyStringArgument() { | ||
Evaluator.getNumberResult("tan('')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testTanWithEmptyArgument() { | public void testTanWithEmptyArgument() { | ||
Evaluator.getNumberResult("tan()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testTanWithoutExerciseVariable() { | public void testTanWithoutExerciseVariable() { | ||
Evaluator.getNumberResult("tan('[var=j]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testTanWithoutInput() { | public void testTanWithoutInput() { | ||
Evaluator.getNumberResult("tan('[pos=42]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Hinweise=== | ===Hinweise=== | ||
* Berechnet nur den Tangens mit Werten im Bogenmaß. Der Gradmaß muss ggf. vorher umgewandelt werden. | * Berechnet nur den Tangens mit Werten im Bogenmaß. Der Gradmaß muss ggf. vorher umgewandelt werden. | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]] |
Version vom 19. September 2017, 07:45 Uhr
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.