LessThanOrEqual: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
(JUnit Tests)
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"));
+
lessThanOrEqualFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
  placeFillInVariable(3, OMParser.parse("2.5"));
+
lessThanOrEqualFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
+
lessThanOrEqualFillInVariableMap.put(3, ExpressionParser.parse("2.5", null, null));
  placeExerciseVariable("a", OMParser.parse("8"));
+
 
  placeExerciseVariable("b", OMParser.parse("25"));
+
lessThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
  placeExerciseVariable("c", OMParser.parse("2.5"));
+
lessThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
 +
lessThanOrEqualExerciseVariableMap.put("c", ExpressionParser.parse("2.5", null, null));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual1() {
 +
assertTrue(!Evaluator.getBooleanResult("22<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual2() {
 +
assertTrue(Evaluator.getBooleanResult("8<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual3() {
 +
assertTrue(Evaluator.getBooleanResult("2<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual4() {
 +
assertTrue(Evaluator.getBooleanResult("8<=9", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual5() {
 +
assertTrue(!Evaluator.getBooleanResult("45<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual6() {
 +
assertTrue(Evaluator.getBooleanResult("7<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual7() {
 +
assertTrue(Evaluator.getBooleanResult("-0.2<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqual8() {
 +
assertTrue(Evaluator.getBooleanResult("0<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables1() {
 +
assertTrue(!Evaluator.getBooleanResult("22<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables2() {
 +
assertTrue(Evaluator.getBooleanResult("3<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables3() {
 +
assertTrue(Evaluator.getBooleanResult("2<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables4() {
 +
assertTrue(Evaluator.getBooleanResult("8<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 
}
 
}
 
 
 
@Test
 
@Test
public void testLessThanOrEqual(){
+
public void testLessThanOrEqualWithVariables5() {
  assertTrue(!getEvaluator().getBooleanResult("22<=8"));
+
assertTrue(Evaluator.getBooleanResult("8<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("8<=8"));
 
  assertTrue(getEvaluator().getBooleanResult("2<=8"));
 
  assertTrue(getEvaluator().getBooleanResult("8<=9"));
 
  assertTrue(!getEvaluator().getBooleanResult("45<=7"));
 
  assertTrue(getEvaluator().getBooleanResult("7<=7"));
 
  assertTrue(getEvaluator().getBooleanResult("-0.2<=0"));
 
  assertTrue(getEvaluator().getBooleanResult("0<=0"));
 
 
}
 
}
+
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables6() {
 +
assertTrue(!Evaluator.getBooleanResult("[var=b]<=23", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables7() {
 +
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables8() {
 +
assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithVariables9() {
 +
assertTrue(!Evaluator.getBooleanResult("[var=b]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput1() {
 +
assertTrue(!Evaluator.getBooleanResult("22<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput2() {
 +
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput3() {
 +
assertTrue(Evaluator.getBooleanResult("2<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput4() {
 +
assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput5() {
 +
assertTrue(Evaluator.getBooleanResult("[pos=2]<=5", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput6() {
 +
assertTrue(!Evaluator.getBooleanResult("5<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithInput7() {
 +
assertTrue(!Evaluator.getBooleanResult("[pos=1]<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 +
@Test
 +
public void testLessThanOrEqualWithEncapsulation1() {
 +
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= 2)", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
 +
}
 +
 
 
@Test
 
@Test
public void testLessThanOrEqualWithVariables(){
+
public void testLessThanOrEqualWithEncapsulation2() {
  assertTrue(!getEvaluator().getBooleanResult("22<=[var=a]"));
+
assertTrue(Evaluator.getBooleanResult("1 <= (1 <= (0 <= 1))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("3<=[var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("2<=[var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("8<=[var=b]"));
 
  assertTrue(getEvaluator().getBooleanResult("8<=[var=a]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[var=b]<=23"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=a]<=[var=a]"));
 
  assertTrue(getEvaluator().getBooleanResult("[var=a]<=[var=b]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[var=b]<=[var=a]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThanOrEqualWithInput(){
+
public void testLessThanOrEqualWithEncapsulation3() {
  assertTrue(!getEvaluator().getBooleanResult("22<=[pos=1]"));
+
assertTrue(Evaluator.getBooleanResult("0 <= (0 <= (0 <= (0 <= (0 <= 1))))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("3<=[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("2<=[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("3<=[pos=1]"));
 
  assertTrue(getEvaluator().getBooleanResult("[pos=2]<=5"));
 
  assertTrue(!getEvaluator().getBooleanResult("5<=[pos=2]"));
 
  assertTrue(!getEvaluator().getBooleanResult("[pos=1]<=[pos=2]"));
 
 
}
 
}
+
 
 
@Test
 
@Test
public void testLessThanOrEqualWithEncapsulation(){
+
public void testLessThanOrEqualWithEncapsulation4() {
  assertTrue(getEvaluator().getBooleanResult("1 <= (1 <= 2)"));
+
assertTrue(Evaluator.getBooleanResult("((((1 <= 1) <= 1) <= 1) <= 1) <= 1", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
  assertTrue(getEvaluator().getBooleanResult("1 <= (1 <= (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(expected=ParserException.class)
 
public void testLessThanOrEqualWithWrongInputCharacter() {
 
public void testLessThanOrEqualWithWrongInputCharacter() {
  getEvaluator().getBooleanResult("6 <= a");
+
Evaluator.getBooleanResult("6 <= ab", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
 +
fail();
 
}
 
}
+
 
@Test(expected=UnsupportedBinaryOperatorException.class)
+
@Test(expected=FunctionInvalidArgumentTypeException.class)
 
public void testLessThanOrEqualWithWrongInputString() {
 
public void testLessThanOrEqualWithWrongInputString() {
  getEvaluator().getBooleanResult("6 <= 'a'");
+
Evaluator.getBooleanResult("6 <= 'a'", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedExerciseVariableException.class)
 
@Test (expected=UndefinedExerciseVariableException.class)
 
public void testLessThanOrEqualWithMissingExcerciseVariable() {
 
public void testLessThanOrEqualWithMissingExcerciseVariable() {
  getEvaluator().getBooleanResult("[var=j] <= 2");
+
Evaluator.getBooleanResult("[var=j] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
 +
fail();
 
}
 
}
+
 
 
@Test (expected=UndefinedFillInVariableException.class)
 
@Test (expected=UndefinedFillInVariableException.class)
 
public void testLessThanOrEqualWithMissingInput() {
 
public void testLessThanOrEqualWithMissingInput() {
  getEvaluator().getBooleanResult("[pos=42] <= 2");
+
Evaluator.getBooleanResult("[pos=42] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
 +
fail();
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 19. September 2017, 07:31 Uhr

Beschreibung

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

Syntax

a <= b

Parameter

  • a - double
  • b - double

Return Value

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

Beispiele

    --> returns true
    --> returns true
    --> returns false

JUnit Tests

[Anzeigen]

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

	lessThanOrEqualExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
	lessThanOrEqualExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
	lessThanOrEqualExerciseVariableMap.put("c", ExpressionParser.parse("2.5", null, null));
}

@Test
public void testLessThanOrEqual1() {
	assertTrue(!Evaluator.getBooleanResult("22<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual2() {
	assertTrue(Evaluator.getBooleanResult("8<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual3() {
	assertTrue(Evaluator.getBooleanResult("2<=8", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual4() {
	assertTrue(Evaluator.getBooleanResult("8<=9", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual5() {
	assertTrue(!Evaluator.getBooleanResult("45<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual6() {
	assertTrue(Evaluator.getBooleanResult("7<=7", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual7() {
	assertTrue(Evaluator.getBooleanResult("-0.2<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqual8() {
	assertTrue(Evaluator.getBooleanResult("0<=0", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables1() {
	assertTrue(!Evaluator.getBooleanResult("22<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables2() {
	assertTrue(Evaluator.getBooleanResult("3<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables3() {
	assertTrue(Evaluator.getBooleanResult("2<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables4() {
	assertTrue(Evaluator.getBooleanResult("8<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}
	
@Test
public void testLessThanOrEqualWithVariables5() {
	assertTrue(Evaluator.getBooleanResult("8<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables6() {
	assertTrue(!Evaluator.getBooleanResult("[var=b]<=23", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables7() {
	assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables8() {
	assertTrue(Evaluator.getBooleanResult("[var=a]<=[var=b]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithVariables9() {
	assertTrue(!Evaluator.getBooleanResult("[var=b]<=[var=a]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput1() {
	assertTrue(!Evaluator.getBooleanResult("22<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput2() {
	assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput3() {
	assertTrue(Evaluator.getBooleanResult("2<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput4() {
	assertTrue(Evaluator.getBooleanResult("3<=[pos=1]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput5() {
	assertTrue(Evaluator.getBooleanResult("[pos=2]<=5", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput6() {
	assertTrue(!Evaluator.getBooleanResult("5<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithInput7() {
	assertTrue(!Evaluator.getBooleanResult("[pos=1]<=[pos=2]", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithEncapsulation1() {
	assertTrue(Evaluator.getBooleanResult("1 <= (1 <= 2)", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithEncapsulation2() {
	assertTrue(Evaluator.getBooleanResult("1 <= (1 <= (0 <= 1))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithEncapsulation3() {
	assertTrue(Evaluator.getBooleanResult("0 <= (0 <= (0 <= (0 <= (0 <= 1))))", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test
public void testLessThanOrEqualWithEncapsulation4() {
	assertTrue(Evaluator.getBooleanResult("((((1 <= 1) <= 1) <= 1) <= 1) <= 1", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap));
}

@Test(expected=ParserException.class)
public void testLessThanOrEqualWithWrongInputCharacter() {
	Evaluator.getBooleanResult("6 <= ab", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
	fail();
}

@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testLessThanOrEqualWithWrongInputString() {
	Evaluator.getBooleanResult("6 <= 'a'", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedExerciseVariableException.class)
public void testLessThanOrEqualWithMissingExcerciseVariable() {
	Evaluator.getBooleanResult("[var=j] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
	fail();
}

@Test (expected=UndefinedFillInVariableException.class)
public void testLessThanOrEqualWithMissingInput() {
	Evaluator.getBooleanResult("[pos=42] <= 2", lessThanOrEqualExerciseVariableMap, lessThanOrEqualFillInVariableMap);
	fail();
}

Hinweise