Asin

Aus JACK Wiki
Zur Navigation springen Zur Suche springen

Beschreibung

Der Arkussinus wird durch asin beschrieben. Er erwartet einen Parameter und gibt einen Wert an der Stelle zurück.

Syntax

asin(String zahl)

Parameter

  • zahl - ein Wert zwischen '-1' und '1'

Return Value

  • Gibt den Wert des Arkussinus an der Stelle zurück.

Beispiele

asin('0')    --> returns 0

JUnit Tests

[Anzeigen]

private double PI = Math.PI;

@Test
public void testAsin1() {
	assertEquals(0, Evaluator.getNumberResult("asin(0)", exerciseVariableMap, fillInVariableMap), 0.0);
}

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

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

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

@Test
public void testAsin5() {
	assertEquals(0.775397496610753, Evaluator.getNumberResult("asin(0.7)", exerciseVariableMap, fillInVariableMap),
			0.0);
}

@Test
public void testAsinWithInput1() {
	assertEquals(0, Evaluator.getNumberResult("asin([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0);
}

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

@Test
public void testAsinWithInput3() {
	assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([pos=3])", exerciseVariableMap, fillInVariableMap),
			0.0);
}

@Test
public void testAsinWithVariables1() {
	assertEquals(0, Evaluator.getNumberResult("asin([var=a])", exerciseVariableMap, fillInVariableMap), 0.0);
}

@Test
public void testAsinWithVariables2() {
	assertEquals(PI / 2, Evaluator.getNumberResult("asin([var=b])", exerciseVariableMap, fillInVariableMap),
			0.0001);
}

@Test
public void testAsinWithVariables3() {
	assertNotEquals(PI / 2, Evaluator.getNumberResult("asin([var=c])", exerciseVariableMap, fillInVariableMap),
			0.0);
}

@Test
public void testAsinWithExpressions1() {
	assertEquals(0, Evaluator.getNumberResult("asin(asin(asin(0)))", exerciseVariableMap, fillInVariableMap),
			0.0);

}

@Test
public void testAsinWithExpressions2() {
	assertEquals(0.202744039431659,
			Evaluator.getNumberResult("asin(asin(0.2))", exerciseVariableMap, fillInVariableMap), 0.0);
}

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

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

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

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

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

Hinweise