LessThan: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Markierung: Ersetzt
Zeile 14: Zeile 14:


===Beispiele===
===Beispiele===
  <math>3 < 5</math>
  3 < 5   --> returns true
 
====JUnit Tests====
lessThan(5, 3)   --> returns false
<span class="mw-customtoggle-myDivision">[Anzeigen]</span>
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision">
@BeforeClass
public static void beforeTest() throws FunctionNotImplementedException, UndefinedFillInVariableException,
UndefinedExerciseVariableException, ParserException, ErroneousFillInVariableException, ErroneousExerciseVariableException {
lessThanFillInVariableMap.put(1, ExpressionParser.parse("3", null, null));
lessThanFillInVariableMap.put(2, ExpressionParser.parse("1", null, null));
 
lessThanExerciseVariableMap.put("a", ExpressionParser.parse("8", null, null));
lessThanExerciseVariableMap.put("b", ExpressionParser.parse("25", null, null));
}
 
@Test
public void testLessThan1() {
assertTrue(Evaluator.getBooleanResult("8<22", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThan2() {
assertTrue(!Evaluator.getBooleanResult("22<8", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThan3() {
assertTrue(Evaluator.getBooleanResult("3.5<5.7", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThan4() {
assertTrue(Evaluator.getBooleanResult("-1<1", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThan5() {
assertTrue(Evaluator.getBooleanResult("-0.2<0", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables1() {
assertTrue(Evaluator.getBooleanResult("8<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables2() {
assertTrue(!Evaluator.getBooleanResult("9<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables3() {
assertTrue(!Evaluator.getBooleanResult("22<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables4() {
assertTrue(Evaluator.getBooleanResult("[var=a]<100", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables5() {
assertTrue(Evaluator.getBooleanResult("2<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables6() {
assertTrue(
Evaluator.getBooleanResult("[var=a]<[var=b]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithExerciseVariables7() {
assertTrue(
!Evaluator.getBooleanResult("[var=b]<[var=a]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput1() {
assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput2() {
assertTrue(Evaluator.getBooleanResult("[pos=2]<34", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput3() {
assertTrue(!Evaluator.getBooleanResult("2<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput4() {
assertTrue(!Evaluator.getBooleanResult("22<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput5() {
assertTrue(Evaluator.getBooleanResult("2<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput6() {
assertTrue(
Evaluator.getBooleanResult("[pos=2]<[pos=1]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithInput7() {
assertTrue(
!Evaluator.getBooleanResult("[pos=1]<[pos=2]", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithEncapsulation1() {
assertTrue(!Evaluator.getBooleanResult("1 < (1 < 2)", lessThanExerciseVariableMap, lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithEncapsulation2() {
assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < 1))", lessThanExerciseVariableMap,
lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithEncapsulation3() {
assertTrue(Evaluator.getBooleanResult("0 < (0 < (0 < (0 < (0 < 1))))", lessThanExerciseVariableMap,
lessThanFillInVariableMap));
}
 
@Test
public void testLessThanWithEncapsulation4() {
assertTrue(!Evaluator.getBooleanResult("((((1 < 1) < 1) < 1) < 1) < 1", lessThanExerciseVariableMap,
lessThanFillInVariableMap));
}
 
@Test(expected = ParserException.class)
public void testLessThanWithWrongInputCharacter() {
Evaluator.getBooleanResult("6 < ab", lessThanExerciseVariableMap, lessThanFillInVariableMap);
}
 
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testLessThanWithWrongInputString() {
Evaluator.getBooleanResult("6 < 'a'", lessThanExerciseVariableMap, lessThanFillInVariableMap);
fail();
}
 
@Test(expected = UndefinedExerciseVariableException.class)
public void testLessThanWithMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
fail();
}
 
@Test(expected = UndefinedFillInVariableException.class)
public void testLessThanWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] < 2", lessThanExerciseVariableMap, lessThanFillInVariableMap);
fail();
}
</syntaxhighlight>


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


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

Version vom 25. September 2018, 08:57 Uhr

Beschreibung

Die Funktion lessThan vergleicht zwei Ausdrücke nach der Größe miteinander.

Syntax

a < b
lessThan(a,b)

Parameter

Return Value

  • Gibt einen Boolean zurück

Beispiele

3 < 5    --> returns true

lessThan(5, 3)    --> returns false

Hinweise