GreaterThanOrEqual: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Zeile 23: Zeile 23:
<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
@BeforeClass
public void beforeTest() {
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
  placeFillInVariable(1, OMParser.parse("3"));
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
  placeFillInVariable(2, OMParser.parse("1"));
greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
  placeExerciseVariable("a", OMParser.parse("8"));
 
  placeExerciseVariable("b", OMParser.parse("25"));
greaterThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
greaterThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}
 
@Test
public void testGreaterThan1() {
assertTrue(Evaluator.getBooleanResult("22>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThan2() {
assertTrue(!Evaluator.getBooleanResult("2>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThan3() {
assertTrue(Evaluator.getBooleanResult("5.7>3.5", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThan4() {
assertTrue(Evaluator.getBooleanResult("1>-1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThan5() {
assertTrue(Evaluator.getBooleanResult("0.2>0", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables1() {
assertTrue(Evaluator.getBooleanResult("[var=b]>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables2() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>9", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables3() {
assertTrue(Evaluator.getBooleanResult("[var=b]>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables4() {
assertTrue(!Evaluator.getBooleanResult("[var=a]>[var=b]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables5() {
assertTrue(Evaluator.getBooleanResult("22>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithVariables6() {
assertTrue(!Evaluator.getBooleanResult("2>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithInput1() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithInput2() {
assertTrue(Evaluator.getBooleanResult("34>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithInput3() {
assertTrue(!Evaluator.getBooleanResult("[pos=2]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
 
@Test
public void testGreaterThanWithInput4() {
assertTrue(Evaluator.getBooleanResult("[pos=1]>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
}


@Test
@Test
public void testGreaterThanOrEqual(){
public void testGreaterThanWithInput5() {
  assertTrue(getEvaluator().getBooleanResult("22>=8"));
assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("8>=8"));
  assertTrue(!getEvaluator().getBooleanResult("2>=8"));
  assertTrue(getEvaluator().getBooleanResult("9>=8"));
  assertTrue(!getEvaluator().getBooleanResult("7>=45"));
  assertTrue(getEvaluator().getBooleanResult("7>=7"));
  assertTrue(getEvaluator().getBooleanResult("0>=-0.2"));
  assertTrue(getEvaluator().getBooleanResult("0>=0"));
}
}
 
@Test
@Test
public void testGreaterThanOrEqualWithVariables(){
public void testGreaterThanWithInput6() {
  assertTrue(getEvaluator().getBooleanResult("22>=[var=a]"));
assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("2>=[var=a]"));
  assertTrue(getEvaluator().getBooleanResult("[var=b]>=8"));
  assertTrue(getEvaluator().getBooleanResult("[var=a]>=8"));
  assertTrue(!getEvaluator().getBooleanResult("23>=[var=b]"));
  assertTrue(getEvaluator().getBooleanResult("[var=a]>=[var=a]"));
  assertTrue(getEvaluator().getBooleanResult("[var=b]>=[var=a]"));
  assertTrue(!getEvaluator().getBooleanResult("[var=a]>=[var=b]"));
}
}
 
@Test
@Test
public void testGreaterThanOrEqualWithInput(){
public void testGreaterThanWithInput7() {
  assertTrue(getEvaluator().getBooleanResult("22>=[pos=1]"));
assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("3>=[pos=1]"));
}
  assertTrue(!getEvaluator().getBooleanResult("2>=[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("5>=[pos=2]"));
@Test
  assertTrue(!getEvaluator().getBooleanResult("[pos=2]>=5"));
public void testGreaterThanWithEncapsulation1() {
  assertTrue(!getEvaluator().getBooleanResult("[pos=2]>=[pos=1]"));
assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
}


@Test
@Test
public void testGreaterThanOrEqualWithEncapsulation(){
public void testGreaterThanWithEncapsulation2() {
  assertTrue(getEvaluator().getBooleanResult("1 >= (1 >= 2)"));
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
  assertTrue(!getEvaluator().getBooleanResult("0 >= (0 >= (0 >= 1))"));
  assertTrue(!getEvaluator().getBooleanResult("0 >= (0 >= (0 >= (0 >= (0 >= 1))))"));
  assertTrue(getEvaluator().getBooleanResult("((((1 >= 1) >= 1) >= 1) >= 1) >= 1"));
}
}
 
@Test(expected=ParserMismatchException.class)
@Test
public void testGreaterThanOrEqualWithWrongInputCharacter() {
public void testGreaterThanWithEncapsulation3() {
  getEvaluator().getBooleanResult("6 >= a");
assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
}
 
@Test(expected=UnsupportedBinaryOperatorException.class)
@Test  
public void testGreaterThanOrEqualWithWrongInputString() {
public void testGreaterThanWithEncapsulation4() {
  getEvaluator().getBooleanResult("6 >= 'a'");
assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}
}
 
@Test(expected=ParserException.class)
public void testGreaterThanWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
 
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testGreaterThanWithWrongInputString() {
Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
 
@Test (expected=UndefinedExerciseVariableException.class)
@Test (expected=UndefinedExerciseVariableException.class)
public void testGreaterThanOrEqualWithMissingExcerciseVariable() {
public void testGreaterThanWithMissingExcerciseVariable() {
  getEvaluator().getBooleanResult("[var=j] >= 2");
Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
}
 
@Test (expected=UndefinedFillInVariableException.class)
@Test (expected=UndefinedFillInVariableException.class)
public void testGreaterThanOrEqualWithMissingInput() {
public void testGreaterThanWithMissingInput() {
  getEvaluator().getBooleanResult("[pos=42] >= 2");
Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
fail();
}
}
</syntaxhighlight>
</syntaxhighlight>
===Hinweise===
===Hinweise===


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

Version vom 18. September 2017, 11:58 Uhr

Beschreibung

Die Funktion greaterThanOrEqual vergleicht zwei Ausdrücke der Größe nach miteinander und gibt einen Wahrheitswert zurück, abhängig davon, ob der linksstehende Ausdruck größer-gleich dem rechtsstehenden Ausdruck ist.

Syntax

a >= b

Parameter

  • a - double
  • b - double

Return Value

  • Gibt einen Boolean zurück.
    Wenn der linke Ausdruck größer-gleich dem rechten Ausdruck ist, wird true zurückgegeben, andernfalls false.

Beispiele

<math>6 >= 3</math>    --> returns true
<math>3 >= 3</math>    --> returns true
<math>-1 >= 2</math>    --> returns false

JUnit Tests

[Anzeigen]

@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
		UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
	greaterThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
	greaterThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));

	greaterThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
	greaterThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}

@Test
public void testGreaterThan1() {
	assertTrue(Evaluator.getBooleanResult("22>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThan2() {
	assertTrue(!Evaluator.getBooleanResult("2>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThan3() {
	assertTrue(Evaluator.getBooleanResult("5.7>3.5", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThan4() {
	assertTrue(Evaluator.getBooleanResult("1>-1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThan5() {
	assertTrue(Evaluator.getBooleanResult("0.2>0", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables1() {
	assertTrue(Evaluator.getBooleanResult("[var=b]>8", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables2() {
	assertTrue(!Evaluator.getBooleanResult("[var=a]>9", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables3() {
	assertTrue(Evaluator.getBooleanResult("[var=b]>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables4() {
	assertTrue(!Evaluator.getBooleanResult("[var=a]>[var=b]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables5() {
	assertTrue(Evaluator.getBooleanResult("22>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithVariables6() {
	assertTrue(!Evaluator.getBooleanResult("2>[var=a]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput1() {
	assertTrue(Evaluator.getBooleanResult("[pos=1]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput2() {
	assertTrue(Evaluator.getBooleanResult("34>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput3() {
	assertTrue(!Evaluator.getBooleanResult("[pos=2]>2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput4() {
	assertTrue(Evaluator.getBooleanResult("[pos=1]>[pos=2]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput5() {
	assertTrue(!Evaluator.getBooleanResult("[pos=2]>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput6() {
	assertTrue(Evaluator.getBooleanResult("22>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithInput7() {
	assertTrue(!Evaluator.getBooleanResult("2>[pos=1]", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test 
public void testGreaterThanWithEncapsulation1() {
	assertTrue(Evaluator.getBooleanResult("1 > (1 > 2)", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithEncapsulation2() {
	assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > 2))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test
public void testGreaterThanWithEncapsulation3() {
	assertTrue(!Evaluator.getBooleanResult("1 > (1 > (1 > (1 > (1 > 2))))", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test 
public void testGreaterThanWithEncapsulation4() {
	assertTrue(Evaluator.getBooleanResult("((((1 > 1) > 1) > 1) > 1) > -1", greaterThanExerciseVariableMap, greaterThanFillInVariableMap));
}

@Test(expected=ParserException.class)
public void testGreaterThanWithWrongInputCharacter() {
	Evaluator.getBooleanResult("6 > ab", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
	fail();
}

@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testGreaterThanWithWrongInputString() {
	Evaluator.getBooleanResult("6 > 'a'", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
	fail();
}

@Test (expected=UndefinedExerciseVariableException.class)
public void testGreaterThanWithMissingExcerciseVariable() {
	Evaluator.getBooleanResult("[var=j] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
	fail();
}

@Test (expected=UndefinedFillInVariableException.class)
public void testGreaterThanWithMissingInput() {
	Evaluator.getBooleanResult("[pos=42] > 2", greaterThanExerciseVariableMap, greaterThanFillInVariableMap);
	fail();
}

Hinweise