Asin: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Syntax) |
Keine Bearbeitungszusammenfassung |
||
Zeile 13: | Zeile 13: | ||
===Beispiele=== | ===Beispiele=== | ||
asin('0') --> returns 0 | asin('0') --> returns 0 | ||
====JUnit Tests==== | |||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed"> | |||
@Before | |||
public void beforeTest() { | |||
placeFillInVariable(1, OMParser.parse("0")); | |||
placeFillInVariable(2, OMParser.parse("1")); | |||
placeFillInVariable(3, OMParser.parse("-1")); | |||
placeExerciseVariable("a", OMParser.parse("0")); | |||
placeExerciseVariable("b", OMParser.parse("1")); | |||
placeExerciseVariable("c", OMParser.parse("-1")); | |||
} | |||
@Test | |||
public void testAsin() { | |||
assertTrue(0 == getEvaluator().getNumberResult("asin(0)")); | |||
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin(-1)")); | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("asin(1)")); | |||
assertTrue(0 == getEvaluator().getNumberResult("asin('0')")); | |||
assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(0.7)")); | |||
assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(.7)")); | |||
} | |||
@Test | |||
public void testAsinWithInput() { | |||
assertTrue(0 == getEvaluator().getNumberResult("asin([pos=1])")); | |||
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([pos=2])")); | |||
assertFalse(PI/2 == getEvaluator().getNumberResult("asin([pos=3])")); | |||
} | |||
@Test | |||
public void testAsinWithVariables() { | |||
assertTrue(0 == getEvaluator().getNumberResult("asin([var=a])")); | |||
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([var=b])")); | |||
assertFalse(PI/2 == getEvaluator().getNumberResult("asin([var=c])")); | |||
} | |||
@Test | |||
public void testAsinWithExpressions() { | |||
assertTrue(0 == getEvaluator().getNumberResult("asin(asin(asin(0)))")); | |||
assertTrue(0.2027440393165833 == getEvaluator().getNumberResult("asin(asin(0.2))")); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testAsinWithONECharacter() { | |||
getEvaluator().getNumberResult("asin(a)"); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testAsinWithEmptyStringArgument() { | |||
getEvaluator().getNumberResult("asin('')"); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testAsinWithEmptyArgument() { | |||
getEvaluator().getNumberResult("asin()"); | |||
} | |||
@Test(expected=UndefinedExerciseVariableException.class) | |||
public void testAsinWithoutExerciseVariable() { | |||
getEvaluator().getNumberResult("asin('[var=j]')"); | |||
} | |||
@Test(expected=UndefinedFillInVariableException.class) | |||
public void testAsinWithoutInput() { | |||
getEvaluator().getNumberResult("asin('[pos=42]')"); | |||
} | |||
</syntaxhighlight> | |||
===Hinweise=== | ===Hinweise=== | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]] |
Version vom 21. Juni 2017, 09:54 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
@Before
public void beforeTest() {
placeFillInVariable(1, OMParser.parse("0"));
placeFillInVariable(2, OMParser.parse("1"));
placeFillInVariable(3, OMParser.parse("-1"));
placeExerciseVariable("a", OMParser.parse("0"));
placeExerciseVariable("b", OMParser.parse("1"));
placeExerciseVariable("c", OMParser.parse("-1"));
}
@Test
public void testAsin() {
assertTrue(0 == getEvaluator().getNumberResult("asin(0)"));
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin(-1)"));
assertTrue(PI/2 == getEvaluator().getNumberResult("asin(1)"));
assertTrue(0 == getEvaluator().getNumberResult("asin('0')"));
assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(0.7)"));
assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(.7)"));
}
@Test
public void testAsinWithInput() {
assertTrue(0 == getEvaluator().getNumberResult("asin([pos=1])"));
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([pos=2])"));
assertFalse(PI/2 == getEvaluator().getNumberResult("asin([pos=3])"));
}
@Test
public void testAsinWithVariables() {
assertTrue(0 == getEvaluator().getNumberResult("asin([var=a])"));
assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([var=b])"));
assertFalse(PI/2 == getEvaluator().getNumberResult("asin([var=c])"));
}
@Test
public void testAsinWithExpressions() {
assertTrue(0 == getEvaluator().getNumberResult("asin(asin(asin(0)))"));
assertTrue(0.2027440393165833 == getEvaluator().getNumberResult("asin(asin(0.2))"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAsinWithONECharacter() {
getEvaluator().getNumberResult("asin(a)");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAsinWithEmptyStringArgument() {
getEvaluator().getNumberResult("asin('')");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAsinWithEmptyArgument() {
getEvaluator().getNumberResult("asin()");
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testAsinWithoutExerciseVariable() {
getEvaluator().getNumberResult("asin('[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testAsinWithoutInput() {
getEvaluator().getNumberResult("asin('[pos=42]')");
}