Ejemplo n.º 1
0
    def test_canonical_non_literal(self):
        "Test canonicalization, literals on left"
        v = ast.Number(42)
        l = ast.Literal('foo')
        cmp = ast.CompareOperator('=', v, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is v
Ejemplo n.º 2
0
    def test_canonical_non_literal(self):
        "Test canonicalization, literals on left"
        v = ast.Number(42)
        l = ast.Literal('foo')
        cmp = ast.CompareOperator('=', v, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is v
Ejemplo n.º 3
0
    def test_canonical_literal_order(self):
        "Test canonicalization, literals on left"
        l = ast.Literal('foo')
        r = ast.Literal('zip')
        cmp = ast.CompareOperator('>', r, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is r
        assert cmp.type == "<"
Ejemplo n.º 4
0
    def test_canonical_literal_order(self):
        "Test canonicalization, literals on left"
        l = ast.Literal('foo')
        r = ast.Literal('zip')
        cmp = ast.CompareOperator('>', r, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is r
        assert cmp.type == "<"
Ejemplo n.º 5
0
    def test_canonical_non_static(self):
        "Test canonicalization, literals on left"
        static = ast.Literal("'string'")
        static.static = True
        static.static_val = 'string'

        l = ast.Literal('foo')
        cmp = ast.CompareOperator('=', static, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is static
Ejemplo n.º 6
0
    def test_canonical_non_static(self):
        "Test canonicalization, literals on left"
        static = ast.Literal("'string'")
        static.static = True
        static.static_val = 'string'

        l = ast.Literal('foo')
        cmp = ast.CompareOperator('=', static, l)
        compare.canonicalize(cmp)

        assert cmp.left is l
        assert cmp.right is static
Ejemplo n.º 7
0
    def test_canonical_static_order(self):
        "Test canonicalization, static ordering"
        static = ast.Literal("'string'")
        static.static = True
        static.static_val = 'string'

        static2 = ast.Literal("'foo'")
        static2.static = True
        static2.static_val = 'foo'

        cmp = ast.CompareOperator('<', static, static2)
        compare.canonicalize(cmp)

        assert cmp.left is static2
        assert cmp.right is static
        assert cmp.type == ">"
Ejemplo n.º 8
0
    def test_canonical_static_order(self):
        "Test canonicalization, static ordering"
        static = ast.Literal("'string'")
        static.static = True
        static.static_val = 'string'


        static2 = ast.Literal("'foo'")
        static2.static = True
        static2.static_val = 'foo'

        cmp = ast.CompareOperator('<', static, static2)
        compare.canonicalize(cmp)

        assert cmp.left is static2
        assert cmp.right is static
        assert cmp.type == ">"