コード例 #1
0
    def test_basic_eval(self):
        n = Variable("x")
        n.value = Fraction(25, 5)
        self.assertEqual(n.evaluate(), 5)

        n2 = Variable("y", sign=False)
        n2.value = Variable("a", 3)
        self.assertEqual(n2.evaluate(), -3)
コード例 #2
0
    def test_basic_eval(self):
        n = Variable("x")
        n.value = 5
        self.assertEqual(n.evaluate(), 5)

        n2 = Variable("y", sign=False)
        n2.value = 3
        self.assertEqual(n2.evaluate(), -3)

        n3 = Variable("z", sign=False)
        # no value set -> error
        self.assertRaises(ValueError, n3.evaluate)