use of org.nfunk.jep.function.PostfixMathCommandI in project pcgen by PCGen.
the class IfCommandTest method testIf04.
/* Test the case where the condition is a true boolean */
public void testIf04() {
final PostfixMathCommandI c = new IfCommand();
final Stack<Boolean> s = new Stack<>();
s.push(true);
s.push(false);
s.push(true);
runIf(s, c);
final Boolean result = s.pop();
is(result, eq(false), "if (true,false,true) returns false");
}
use of org.nfunk.jep.function.PostfixMathCommandI in project pcgen by PCGen.
the class IfCommandTest method testIf02.
/* Test the case where the condition is a non zero double */
public void testIf02() {
final PostfixMathCommandI c = new IfCommand();
final Stack<Double> s = new Stack<>();
s.push(1.0);
s.push(1.0);
s.push(2.0);
runIf(s, c);
final Double result = s.pop();
is(result, eq(1.0, 0.1), "if (1.0,1.0,2.0) returns 1.0");
}
use of org.nfunk.jep.function.PostfixMathCommandI in project pcgen by PCGen.
the class OrCommandTest method testOr02.
/* Test the case where the first operand is false, but the second is true */
public void testOr02() {
final PostfixMathCommandI c = new OrCommand();
final Stack<Double> s = new Stack<>();
s.push(0.0);
s.push(2.0);
c.setCurNumberOfParameters(2);
runOr(s, c);
final Double result = s.pop();
is(result, eq(2.0, 0.1), "if (0.0,2.0) returns 2.0");
}
use of org.nfunk.jep.function.PostfixMathCommandI in project pcgen by PCGen.
the class OrCommandTest method testOr01.
/* Test the case where the first operand is true */
public void testOr01() {
final PostfixMathCommandI c = new OrCommand();
final Stack<Object> s = new Stack<>();
s.push(1.0);
s.push(2.0);
c.setCurNumberOfParameters(2);
runOr(s, c);
final Double result = (Double) s.pop();
is(result, eq(1.0, 0.1), "if (1.0,2.0) returns 1.0");
}
use of org.nfunk.jep.function.PostfixMathCommandI in project pcgen by PCGen.
the class OrCommandTest method testOr05.
/* Test the case where false and zero are skipped */
public void testOr05() {
final PostfixMathCommandI c = new OrCommand();
final Stack s = new Stack();
s.push(false);
s.push(false);
s.push(false);
s.push(false);
c.setCurNumberOfParameters(4);
runOr(s, c);
final Object result = s.pop();
is(result, new CompareEqualDouble(0.0), "if (false,false,false,false) returns 0.0");
}
Aggregations