LessThan: Unterschied zwischen den Versionen

Aus JACK Wiki
Zur Navigation springen Zur Suche springen
Zeile 4: Zeile 4:
===Syntax===
===Syntax===
  a < b
  a < b
  lessthan(a,b)
  lessThan(a,b)


===Parameter===
===Parameter===

Version vom 25. Oktober 2017, 12:35 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

<math>3 < 5</math>

JUnit Tests

[Anzeigen]

@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();
}

Hinweise