Asin: 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 testAsin1() { | |||
assertEquals(0, Evaluator.getNumberResult("asin(0)", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAsin2() { | ||
assertEquals(-PI / 2, Evaluator.getNumberResult("asin(-1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAsin3() { | ||
assertEquals(PI / 2, Evaluator.getNumberResult("asin(1)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAsin4() { | ||
assertEquals(0, Evaluator.getNumberResult("asin('0')", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | } | ||
@Test | @Test | ||
public void | public void testAsin5() { | ||
assertEquals(0.775397496610753, Evaluator.getNumberResult("asin(0.7)", exerciseVariableMap, fillInVariableMap), | |||
0.0); | |||
} | } | ||
@Test(expected= | @Test | ||
public void testAsinWithInput1() { | |||
assertEquals(0, Evaluator.getNumberResult("asin([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test | |||
public void testAsinWithInput2() { | |||
assertEquals(PI / 2, Evaluator.getNumberResult("asin([pos=2])", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test | |||
public void testAsinWithInput3() { | |||
assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([pos=3])", exerciseVariableMap, fillInVariableMap), | |||
0.0); | |||
} | |||
@Test | |||
public void testAsinWithVariables1() { | |||
assertEquals(0, Evaluator.getNumberResult("asin([var=a])", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test | |||
public void testAsinWithVariables2() { | |||
assertEquals(PI / 2, Evaluator.getNumberResult("asin([var=b])", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | |||
@Test | |||
public void testAsinWithVariables3() { | |||
assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([var=c])", exerciseVariableMap, fillInVariableMap), | |||
0.0); | |||
} | |||
@Test | |||
public void testAsinWithExpressions1() { | |||
assertEquals(0, Evaluator.getNumberResult("asin(asin(asin(0)))", exerciseVariableMap, fillInVariableMap), | |||
0.0); | |||
} | |||
@Test | |||
public void testAsinWithExpressions2() { | |||
assertEquals(0.202744039431659, | |||
Evaluator.getNumberResult("asin(asin(0.2))", exerciseVariableMap, fillInVariableMap), 0.0); | |||
} | |||
@Test(expected = FunctionInvalidArgumentTypeException.class) | |||
public void testAsinWithONECharacter() { | public void testAsinWithONECharacter() { | ||
Evaluator.getNumberResult("asin(a)", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void testAsinWithEmptyStringArgument() { | public void testAsinWithEmptyStringArgument() { | ||
Evaluator.getNumberResult("asin('')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void testAsinWithEmptyArgument() { | public void testAsinWithEmptyArgument() { | ||
Evaluator.getNumberResult("asin()", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedExerciseVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testAsinWithoutExerciseVariable() { | public void testAsinWithoutExerciseVariable() { | ||
Evaluator.getNumberResult("asin('[var=j]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedFillInVariableException.class) | ||
public void testAsinWithoutInput() { | public void testAsinWithoutInput() { | ||
Evaluator.getNumberResult("asin('[pos=42]')", exerciseVariableMap, fillInVariableMap); | |||
fail(); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Version vom 18. September 2017, 10:23 Uhr
Beschreibung
Der Arkussinus wird durch asin beschrieben. Er erwartet einen Parameter und gibt einen Wert an der Stelle zurück.
Syntax
asin(String zahl)
Parameter
- zahl - ein Wert zwischen '-1' und '1'
Return Value
- Gibt den Wert des Arkussinus an der Stelle zurück.
Beispiele
asin('0') --> returns 0
JUnit Tests
[Anzeigen]
private double PI = Math.PI;
@Test
public void testAsin1() {
assertEquals(0, Evaluator.getNumberResult("asin(0)", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAsin2() {
assertEquals(-PI / 2, Evaluator.getNumberResult("asin(-1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAsin3() {
assertEquals(PI / 2, Evaluator.getNumberResult("asin(1)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testAsin4() {
assertEquals(0, Evaluator.getNumberResult("asin('0')", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAsin5() {
assertEquals(0.775397496610753, Evaluator.getNumberResult("asin(0.7)", exerciseVariableMap, fillInVariableMap),
0.0);
}
@Test
public void testAsinWithInput1() {
assertEquals(0, Evaluator.getNumberResult("asin([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAsinWithInput2() {
assertEquals(PI / 2, Evaluator.getNumberResult("asin([pos=2])", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testAsinWithInput3() {
assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([pos=3])", exerciseVariableMap, fillInVariableMap),
0.0);
}
@Test
public void testAsinWithVariables1() {
assertEquals(0, Evaluator.getNumberResult("asin([var=a])", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test
public void testAsinWithVariables2() {
assertEquals(PI / 2, Evaluator.getNumberResult("asin([var=b])", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testAsinWithVariables3() {
assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([var=c])", exerciseVariableMap, fillInVariableMap),
0.0);
}
@Test
public void testAsinWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("asin(asin(asin(0)))", exerciseVariableMap, fillInVariableMap),
0.0);
}
@Test
public void testAsinWithExpressions2() {
assertEquals(0.202744039431659,
Evaluator.getNumberResult("asin(asin(0.2))", exerciseVariableMap, fillInVariableMap), 0.0);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAsinWithONECharacter() {
Evaluator.getNumberResult("asin(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAsinWithEmptyStringArgument() {
Evaluator.getNumberResult("asin('')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAsinWithEmptyArgument() {
Evaluator.getNumberResult("asin()", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testAsinWithoutExerciseVariable() {
Evaluator.getNumberResult("asin('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected = UndefinedFillInVariableException.class)
public void testAsinWithoutInput() {
Evaluator.getNumberResult("asin('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}