Exemple #1
0
    def test__cmp__const(self):
        n = NUMBER(0, lineno=1)
        m = CONST(NUMBER(1, lineno=2), lineno=2)
        m2 = CONST(NUMBER(0, lineno=3), lineno=3)

        self.assertNotEqual(n, m)
        self.assertEqual(n, n)

        self.assertNotEqual(n, 2)
        self.assertEqual(n, 0)
        self.assertGreater(n, -1)
        self.assertLess(n, 1)

        self.assertGreater(m, n)
        self.assertLess(n, m)
        self.assertEqual(n, m2)
        self.assertEqual(m2, n)
Exemple #2
0
 def test__sub__num_const(self):
     a = NUMBER(1, 0)
     b = CONST(NUMBER(2, 0), 0)
     self.assertEqual((a - b).t, '-1')
Exemple #3
0
 def test__radd__num_const(self):
     a = NUMBER(1, 0)
     b = CONST(NUMBER(2, 0), 0)
     self.assertEqual((b + a).t, '3')
Exemple #4
0
 def test__rdiv__num_const(self):
     a = CONST(NUMBER(-3, 0), 0)
     b = NUMBER(2, 0)
     self.assertEqual((a / b).t, str(a.expr.value / b.value))
Exemple #5
0
 def test__rmul__num_const(self):
     a = NUMBER(3, 0)
     b = CONST(NUMBER(2, 0), 0)
     self.assertEqual((b * a).t, '6')