Beispiel #1
0
def test_or_expr():
    for (left, right), expected in (
        ((FALSE, FALSE), datatypes.FALSE),
        ((TRUE, FALSE), datatypes.TRUE),
        ((FALSE, TRUE), datatypes.TRUE),
        ((TRUE, TRUE), datatypes.TRUE),
    ):
        node = or_expr(left, "or", right)
        result = node.evaluate_as_boolean(default_context)
        assert isinstance(result, datatypes.boolean), result
        assert result == expected, (result, expected)
Beispiel #2
0
def test_or_expr():
    for (left, right), expected in (
        ((FALSE, FALSE), datatypes.FALSE),
        ((TRUE, FALSE), datatypes.TRUE),
        ((FALSE, TRUE), datatypes.TRUE),
        ((TRUE, TRUE), datatypes.TRUE),
    ):
        node = or_expr(left, 'or', right)
        result = node.evaluate_as_boolean(default_context)
        assert isinstance(result, datatypes.boolean), result
        assert result == expected, (result, expected)
Beispiel #3
0
def test_predicate():
    ctx = context(ROOT, 1, 1)
    for args, expected in (
        # FIXME: test literal optimization
        # FIXME: test `position() = Expr` optimization
        # FIXME: test `position() [>,>=] Expr` optimization
        # FIXME: test `Expr [<,<=] position()` optimization
        # FIXME: test numeric-type expression
        # test boolean-type expression
        (and_expr(TRUE, 'and', FALSE), []),
        (or_expr(TRUE, 'or', FALSE), [ROOT]),
        # FIXME: test object-type expression
        ):
        result = predicate(args).select(ctx, [ROOT])
        result = list(result)
        assert result == expected, (result, expected)
Beispiel #4
0
def test_predicate():
    ctx = context(ROOT, 1, 1)
    for args, expected in (
            # FIXME: test literal optimization
            # FIXME: test `position() = Expr` optimization
            # FIXME: test `position() [>,>=] Expr` optimization
            # FIXME: test `Expr [<,<=] position()` optimization
            # FIXME: test numeric-type expression
            # test boolean-type expression
        (and_expr(TRUE, 'and', FALSE), []),
        (or_expr(TRUE, 'or', FALSE), [ROOT]),
            # FIXME: test object-type expression
    ):
        result = predicate(args).select(ctx, [ROOT])
        result = list(result)
        assert result == expected, (result, expected)