Atan: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Zeile 14: Zeile 14:
  atan('0')    --> returns 0
  atan('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"));
  placeExerciseVariable("a", OMParser.parse("0"));
  placeExerciseVariable("b", OMParser.parse("1"));
}
@Test
public void testAtan() {
  assertTrue(0 == getEvaluator().getNumberResult("atan('0')"));
  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
public void testAtanWithInput() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([pos=1])"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([pos=2])"));
}
@Test
public void testAtanWithVariables() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([var=a])"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([var=b])"));
}
@Test
public void testAtanWithExpression() {
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(atan(0)))"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithONECharacter() {
  getEvaluator().getNumberResult("atan(a)");
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithEmptyStringArgument() {
  getEvaluator().getNumberResult(("atan('')"));
}
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithEmptyArgument() {
  getEvaluator().getNumberResult(("atan()"));
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testAtanWithoutExerciseVariable() {
  getEvaluator().getNumberResult("atan([var=j])");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testAtanWithoutInput() {
  getEvaluator().getNumberResult("atan([pos=42])");
}
</syntaxhighlight>
===Hinweise===
===Hinweise===


[[Kategorie:Evaluatorfunktion]]
[[Kategorie:Evaluatorfunktion]]

Version vom 21. Juni 2017, 09:56 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

@Before 
public void beforeTest() {
  placeFillInVariable(1, OMParser.parse("0"));
  placeFillInVariable(2, OMParser.parse("1"));
		
  placeExerciseVariable("a", OMParser.parse("0"));
  placeExerciseVariable("b", OMParser.parse("1"));
}
	
@Test
public void testAtan() {
  assertTrue(0 == getEvaluator().getNumberResult("atan('0')"));
  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
public void testAtanWithInput() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([pos=1])"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([pos=2])"));
}

@Test
public void testAtanWithVariables() {
  assertTrue(0 == getEvaluator().getNumberResult("atan([var=a])"));
  assertTrue(PI/4 == getEvaluator().getNumberResult("atan([var=b])"));
}
	
@Test
public void testAtanWithExpression() {
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("atan(atan(atan(0)))"));
}

@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithONECharacter() {
  getEvaluator().getNumberResult("atan(a)");
}
	
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithEmptyStringArgument() {
  getEvaluator().getNumberResult(("atan('')"));
}
	
@Test(expected=InvalidCASFunctionArgumentException.class)
public void testAtanWithEmptyArgument() {
  getEvaluator().getNumberResult(("atan()"));
}
	
@Test(expected=UndefinedExerciseVariableException.class)
public void testAtanWithoutExerciseVariable() {
  getEvaluator().getNumberResult("atan([var=j])");
}
	
@Test(expected=UndefinedFillInVariableException.class)
public void testAtanWithoutInput() {
  getEvaluator().getNumberResult("atan([pos=42])");
}

Hinweise