Atan: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 17: | Zeile 17: | ||
<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"> | ||
@ | private double PI = Math.PI; | ||
public void | |||
@Test | |||
public void testAtan1() { | |||
assertEquals(0, Evaluator.getNumberResult("atan('0')", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test | |||
public void testAtan2() { | |||
assertEquals(0.463647609000806, | |||
Evaluator.getNumberResult("atan('0.5')", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test | |||
public void testAtan4() { | |||
assertEquals(PI / 4, Evaluator.getNumberResult("atan('1')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testAtan5() { | |||
assertEquals(-PI / 4, Evaluator.getNumberResult("atan('-1')", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testAtan6() { | |||
assertEquals(PI / 4, Evaluator.getNumberResult("atan(1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testAtan7() { | |||
assertEquals(-PI / 4, Evaluator.getNumberResult("atan(-1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testAtanWithInput1() { | |||
assertEquals(0, Evaluator.getNumberResult("atan([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtanWithInput2() { | ||
assertEquals(PI / 4, Evaluator.getNumberResult("atan([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtanWithVariables1() { | ||
assertEquals(0, Evaluator.getNumberResult("atan([var=a])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtanWithVariables2() { | ||
assertEquals(PI / 4, Evaluator.getNumberResult("atan([var=b])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAtanWithExpression1() { | ||
assertEquals(0, Evaluator.getNumberResult("atan(atan(0))", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test(expected= | @Test | ||
public void testAtanWithExpression2() { | |||
assertEquals(0, Evaluator.getNumberResult("atan(atan(atan(0)))", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testAtanWithONECharacter() { | public void testAtanWithONECharacter() { | ||
Evaluator.getNumberResult("atan(a)", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testAtanWithEmptyStringArgument() { | public void testAtanWithEmptyStringArgument() { | ||
Evaluator.getNumberResult("atan('')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testAtanWithEmptyArgument() { | public void testAtanWithEmptyArgument() { | ||
Evaluator.getNumberResult("atan()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testAtanWithoutExerciseVariable() { | public void testAtanWithoutExerciseVariable() { | ||
Evaluator.getNumberResult("atan([var=j])", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testAtanWithoutInput() { | public void testAtanWithoutInput() { | ||
Evaluator.getNumberResult("atan([pos=42])", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Hinweise=== | ===Hinweise=== | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]] |
Version vom 18. September 2017, 10:24 Uhr
Beschreibung
Der Arkustangens wird durch die Funktion atan' beschrieben. Er erwartet einen Parameter und gibt einen Wert zurück.
Syntax
atan(String zahl)
Parameter
- zahl - einen Zahlenwert
Return Value
- Gibt den Wert des Arkustangens an der Stelle zurück.
Beispiele
atan('0') --> returns 0
JUnit Tests
[Anzeigen]
private double PI = Math.PI;
@Test
public void testAtan1() {
assertEquals(0, Evaluator.getNumberResult("atan('0')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAtan2() {
assertEquals(0.463647609000806,
Evaluator.getNumberResult("atan('0.5')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAtan4() {
assertEquals(PI / 4, Evaluator.getNumberResult("atan('1')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan5() {
assertEquals(-PI / 4, Evaluator.getNumberResult("atan('-1')", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan6() {
assertEquals(PI / 4, Evaluator.getNumberResult("atan(1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtan7() {
assertEquals(-PI / 4, Evaluator.getNumberResult("atan(-1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtanWithInput1() {
assertEquals(0, Evaluator.getNumberResult("atan([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAtanWithInput2() {
assertEquals(PI / 4, Evaluator.getNumberResult("atan([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtanWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("atan([var=a])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAtanWithVariables2() {
assertEquals(PI / 4, Evaluator.getNumberResult("atan([var=b])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAtanWithExpression1() {
assertEquals(0, Evaluator.getNumberResult("atan(atan(0))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAtanWithExpression2() {
assertEquals(0, Evaluator.getNumberResult("atan(atan(atan(0)))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAtanWithONECharacter() {
Evaluator.getNumberResult("atan(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAtanWithEmptyStringArgument() {
Evaluator.getNumberResult("atan('')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAtanWithEmptyArgument() {
Evaluator.getNumberResult("atan()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testAtanWithoutExerciseVariable() {
Evaluator.getNumberResult("atan([var=j])", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testAtanWithoutInput() {
Evaluator.getNumberResult("atan([pos=42])", exerciseVariableMap, fillInVariableMap);
fail();
}