Acos: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Syntax) |
Keine Bearbeitungszusammenfassung |
||
Zeile 13: | Zeile 13: | ||
===Beispiele=== | ===Beispiele=== | ||
acos('1') --> returns 0 | acos('1') --> 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 testAcos() { | |||
assertTrue(0 == getEvaluator().getNumberResult("acos('1')")); | |||
assertTrue(PI == getEvaluator().getNumberResult("acos('-1')")); | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("acos('0')")); | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("acos('0')")); | |||
assertTrue(0.7953988301841436 == getEvaluator().getNumberResult("acos(0.7)")); | |||
assertTrue(0.7953988301841436 == getEvaluator().getNumberResult("acos(.7)")); | |||
} | |||
@Test | |||
public void testAcosWithInput() { | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("acos([pos=1])")); | |||
assertTrue(0 == getEvaluator().getNumberResult("acos([pos=2])")); | |||
assertTrue(PI == getEvaluator().getNumberResult("acos([pos=3])")); | |||
} | |||
@Test | |||
public void testAcosWithVariables() { | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("acos([var=a])")); | |||
assertTrue(0 == getEvaluator().getNumberResult("acos([var=b])")); | |||
assertTrue(PI == getEvaluator().getNumberResult("acos([var=c])")); | |||
} | |||
@Test | |||
public void testAcosWithExpressions() { | |||
assertTrue(0.861722668365135 == getEvaluator().getNumberResult("acos(acos(acos(0.7)))")); | |||
assertTrue(PI/2 == getEvaluator().getNumberResult("acos(acos(1))")); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void TestAcosWithONECharacter(){ | |||
getEvaluator().getNumberResult("acos(a)"); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testAcosWithEmptyStringArgument() { | |||
getEvaluator().getNumberResult(("acos('')")); | |||
} | |||
@Test(expected=InvalidCASFunctionArgumentException.class) | |||
public void testAcosWithEmptyArgument() { | |||
getEvaluator().getNumberResult(("acos()")); | |||
} | |||
@Test(expected=UndefinedExerciseVariableException.class) | |||
public void testAcosWithoutExerciseVariable() { | |||
getEvaluator().getNumberResult("acos('[var=j]')"); | |||
} | |||
@Test(expected=UndefinedFillInVariableException.class) | |||
public void testAcosWithoutInput() { | |||
getEvaluator().getNumberResult("acos('[pos=42]')"); | |||
} | |||
</syntaxhighlight> | |||
===Hinweise=== | ===Hinweise=== | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]] |
Version vom 21. Juni 2017, 09:53 Uhr
Beschreibung
Der Arkuskosinus wird durch die Funktion acos beschrieben. Sie erwartet einen Parameter und gibt den Wert an der Stelle zurück.
Syntax
acos(String zahl)
Parameter
- zahl - Ein Zahlenwert zwischen '-1' und '1'.
Return Value
- Gibt den Wert des Arkuskosinus an der Stelle zurück.
Beispiele
acos('1') --> 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 testAcos() {
assertTrue(0 == getEvaluator().getNumberResult("acos('1')"));
assertTrue(PI == getEvaluator().getNumberResult("acos('-1')"));
assertTrue(PI/2 == getEvaluator().getNumberResult("acos('0')"));
assertTrue(PI/2 == getEvaluator().getNumberResult("acos('0')"));
assertTrue(0.7953988301841436 == getEvaluator().getNumberResult("acos(0.7)"));
assertTrue(0.7953988301841436 == getEvaluator().getNumberResult("acos(.7)"));
}
@Test
public void testAcosWithInput() {
assertTrue(PI/2 == getEvaluator().getNumberResult("acos([pos=1])"));
assertTrue(0 == getEvaluator().getNumberResult("acos([pos=2])"));
assertTrue(PI == getEvaluator().getNumberResult("acos([pos=3])"));
}
@Test
public void testAcosWithVariables() {
assertTrue(PI/2 == getEvaluator().getNumberResult("acos([var=a])"));
assertTrue(0 == getEvaluator().getNumberResult("acos([var=b])"));
assertTrue(PI == getEvaluator().getNumberResult("acos([var=c])"));
}
@Test
public void testAcosWithExpressions() {
assertTrue(0.861722668365135 == getEvaluator().getNumberResult("acos(acos(acos(0.7)))"));
assertTrue(PI/2 == getEvaluator().getNumberResult("acos(acos(1))"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void TestAcosWithONECharacter(){
getEvaluator().getNumberResult("acos(a)");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAcosWithEmptyStringArgument() {
getEvaluator().getNumberResult(("acos('')"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAcosWithEmptyArgument() {
getEvaluator().getNumberResult(("acos()"));
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testAcosWithoutExerciseVariable() {
getEvaluator().getNumberResult("acos('[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testAcosWithoutInput() {
getEvaluator().getNumberResult("acos('[pos=42]')");
}