ToRadian: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 20: Zeile 20:
  toRadians([pos=1])
  toRadians([pos=1])
  toRadians([var=a])
  toRadians([var=a])
====JUnit Tests====
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed">
@Test public void testToRadians(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians(180)"));
  assertTrue(2*PI == getEvaluator().getNumberResult("toRadians(360)"));
  assertTrue(3*PI == getEvaluator().getNumberResult("toRadians(540)"));
  assertTrue(PI/2 == getEvaluator().getNumberResult("toRadians(90)"));
  assertTrue(-PI == getEvaluator().getNumberResult("toRadians(-180)"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(0)"));
}
@Test public void testToRadiansWithInput(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians('[pos=1]')"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians('[pos=2]')"));
}
@Test public void testToRadiansWithVariables(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians('[var=a]')"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians('[var=b]')"));
}
@Test
public void testToRadiansWithPointNumbers(){
  assertTrue((PI*.2)/180 == getEvaluator().getNumberResult("toRadians(.2)"));
  assertTrue((-PI*.1)/180 == getEvaluator().getNumberResult("toRadians(-.1)"));
}
@Test
public void testToRadiansWithExpressions(){
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(toRadians(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(toRadians(toRadians(0)))"));
}
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
public void testToRadiansWithWrongInputCharacter(){
  getEvaluator().getNumberResult("toRadians(a)");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToRadiansWithTwoArguments(){
  getEvaluator().getNumberResult("toRadians(180, 90)");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToRadiansWithThreeArguments(){
  getEvaluator().getNumberResult("toRadians(45, 90, 180)");
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testToRadiansWithMissingExerciseVariable(){
  getEvaluator().getNumberResult("toRadians('[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testToRadiansWithMissingInput(){
  getEvaluator().getNumberResult("toRadians('[pos=42]')");
}
</syntaxhighlight>


=== Hinweise ===
=== Hinweise ===


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

Version vom 20. Juni 2017, 10:34 Uhr

Beschreibung

Die Funktion toRadians wandelt Grad-Werte in Radiant um. Die Funktion erwartet einen Grad-Wert und gibt den entsprechenden Radiant zurück.

Syntax

toRadians(float grad)

Parameter

  • grad - der umzuwandelnde Grad-Wert

Return Value

  • Gibt den Grad-Wert als Radiant zurück

Beispiele

Standardfälle

toRadians(180)   --> returns 3.14159
toRadians(360)   --> returns 6.28319

Benutzung mit Variablen

toRadians([pos=1])
toRadians([var=a])

JUnit Tests

@Test public void testToRadians(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians(180)"));
  assertTrue(2*PI == getEvaluator().getNumberResult("toRadians(360)"));
  assertTrue(3*PI == getEvaluator().getNumberResult("toRadians(540)"));
  assertTrue(PI/2 == getEvaluator().getNumberResult("toRadians(90)"));
  assertTrue(-PI == getEvaluator().getNumberResult("toRadians(-180)"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(0)"));
}
	
@Test public void testToRadiansWithInput(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians('[pos=1]')"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians('[pos=2]')"));
}
	
@Test public void testToRadiansWithVariables(){
  assertTrue(PI == getEvaluator().getNumberResult("toRadians('[var=a]')"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians('[var=b]')"));
}
	
@Test
public void testToRadiansWithPointNumbers(){
  assertTrue((PI*.2)/180 == getEvaluator().getNumberResult("toRadians(.2)"));	
  assertTrue((-PI*.1)/180 == getEvaluator().getNumberResult("toRadians(-.1)"));	
}
	
@Test
public void testToRadiansWithExpressions(){
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(toRadians(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("toRadians(toRadians(toRadians(0)))"));
}
	
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
public void testToRadiansWithWrongInputCharacter(){
  getEvaluator().getNumberResult("toRadians(a)");
}
	
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToRadiansWithTwoArguments(){
  getEvaluator().getNumberResult("toRadians(180, 90)");
}
	
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToRadiansWithThreeArguments(){
  getEvaluator().getNumberResult("toRadians(45, 90, 180)");
}
	
@Test(expected=UndefinedExerciseVariableException.class)
public void testToRadiansWithMissingExerciseVariable(){
  getEvaluator().getNumberResult("toRadians('[var=j]')");
}
	
@Test(expected=UndefinedFillInVariableException.class)
public void testToRadiansWithMissingInput(){
  getEvaluator().getNumberResult("toRadians('[pos=42]')");
}

Hinweise