Atan: 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 testAtan1() {
assertEquals(0, Evaluator.getNumberResult("atan('0')", exerciseVariableMap, fillInVariableMap), 0.0);
  placeExerciseVariable("a", OMParser.parse("0"));
}
  placeExerciseVariable("b", OMParser.parse("1"));
 
@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 testAtan() {
public void testAtanWithInput2() {
  assertTrue(0 == getEvaluator().getNumberResult("atan('0')"));
assertEquals(PI / 4, Evaluator.getNumberResult("atan([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0001);
  assertTrue(0.4636476090008061 == getEvaluator().getNumberResult("atan('0.5')"));
  assertTrue(0.4636476090008061 == getEvaluator().getNumberResult("atan('.5')"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan('1')"));
  assertTrue(-PI/4 == getEvaluator().getNumberResult("atan('-1')"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan(1)"));
  assertTrue(-PI/4 == getEvaluator().getNumberResult("atan(-1)"));
}
}


@Test
@Test
public void testAtanWithInput() {
public void testAtanWithVariables1() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([pos=1])"));
assertEquals(0, Evaluator.getNumberResult("atan([var=a])", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([pos=2])"));
}
}


@Test
@Test
public void testAtanWithVariables() {
public void testAtanWithVariables2() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([var=a])"));
assertEquals(PI / 4, Evaluator.getNumberResult("atan([var=b])", exerciseVariableMap, fillInVariableMap), 0.0001);
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([var=b])"));
}
}
 
@Test
@Test
public void testAtanWithExpression() {
public void testAtanWithExpression1() {
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(0))"));
assertEquals(0, Evaluator.getNumberResult("atan(atan(0))", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(atan(0)))"));
}
}


@Test(expected=InvalidCASFunctionArgumentException.class)
@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() {
  getEvaluator().getNumberResult("atan(a)");
Evaluator.getNumberResult("atan(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAtanWithEmptyStringArgument() {
public void testAtanWithEmptyStringArgument() {
  getEvaluator().getNumberResult(("atan('')"));
Evaluator.getNumberResult("atan('')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAtanWithEmptyArgument() {
public void testAtanWithEmptyArgument() {
  getEvaluator().getNumberResult(("atan()"));
Evaluator.getNumberResult("atan()", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedExerciseVariableException.class)
@Test(expected = UndefinedExerciseVariableException.class)
public void testAtanWithoutExerciseVariable() {
public void testAtanWithoutExerciseVariable() {
  getEvaluator().getNumberResult("atan([var=j])");
Evaluator.getNumberResult("atan([var=j])", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedFillInVariableException.class)
@Test(expected = UndefinedFillInVariableException.class)
public void testAtanWithoutInput() {
public void testAtanWithoutInput() {
  getEvaluator().getNumberResult("atan([pos=42])");
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();
}

Hinweise