Exemplo n.º 1
0
    def test_push_result(self):
        "Test false push result"
        f = ast.Constant(False)
        n = ast.PushResult(None, f)

        # Should reduce to False
        c, r = optimizer.optimization_pass(n)
        assert c == 1
        assert isinstance(r, ast.Constant)
        assert r.value == False
Exemplo n.º 2
0
    def test_push(self):
        p = ast.PushResult(True, ast.Constant(True))
        class TestSet(object):
            def __init__(self):
                self.res = []
            def push_match(self, m):
                self.res.append(m)

        testset = TestSet()
        assert p.evaluate(testset, {})
        assert testset.res == [True]