Ejemplo n.º 1
0
    def test_both_dead(self):
        "Test removing a both node when one side is dead"
        t = ast.Constant(True)
        f = ast.Constant(False)

        # Should reduce to left
        n = ast.Both(t, f)
        c, r = optimizer.optimization_pass(n)
        assert c == 1
        assert r is t

        # Should reduce to right
        n = ast.Both(f, t)
        c, r = optimizer.optimization_pass(n)
        assert c == 1
        assert r is t
Ejemplo n.º 2
0
    def test_both_all_false(self):
        "Test removing a both node when both sides are false"
        f = ast.Constant(False)
        n = ast.Both(f, f)

        # Should reduce to False
        c, r = optimizer.optimization_pass(n)
        assert c == 1
        assert isinstance(r, ast.Constant)
        assert r.value == False
Ejemplo n.º 3
0
 def test_iterall_true(self):
     c1 = ast.Constant(False)
     c2 = ast.Constant(True)
     n = ast.Both(c1, c2)
     assert n.evaluate(MockPred(), {}) == True
Ejemplo n.º 4
0
 def test_both_false(self):
     c1 = ast.Constant(False)
     c2 = ast.Constant(False)
     n = ast.Both(c1, c2)
     assert n.evaluate(MockPred(), {}) == False