Atan: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Zeile 12: Zeile 12:


===Beispiele===
===Beispiele===
  atan('0')    --> returns 0
  atan(0)    --> returns 0


====JUnit Tests====
====JUnit Tests====

Version vom 4. Oktober 2017, 12:50 Uhr

Beschreibung

Der Arkustangens wird durch die Funktion atan' beschrieben. Er erwartet einen Parameter und gibt einen Wert zurück.

Syntax

atan(Gleitkommazahl 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