Acos: Unterschied zwischen den Versionen

Aus JACK Wiki
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">
@Before
private double PI = Math.PI;
public void beforeTest() {
 
  placeFillInVariable(1, OMParser.parse("0"));
@Test
  placeFillInVariable(2, OMParser.parse("1"));
public void testAcos1() {
  placeFillInVariable(3, OMParser.parse("-1"));
assertEquals(0, Evaluator.getNumberResult("acos('1')", exerciseVariableMap, fillInVariableMap), 0.0);
}
  placeExerciseVariable("a", OMParser.parse("0"));
 
  placeExerciseVariable("b", OMParser.parse("1"));
@Test
  placeExerciseVariable("c", OMParser.parse("-1"));
public void testAcos2() {
assertEquals(PI, Evaluator.getNumberResult("acos('-1')", exerciseVariableMap, fillInVariableMap), 0.0);
}
 
@Test
public void testAcos3() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}
 
@Test
public void testAcos4() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}
 
@Test
public void testAcos5() {
assertEquals(0.795398830184144, Evaluator.getNumberResult("acos(0.7)", exerciseVariableMap, fillInVariableMap),
0.0);
}
 
@Test
public void testAcosWithInput1() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos([pos=1])", exerciseVariableMap, fillInVariableMap),
0.0001);
}
 
@Test
public void testAcosWithInput2() {
assertEquals(0, Evaluator.getNumberResult("acos([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0);
}
 
@Test
public void testAcosWithInput3() {
assertEquals(PI, Evaluator.getNumberResult("acos([pos=3])", exerciseVariableMap, fillInVariableMap), 0.0);
}
 
@Test
public void testAcosWithVariables1() {
assertEquals(PI / 2, Evaluator.getNumberResult("acos([var=a])", exerciseVariableMap, fillInVariableMap),
0.000001);
}
}
 
@Test
@Test
public void testAcos() {
public void testAcosWithVariables2() {
  assertTrue(0 == getEvaluator().getNumberResult("acos('1')"));
assertEquals(0, Evaluator.getNumberResult("acos([var=b])", exerciseVariableMap, fillInVariableMap), 0.0);
  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
@Test
public void testAcosWithInput() {
public void testAcosWithVariables3() {
  assertTrue(PI/2 == getEvaluator().getNumberResult("acos([pos=1])"));
assertEquals(PI, Evaluator.getNumberResult("acos([var=c])", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(0 == getEvaluator().getNumberResult("acos([pos=2])"));
  assertTrue(PI == getEvaluator().getNumberResult("acos([pos=3])"));
}
}


@Test
@Test
public void testAcosWithVariables() {
public void testAcosWithExpressions1() {
  assertTrue(PI/2 == getEvaluator().getNumberResult("acos([var=a])"));
assertEquals(0.861722668365136,
  assertTrue(0 == getEvaluator().getNumberResult("acos([var=b])"));
Evaluator.getNumberResult("acos(acos(acos(0.7)))", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(PI == getEvaluator().getNumberResult("acos([var=c])"));
}
}
 
@Test
@Test
public void testAcosWithExpressions() {
public void testAcosWithExpressions2() {
  assertTrue(0.861722668365135 == getEvaluator().getNumberResult("acos(acos(acos(0.7)))"));
assertEquals(PI / 2, Evaluator.getNumberResult("acos(acos(1))", exerciseVariableMap, fillInVariableMap), 0.0001);
  assertTrue(PI/2 == getEvaluator().getNumberResult("acos(acos(1))"));
}
}


@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void TestAcosWithONECharacter(){
public void TestAcosWithONECharacter() {
  getEvaluator().getNumberResult("acos(a)");
Evaluator.getNumberResult("acos(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAcosWithEmptyStringArgument() {
public void testAcosWithEmptyStringArgument() {
  getEvaluator().getNumberResult(("acos('')"));
Evaluator.getNumberResult("acos('')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAcosWithEmptyArgument() {
public void testAcosWithEmptyArgument() {
  getEvaluator().getNumberResult(("acos()"));
Evaluator.getNumberResult("acos()", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedExerciseVariableException.class)
@Test(expected = UndefinedExerciseVariableException.class)
public void testAcosWithoutExerciseVariable() {
public void testAcosWithoutExerciseVariable() {
  getEvaluator().getNumberResult("acos('[var=j]')");
Evaluator.getNumberResult("acos('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedFillInVariableException.class)
@Test(expected = UndefinedFillInVariableException.class)
public void testAcosWithoutInput() {
public void testAcosWithoutInput() {
  getEvaluator().getNumberResult("acos('[pos=42]')");
Evaluator.getNumberResult("acos('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
</syntaxhighlight>
</syntaxhighlight>

Version vom 18. September 2017, 10:20 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

[Anzeigen]

private double PI = Math.PI;

@Test
public void testAcos1() {
	assertEquals(0, Evaluator.getNumberResult("acos('1')", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcos2() {
	assertEquals(PI, Evaluator.getNumberResult("acos('-1')", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcos3() {
	assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}

@Test
public void testAcos4() {
	assertEquals(PI / 2, Evaluator.getNumberResult("acos('0')", exerciseVariableMap, fillInVariableMap), 0.000001);
}

@Test
public void testAcos5() {
	assertEquals(0.795398830184144, Evaluator.getNumberResult("acos(0.7)", exerciseVariableMap, fillInVariableMap),
			0.0);
}

@Test
public void testAcosWithInput1() {
	assertEquals(PI / 2, Evaluator.getNumberResult("acos([pos=1])", exerciseVariableMap, fillInVariableMap),
			0.0001);
}

@Test
public void testAcosWithInput2() {
	assertEquals(0, Evaluator.getNumberResult("acos([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcosWithInput3() {
	assertEquals(PI, Evaluator.getNumberResult("acos([pos=3])", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcosWithVariables1() {
	assertEquals(PI / 2, Evaluator.getNumberResult("acos([var=a])", exerciseVariableMap, fillInVariableMap),
			0.000001);
}

@Test
public void testAcosWithVariables2() {
	assertEquals(0, Evaluator.getNumberResult("acos([var=b])", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcosWithVariables3() {
	assertEquals(PI, Evaluator.getNumberResult("acos([var=c])", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcosWithExpressions1() {
	assertEquals(0.861722668365136,
			Evaluator.getNumberResult("acos(acos(acos(0.7)))", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAcosWithExpressions2() {
	assertEquals(PI / 2, Evaluator.getNumberResult("acos(acos(1))", exerciseVariableMap, fillInVariableMap), 0.0001);
}

@Test(expected = FunctionInvalidArgumentTypeException.class)
public void TestAcosWithONECharacter() {
	Evaluator.getNumberResult("acos(a)", exerciseVariableMap, fillInVariableMap);
	fail();
}

@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAcosWithEmptyStringArgument() {
	Evaluator.getNumberResult("acos('')", exerciseVariableMap, fillInVariableMap);
	fail();
}

@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAcosWithEmptyArgument() {
	Evaluator.getNumberResult("acos()", exerciseVariableMap, fillInVariableMap);
	fail();
}

@Test(expected = UndefinedExerciseVariableException.class)
public void testAcosWithoutExerciseVariable() {
	Evaluator.getNumberResult("acos('[var=j]')", exerciseVariableMap, fillInVariableMap);
	fail();
}

@Test(expected = UndefinedFillInVariableException.class)
public void testAcosWithoutInput() {
	Evaluator.getNumberResult("acos('[pos=42]')", exerciseVariableMap, fillInVariableMap);
	fail();
}

Hinweise