Ejemplo n.º 1
0
    def test_evaluation_simple(self):

        two_plus_two = Operation(OperationType.PLUS(),
                                 [Variable(2.0), Variable(2.0)])
        two_plus_two_divided_by_four = Operation(
            OperationType.DIVIDE(), [two_plus_two, Variable(4)])

        self.assertTrue(two_plus_two_divided_by_four.is_evaluatable())
        self.assertAlmostEqual(two_plus_two_divided_by_four.evaluate(), 1)
Ejemplo n.º 2
0
    def test_evaluation_trivial(self):

        two = Operation(OperationType.POSITIVE(), [Variable('2')])

        self.assertTrue(two.is_evaluatable())
        self.assertAlmostEqual(two.evaluate(), 2)

        x = Operation(OperationType.POSITIVE(), [Variable('x')])
        self.assertFalse(x.is_evaluatable())