Example #1
0
 @Test(expected = InvalidTypeException.class)
 public void nullIsNotAllowed() throws PseudoException {
   NullEvaluator op1 = new NullEvaluator();
   IntegerEvaluator op2 = new IntegerEvaluator(0);
   MultEvaluator evaluator = new MultEvaluator(op1, op2);
   evaluator.evaluate(scope);
   fail("Cannot perform arithmetic on Null.");
 }
Example #2
0
 @Test(expected = InvalidTypeException.class)
 public void stringMultipliedByStringIsNotAllowed() throws PseudoException {
   MultEvaluator evaluator = new MultEvaluator(new StringEvaluator("9"), new StringEvaluator("3"));
   evaluator.evaluate(scope);
   fail("A string cannot be used in division.");
 }
Example #3
0
 @Test
 public void integerMultipliedByDoubleIsADouble() throws PseudoException {
   MultEvaluator evaluator = new MultEvaluator(new IntegerEvaluator(0), new DoubleEvaluator(0.0));
   Type ret = evaluator.evaluate(scope);
   assertEquals("0*0.0 must be double 0.0.", 0.0, (Double) ret.getValue(), 0.01);
 }
Example #4
0
 @Test
 public void doubleMultipliedByIntegerIsADouble() throws PseudoException {
   MultEvaluator evaluator = new MultEvaluator(new DoubleEvaluator(3.0), new IntegerEvaluator(3));
   Type ret = evaluator.evaluate(scope);
   assertEquals("3.0*3 must be double 9.0.", 9.0, (Double) ret.getValue(), 0.01);
 }
Example #5
0
 @Test
 public void integerMultipliedByIntegerIsAnInteger() throws PseudoException {
   MultEvaluator evaluator = new MultEvaluator(new IntegerEvaluator(1), new IntegerEvaluator(1));
   Type ret = evaluator.evaluate(scope);
   assertEquals("1*1 must be integer 1.", 1, ret.getValue());
 }