ToDegree: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 21: Zeile 21:
  toDegrees([var=a])
  toDegrees([var=a])


====JUnit Tests====
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed">
@Test public void testToDegrees(){
  assertTrue(540 == getEvaluator().getNumberResult("toDegrees("+3*PI+")"));
  assertTrue(360 == getEvaluator().getNumberResult("toDegrees("+2*PI+")"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees("+PI+")"));
  assertTrue(-180 == getEvaluator().getNumberResult("toDegrees("+-PI+")"));
  assertTrue(90 == getEvaluator().getNumberResult("toDegrees("+PI/2+")"));
  assertTrue(45 == getEvaluator().getNumberResult("toDegrees("+PI/4+")"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees(1)"));
}
@Test public void testToDegreesWithInput(){
  assertTrue(90 == getEvaluator().getNumberResult("toDegrees('[pos=90]')"));
  assertTrue(45 == getEvaluator().getNumberResult("toDegrees('[pos=45]')"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees('[pos=1]')"));
}
@Test public void testToDegreesWithVariables(){
  assertTrue(360 == getEvaluator().getNumberResult("toDegrees('[var=degd]')"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees('[var=degc]')"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees('[var=b]')"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees('[var=PI]')"));
}
@Test
public void testToDegreesWithPointNumbers(){
  assertTrue(180/(PI*.2) == getEvaluator().getNumberResult("toDegrees(.2)"));
  assertTrue(180/(-PI*.1) == getEvaluator().getNumberResult("toDegrees(-.1)"));
}
@Test
public void testToDegreesWithExpressions(){
  assertTrue(0 == getEvaluator().getNumberResult("toDegrees(toDegrees(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("toDegrees(toDegrees(toDegrees(0)))"));
}
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
public void testToDegreesWithWrongInputCharacter(){
  getEvaluator().getNumberResult("toDegrees(a)");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToDegreesWithTwoArguments(){
  getEvaluator().getNumberResult("toDegrees(4, 3)");
}
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToDegreesWithThreeArguments(){
  getEvaluator().getNumberResult("toDegrees(2, 3, 4)");
}
@Test(expected=UndefinedExerciseVariableException.class)
public void testToDegreesWithMissingExerciseVariable(){
  getEvaluator().getNumberResult("toDegrees('[var=j]')");
}
@Test(expected=UndefinedFillInVariableException.class)
public void testToDegreesWithMissingInput(){
  getEvaluator().getNumberResult("toDegrees('[pos=42]')");
}
</syntaxhighlight>
=== Hinweise ===
=== Hinweise ===


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

Version vom 20. Juni 2017, 10:31 Uhr

Beschreibung

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

Syntax

toDegrees(float radiant)

Parameter

  • radiant - der umzuwandelnde Radiant-Wert

Return Value

  • Gibt den Radiant-Wert in Grad zurück

Beispiele

Standardfälle

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

Benutzung mit Variablen

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

JUnit Tests

@Test public void testToDegrees(){
  assertTrue(540 == getEvaluator().getNumberResult("toDegrees("+3*PI+")"));
  assertTrue(360 == getEvaluator().getNumberResult("toDegrees("+2*PI+")"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees("+PI+")"));
  assertTrue(-180 == getEvaluator().getNumberResult("toDegrees("+-PI+")"));
  assertTrue(90 == getEvaluator().getNumberResult("toDegrees("+PI/2+")"));
  assertTrue(45 == getEvaluator().getNumberResult("toDegrees("+PI/4+")"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees(1)"));
}
	
@Test public void testToDegreesWithInput(){
  assertTrue(90 == getEvaluator().getNumberResult("toDegrees('[pos=90]')"));
  assertTrue(45 == getEvaluator().getNumberResult("toDegrees('[pos=45]')"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees('[pos=1]')"));
}
	
@Test public void testToDegreesWithVariables(){
  assertTrue(360 == getEvaluator().getNumberResult("toDegrees('[var=degd]')"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees('[var=degc]')"));
  assertTrue(180/PI == getEvaluator().getNumberResult("toDegrees('[var=b]')"));
  assertTrue(180 == getEvaluator().getNumberResult("toDegrees('[var=PI]')"));
}
	
@Test
public void testToDegreesWithPointNumbers(){
  assertTrue(180/(PI*.2) == getEvaluator().getNumberResult("toDegrees(.2)"));	
  assertTrue(180/(-PI*.1) == getEvaluator().getNumberResult("toDegrees(-.1)"));	
}
	
@Test
public void testToDegreesWithExpressions(){
  assertTrue(0 == getEvaluator().getNumberResult("toDegrees(toDegrees(0))"));
  assertTrue(0 == getEvaluator().getNumberResult("toDegrees(toDegrees(toDegrees(0)))"));
}
	
@Test(expected=InvalidEvaluatorFunctionArgumentException.class)
public void testToDegreesWithWrongInputCharacter(){
  getEvaluator().getNumberResult("toDegrees(a)");
}
	
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToDegreesWithTwoArguments(){
  getEvaluator().getNumberResult("toDegrees(4, 3)");
}
	
@Test(expected=UnsupportedEvaluatorFunctionException.class)
public void testToDegreesWithThreeArguments(){
  getEvaluator().getNumberResult("toDegrees(2, 3, 4)");
}
	
@Test(expected=UndefinedExerciseVariableException.class)
public void testToDegreesWithMissingExerciseVariable(){
  getEvaluator().getNumberResult("toDegrees('[var=j]')");
}
	
@Test(expected=UndefinedFillInVariableException.class)
public void testToDegreesWithMissingInput(){
  getEvaluator().getNumberResult("toDegrees('[pos=42]')");
}

Hinweise