BooleanOr: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Spobel (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
|||
Zeile 6: | Zeile 6: | ||
===Parameter=== | ===Parameter=== | ||
* '''x''' - | * '''x''' - [[Boolean]] | ||
* '''y''' - | * '''y''' - [[Boolean]] | ||
===Return Value=== | ===Return Value=== | ||
Zeile 13: | Zeile 13: | ||
===Beispiele=== | ===Beispiele=== | ||
1 || 1 --> | 1 || 1 --> True | ||
0 || 1 --> | 0 || 1 --> True | ||
1 || 0 --> | 1 || 0 --> True | ||
0 || 0 --> | 0 || 0 --> False | ||
(2+4==6) || (3+3==6) --> | (2+4==6) || (3+3==6) --> True | ||
====JUnit Tests==== | ====JUnit Tests==== | ||
Zeile 146: | Zeile 146: | ||
* erwartet zwei boolsche Ausdrücke | * erwartet zwei boolsche Ausdrücke | ||
[[Kategorie:Evaluatorfunktion]] | [[Kategorie:Evaluatorfunktion]][[Kategorie:Booleanfunktionen]] |
Version vom 4. Oktober 2017, 13:04 Uhr
Beschreibung
Die Funktion BooleanOr ("||") vergleicht zwei Aussagen auf true oder false. Es wird nur dann false zurückgegeben, wenn beide Aussagen false sind.
Syntax
x || y
Parameter
Return Value
- Gibt einen Boolean zurück.
Beispiele
1 || 1 --> True 0 || 1 --> True 1 || 0 --> True 0 || 0 --> False
(2+4==6) || (3+3==6) --> True
JUnit Tests
[Anzeigen]
@Test
public void testBooleanOr1() {
assertTrue(Evaluator.getBooleanResult("1 || 1", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOr2() {
assertTrue(Evaluator.getBooleanResult("0 || 1", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOr3() {
assertTrue(Evaluator.getBooleanResult("1 || 0", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOr4() {
assertTrue(!Evaluator.getBooleanResult("0 || 0", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOr5() {
assertEquals(true, Evaluator.getBooleanResult("(2+4==6) || (3+3==6)", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithVariables1() {
assertTrue(Evaluator.getBooleanResult("[pos=2] || 1", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithVariables2() {
assertTrue(Evaluator.getBooleanResult("1 || [pos=1]", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithInput1() {
assertTrue(Evaluator.getBooleanResult("[var=b] || 1", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithInput2() {
assertTrue(Evaluator.getBooleanResult("1 || [var=a]", exerciseVariableMap, fillInVariableMap) );
}
@Test
public void testBooleanOrWithEncapsulation1() {
assertTrue(!Evaluator.getBooleanResult("0 || (0 || 0)", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithEncapsulation2() {
assertTrue(Evaluator.getBooleanResult("1 || (1 || 1)", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithEncapsulation3() {
assertTrue(!Evaluator.getBooleanResult("0 || (0 || (0 || (0 ||(0 || 0))))", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithEncapsulation4() {
assertTrue(Evaluator.getBooleanResult("1 || (1 || (1 || (1 || (1 || 1))))", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithEncapsulation5() {
assertTrue(!Evaluator.getBooleanResult("((((0 || 0) || 0) || 0) || 0) || 0", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithEncapsulation6() {
assertTrue(Evaluator.getBooleanResult("((((1 || 1) || 1) || 1) || 1) || 1", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithDifferentNumbers1() {
assertTrue(Evaluator.getBooleanResult("2 || 2", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithDifferentNumbers2() {
assertTrue(Evaluator.getBooleanResult("-1 || 2", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithDifferentNumbers3() {
assertFalse(Evaluator.getBooleanResult("-1 || 0", exerciseVariableMap, fillInVariableMap));
}
@Test
public void testBooleanOrWithDifferentNumbers4() {
assertTrue(Evaluator.getBooleanResult("2.34 || 1.11", exerciseVariableMap, fillInVariableMap));
}
@Test(expected=ParserException.class)
public void testBooleanOrWithWrongInputCharacter() {
Evaluator.getBooleanResult("1 || ab", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test(expected=FunctionInvalidArgumentTypeException.class)
public void testBooleanOrWithWrongInputString() {
Evaluator.getBooleanResult("1 || 'a'", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=UndefinedExerciseVariableException.class)
public void testBooleanOrMissingExcerciseVariable() {
Evaluator.getBooleanResult("[var=j] || 1", exerciseVariableMap, fillInVariableMap);
fail();
}
@Test (expected=UndefinedFillInVariableException.class)
public void testBooleanOrWithMissingInput() {
Evaluator.getBooleanResult("[pos=42] || 1", exerciseVariableMap, fillInVariableMap);
fail();
}
Hinweise
- erwartet zwei boolsche Ausdrücke