Example #1
0
 def test_expression(self):
     from xotl.ql.expressions import (count, ExpressionTree, or_, and_,
                                      pow_, lt, eq, add)
     expr = ((q(1) < 3) & (1 == q("1")) |
             (q("a") + q("b") ** 2 == q("x") + count("y")))
     expected = or_(and_(lt(1, 3), eq(1, "1")),
                    eq(add("a", pow_("b", 2)), add("x", count("y"))))
     self.assertIsInstance(expr, ExpressionTree)
     with context(UNPROXIFING_CONTEXT):
         self.assertTrue(expr == expected, "%s ---- %s" % (expected, expr))
Example #2
0
 def test_expression(self):
     from xotl.ql.expressions import (count, ExpressionTree, or_, and_,
                                      pow_, lt, eq, add)
     expr = ((q(1) < 3) & (1 == q("1")) |
             (q("a") + q("b")**2 == q("x") + count("y")))
     expected = or_(and_(lt(1, 3), eq(1, "1")),
                    eq(add("a", pow_("b", 2)), add("x", count("y"))))
     self.assertIsInstance(expr, ExpressionTree)
     with context(UNPROXIFING_CONTEXT):
         self.assertTrue(expr == expected, "%s ---- %s" % (expected, expr))
Example #3
0
    def __eq__(self, other):
        '''
            >>> with context(UNPROXIFING_CONTEXT):
            ...    this('parent') == this('parent')
            True

            >>> from xotl.ql.expressions import _true
            >>> (this('parent') == this('parent')) is _true
            True
        '''
        from xotl.ql.expressions import eq
        with context(UNPROXIFING_CONTEXT):
            if isinstance(other, Term):
                res = validate_attrs(self, other, ('name', 'parent'))
            else:
                res = False
        if context[UNPROXIFING_CONTEXT]:
            return res
        else:
            if not res:
                return eq(self, other)
            else:
                # In logic A == A is always true so we don't produce nothing
                # for it.
                return _true
Example #4
0
    def __eq__(self, other):
        '''
            >>> with context(UNPROXIFING_CONTEXT):
            ...    this('parent') == this('parent')
            True

            >>> from xotl.ql.expressions import _true
            >>> (this('parent') == this('parent')) is _true
            True
        '''
        from xotl.ql.expressions import eq
        with context(UNPROXIFING_CONTEXT):
            if isinstance(other, Term):
                res = validate_attrs(self, other, ('name', 'parent'))
            else:
                res = False
        if context[UNPROXIFING_CONTEXT]:
            return res
        else:
            if not res:
                return eq(self, other)
            else:
                # In logic A == A is always true so we don't produce nothing
                # for it.
                return _true