Asin: 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 testAsin1() {
  placeFillInVariable(3, OMParser.parse("-1"));
assertEquals(0, Evaluator.getNumberResult("asin(0)", exerciseVariableMap, fillInVariableMap), 0.0);
  placeExerciseVariable("a", OMParser.parse("0"));
  placeExerciseVariable("b", OMParser.parse("1"));
  placeExerciseVariable("c", OMParser.parse("-1"));
}
}
 
@Test
@Test
public void testAsin() {
public void testAsin2() {
  assertTrue(0 == getEvaluator().getNumberResult("asin(0)"));
assertEquals(-PI / 2, Evaluator.getNumberResult("asin(-1)", exerciseVariableMap, fillInVariableMap), 0.0001);
  assertTrue(-PI/2 == getEvaluator().getNumberResult("asin(-1)"));
  assertTrue(PI/2 == getEvaluator().getNumberResult("asin(1)"));
  assertTrue(0 == getEvaluator().getNumberResult("asin('0')"));
  assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(0.7)"));
  assertTrue(0.775397496610753 == getEvaluator().getNumberResult("asin(.7)"));
}
}


@Test
@Test
public void testAsinWithInput() {
public void testAsin3() {
  assertTrue(0 == getEvaluator().getNumberResult("asin([pos=1])"));
assertEquals(PI / 2, Evaluator.getNumberResult("asin(1)", exerciseVariableMap, fillInVariableMap), 0.0001);
  assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([pos=2])"));
  assertFalse(PI/2 == getEvaluator().getNumberResult("asin([pos=3])"));
}
}


@Test
@Test
public void testAsinWithVariables() {
public void testAsin4() {
  assertTrue(0 == getEvaluator().getNumberResult("asin([var=a])"));
assertEquals(0, Evaluator.getNumberResult("asin('0')", exerciseVariableMap, fillInVariableMap), 0.0);
  assertTrue(-PI/2 == getEvaluator().getNumberResult("asin([var=b])"));
  assertFalse(PI/2 == getEvaluator().getNumberResult("asin([var=c])"));
}
}
 
@Test
@Test
public void testAsinWithExpressions() {
public void testAsin5() {
  assertTrue(0 == getEvaluator().getNumberResult("asin(asin(asin(0)))"));
assertEquals(0.775397496610753, Evaluator.getNumberResult("asin(0.7)", exerciseVariableMap, fillInVariableMap),
  assertTrue(0.2027440393165833 == getEvaluator().getNumberResult("asin(asin(0.2))"));
0.0);
}
}


@Test(expected=InvalidCASFunctionArgumentException.class)
@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() {
public void testAsinWithONECharacter() {
  getEvaluator().getNumberResult("asin(a)");
Evaluator.getNumberResult("asin(a)", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testAsinWithEmptyStringArgument() {
public void testAsinWithEmptyStringArgument() {
  getEvaluator().getNumberResult("asin('')");
Evaluator.getNumberResult("asin('')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=InvalidCASFunctionArgumentException.class)
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testAsinWithEmptyArgument() {
public void testAsinWithEmptyArgument() {
  getEvaluator().getNumberResult("asin()");
Evaluator.getNumberResult("asin()", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedExerciseVariableException.class)
@Test(expected = UndefinedExerciseVariableException.class)
public void testAsinWithoutExerciseVariable() {
public void testAsinWithoutExerciseVariable() {
  getEvaluator().getNumberResult("asin('[var=j]')");
Evaluator.getNumberResult("asin('[var=j]')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
 
@Test(expected=UndefinedFillInVariableException.class)
@Test(expected = UndefinedFillInVariableException.class)
public void testAsinWithoutInput() {
public void testAsinWithoutInput() {
  getEvaluator().getNumberResult("asin('[pos=42]')");
Evaluator.getNumberResult("asin('[pos=42]')", exerciseVariableMap, fillInVariableMap);
fail();
}
}
</syntaxhighlight>
</syntaxhighlight>

Version vom 18. September 2017, 10:23 Uhr

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