EqualsSemiSem: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 21: Zeile 21:
  equalssemisem('4.1','[var=a]')
  equalssemisem('4.1','[var=a]')
  equalssemisem('[var=a]','[pos=2]')
  equalssemisem('[var=a]','[pos=2]')
====JUnit Tests====
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed">
@Before
public void beforeTest() {
  placeFillInVariable(1, OMParser.parse("2.7"));
  placeFillInVariable(2, OMParser.parse("3.5"));
  placeExerciseVariable("a", OMParser.parse("2.7"));
  placeExerciseVariable("b", OMParser.parse("3.5"));
}
@Test
public void testEqualsSemiSem() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('7.3','7.3')"));
  assertFalse(getEvaluator().getBooleanResult("equalssemisem('3','3.5')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.0','3')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('.5','0.5')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('5.','5')"));
}
@Test
public void testEqualsSemiSemWithInput() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('[pos=1]','2.7')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.5','[pos=2]')"));
}
@Test
public void testEqualsSemiSemWithVariables() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('[var=a]','2.7')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.5','[var=b]')"));
}
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputWrongArguments() {
  getEvaluator().getBooleanResult("equalssemisem('5/2','2.5')");
}
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputEmptyArguments() {
  getEvaluator().getBooleanResult("equalssemisem('','0.5')");
}
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputCharacter() {
  getEvaluator().getBooleanResult("equalssemisem('a','a')");
}
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithOneRationalAndOneTextArgument() {
  getEvaluator().getBooleanResult("equalssemisem(1,'1')");
}
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithTwoRationalArguments() {
  getEvaluator().getBooleanResult("equalssemisem(1, 1)");
}
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithOneArgument() {
  getEvaluator().getBooleanResult("equalssemisem('1')");
}
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithThreeArguments() {
  getEvaluator().getBooleanResult("equalssemisem('1', '1', '1')");
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testEqualsSemiSemWithMissingExerciseVariable() {
  getEvaluator().getBooleanResult("equalssemisem('[var=j]','2.5')");
}
@Test (expected=UndefinedFillInVariableException.class)
public void testEqualsSemiSemWithMissingInput() {
  getEvaluator().getBooleanResult("equalssemisem('[pos=42]','1.22')");
}
</syntaxhighlight>


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

Version vom 20. Juni 2017, 16:07 Uhr

Beschreibung

Die Funktion equalssemisem vergleicht zwei rationale Zahlen miteinander auf ihre Gleichheit. Die Funktion erwartet zwei Zahlen und gibt einen Boolean zurück.

Syntax

equalsemisem(String zahl1, String zahl2)

Parameter

  • zahl1 - erste zu vergleichende rationale Zahl
  • zahl2 - zweite zu vergleichende rationale Zahl

Return Value

  • Gibt einen Boolean zurück

Beispiele

Standardfälle

equalssemisem('7.3','7.3')   --> returns true
equalssemisem('7.3','6.2')   --> returns false

Benutzung von Variablen

equalssemisem('[pos=1]','2.4')
equalssemisem('4.1','[var=a]')
equalssemisem('[var=a]','[pos=2]')

JUnit Tests

@Before 
public void beforeTest() {
  placeFillInVariable(1, OMParser.parse("2.7"));
  placeFillInVariable(2, OMParser.parse("3.5"));
		
  placeExerciseVariable("a", OMParser.parse("2.7"));
  placeExerciseVariable("b", OMParser.parse("3.5"));
}
	
@Test 
public void testEqualsSemiSem() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('7.3','7.3')"));
  assertFalse(getEvaluator().getBooleanResult("equalssemisem('3','3.5')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.0','3')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('.5','0.5')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('5.','5')"));
}
	
@Test 
public void testEqualsSemiSemWithInput() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('[pos=1]','2.7')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.5','[pos=2]')"));
}
	
@Test 
public void testEqualsSemiSemWithVariables() {
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('[var=a]','2.7')"));
  assertTrue(getEvaluator().getBooleanResult("equalssemisem('3.5','[var=b]')"));
}
	
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputWrongArguments() {
  getEvaluator().getBooleanResult("equalssemisem('5/2','2.5')");
}
		
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputEmptyArguments() {
  getEvaluator().getBooleanResult("equalssemisem('','0.5')");
}
	
@Test (expected=InvalidEvaluatorFunctionArgumentException.class)
public void testEqualsSemiSemWithWrongInputCharacter() {
  getEvaluator().getBooleanResult("equalssemisem('a','a')");
}
	
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithOneRationalAndOneTextArgument() {
  getEvaluator().getBooleanResult("equalssemisem(1,'1')");
}
	
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithTwoRationalArguments() {
  getEvaluator().getBooleanResult("equalssemisem(1, 1)");
}
	
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithOneArgument() {
  getEvaluator().getBooleanResult("equalssemisem('1')");
}
	
@Test (expected=UnsupportedEvaluatorFunctionException.class)
public void testEqualsSemiSemWithThreeArguments() {
  getEvaluator().getBooleanResult("equalssemisem('1', '1', '1')");
}
	
@Test (expected=UndefinedExerciseVariableException.class)
public void testEqualsSemiSemWithMissingExerciseVariable() {
  getEvaluator().getBooleanResult("equalssemisem('[var=j]','2.5')");
}
	
@Test (expected=UndefinedFillInVariableException.class)
public void testEqualsSemiSemWithMissingInput() {
  getEvaluator().getBooleanResult("equalssemisem('[pos=42]','1.22')");
}

Hinweise

  • Es muss ein Dezimalpunkt statt eines Kommas verwendet werden.