Ejemplo n.º 1
0
 def test_returns_division(self):
     for ltv in super()._TEST_VALUES:
         for rtv in super()._TEST_VALUES:
             op = pydician.DivideOp(pydician.LiteralValueOp(ltv),
                                    pydician.LiteralValueOp(rtv))
             if rtv == 0:
                 with self.assertRaises(ZeroDivisionError):
                     op.run()
             else:
                 self.assertEqual(op.run(), ltv / rtv)
Ejemplo n.º 2
0
 def test_returns_unmodified(self):
     test_values = [
         None, True, False, 0, 1, -1, 0.5, -0.5, 'Something',
         'Something else'
     ]
     for tv in test_values:
         self.assertEqual(pydician.LiteralValueOp(tv).run(), tv)
Ejemplo n.º 3
0
 def test_returns_multiplication(self):
     for ltv in super()._TEST_VALUES:
         for rtv in super()._TEST_VALUES:
             op = pydician.MultiplyOp(pydician.LiteralValueOp(ltv),
                                      pydician.LiteralValueOp(rtv))
             self.assertEqual(op.run(), ltv * rtv)
Ejemplo n.º 4
0
 def test_returns_subtraction(self):
     for ltv in super()._TEST_VALUES:
         for rtv in super()._TEST_VALUES:
             op = pydician.SubtractOp(pydician.LiteralValueOp(ltv),
                                      pydician.LiteralValueOp(rtv))
             self.assertEqual(op.run(), ltv - rtv)
Ejemplo n.º 5
0
 def test_returns_arithmetic_negate(self):
     for tv in super()._TEST_VALUES:
         op = pydician.NegateOp(pydician.LiteralValueOp(tv))
         self.assertEqual(op.run(), -tv)
Ejemplo n.º 6
0
 def test_returns_int(self):
     op = pydician.SingleDieRollOp(
         pydician.DieOp(pydician.LiteralValueOp(6)))
     result = op.run()
     self.assertEqual(type(result), int)
Ejemplo n.º 7
0
 def test_die_generates_int(self):
     op = pydician.DieOp(pydician.LiteralValueOp(6))
     die = op.run()
     self.assertEqual(type(die()), int)
Ejemplo n.º 8
0
 def test_returns_callable(self):
     op = pydician.DieOp(pydician.LiteralValueOp(6))
     self.assertTrue(callable(op.run()))
Ejemplo n.º 9
0
 def test_returns_not_equals_to(self):
     for lv in super()._TEST_VALUES:
         for rv in super()._TEST_VALUES:
             op = pydician.NotEqualOp(pydician.LiteralValueOp(lv),
                                      pydician.LiteralValueOp(rv))
             self.assertEqual(op.run(), 1 if lv != rv else 0)
Ejemplo n.º 10
0
 def test_returns_greater_than_or_equals_to(self):
     for lv in super()._TEST_VALUES:
         for rv in super()._TEST_VALUES:
             op = pydician.GreaterOrEqualOp(pydician.LiteralValueOp(lv),
                                            pydician.LiteralValueOp(rv))
             self.assertEqual(op.run(), 1 if lv >= rv else 0)
Ejemplo n.º 11
0
 def test_returns_less_than(self):
     for lv in super()._TEST_VALUES:
         for rv in super()._TEST_VALUES:
             op = pydician.SmallerOp(pydician.LiteralValueOp(lv),
                                     pydician.LiteralValueOp(rv))
             self.assertEqual(op.run(), 1 if lv < rv else 0)