def test_namespace_uri_function(): for arg, expected in ( (nodeset_literal([]), datatypes.string()), (nodeset_literal([CHILD3]), datatypes.string('http://foo.com')) ): result = function_call('namespace-uri', [arg]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) assert result == expected, (result, expected)
def test_namespace_uri_function(): for arg, expected in ((nodeset_literal([]), datatypes.string()), (nodeset_literal([CHILD3]), datatypes.string('http://foo.com'))): result = function_call('namespace-uri', [arg]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) assert result == expected, (result, expected)
def test_local_name_function(): for arg, expected in ( (nodeset_literal([]), datatypes.string()), (nodeset_literal([CHILD3]), datatypes.string('CHILD3')), ): result = function_call('local-name', [arg]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) assert result == expected, (result, expected)
def test_filter_exr(): result = filter_expr(nodeset_literal([ROOT, CHILD1]), predicates([predicate(TRUE)]) ).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT, CHILD1])) result = filter_expr(nodeset_literal([ROOT, CHILD1]), predicates([predicate(FALSE)]) ).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset())
def test_contains_function(): for args, expected in ( ([nodeset_literal([CHILD1]), string_literal('"3.14"')], datatypes.FALSE), ([nodeset_literal([CHILD1]), nodeset_literal([CHILD1])], datatypes.TRUE), ([nodeset_literal([CHILD1]), string_literal('""')], datatypes.TRUE), ): result = function_call('contains', args).evaluate_as_boolean(CONTEXT1) assert isinstance(result, datatypes.boolean) assert result == expected, (result, expected)
def test_filter_exr(): result = filter_expr(nodeset_literal([ROOT, CHILD1]), predicates([predicate(TRUE) ])).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT, CHILD1])) result = filter_expr(nodeset_literal([ROOT, CHILD1]), predicates([predicate(FALSE) ])).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset())
def test_concat_function(): result = function_call('concat', [nodeset_literal([CHILD1]), string_literal('"3.14"'), string_literal('"Hi"')]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) expected = datatypes.string('\n \n \n Text1\n 3.14Hi') assert result == expected, (result, expected)
def test_concat_function(): result = function_call('concat', [ nodeset_literal([CHILD1]), string_literal('"3.14"'), string_literal('"Hi"') ]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) expected = datatypes.string('\n \n \n Text1\n 3.14Hi') assert result == expected, (result, expected)
def test_id_function(): for args, expected in ( ([number_literal('1')], datatypes.nodeset([CHILD2])), ([string_literal('"1 1"')], datatypes.nodeset([CHILD2])), ([string_literal('"0"')], datatypes.nodeset()), ([string_literal('"0 1"')], datatypes.nodeset([CHILD2])), ([string_literal('"0 1 1"')], datatypes.nodeset([CHILD2])), ([string_literal('"0 0 1 1"')], datatypes.nodeset([CHILD2])), ([nodeset_literal([EGG1])], datatypes.nodeset()), ([nodeset_literal([EGG1, EGG2])], datatypes.nodeset([CHILD2])), ([nodeset_literal([EGG1, EGG2, EGG3])], datatypes.nodeset([CHILD2])), ([nodeset_literal([EGG1, EGG2, EGG3, EGG4])], datatypes.nodeset([CHILD2])), ): result = function_call('id', args).evaluate_as_nodeset(CONTEXT1) assert isinstance(result, datatypes.nodeset) result = list(result) expected = list(expected) assert result == expected, (args, result, expected)
def test_equality_expr(): for (left, right), expected in ( # `=` tests ((number_literal('5'), number_literal('5')), datatypes.TRUE), ((number_literal('5'), number_literal('-5')), datatypes.FALSE), ((number_literal('-5'), number_literal('-5')), datatypes.TRUE), ((number_literal('0'), number_literal('0')), datatypes.TRUE), ((POSITIVE_INFINITY, POSITIVE_INFINITY), datatypes.TRUE), ((POSITIVE_INFINITY, NEGATIVE_INFINITY), datatypes.FALSE), ((NEGATIVE_INFINITY, POSITIVE_INFINITY), datatypes.FALSE), ((NEGATIVE_INFINITY, NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal('5'), POSITIVE_INFINITY), datatypes.FALSE), ((number_literal('5'), NOT_A_NUMBER), datatypes.FALSE), ((NOT_A_NUMBER, NOT_A_NUMBER), datatypes.FALSE), ((number_literal('5'), nodeset_literal([NUM31])), datatypes.FALSE), ((string_literal('5'), string_literal('5')), datatypes.TRUE), ((string_literal('5'), string_literal('-5')), datatypes.FALSE), ((string_literal('-5'), string_literal('-5')), datatypes.TRUE), ((string_literal('0'), string_literal('0')), datatypes.TRUE), ((string_literal('Hi'), string_literal('Hi')), datatypes.TRUE), ((string_literal('5'), string_literal('Hi')), datatypes.FALSE), ((string_literal('5'), string_literal('NaN')), datatypes.FALSE), ((string_literal('NaN'), string_literal('NaN')), datatypes.TRUE), ((string_literal('5'), nodeset_literal([NUM31])), datatypes.FALSE), ((EMPTY_NODESET, TRUE), datatypes.FALSE), ((EMPTY_NODESET, FALSE), datatypes.TRUE), ((EMPTY_NODESET, nodeset_literal([EGG1])), datatypes.FALSE), ((nodeset_literal([EGG1]), EMPTY_NODESET), datatypes.FALSE), ((nodeset_literal([EGG1]), nodeset_literal([EGG1])), datatypes.TRUE), ((string_literal('egg1'), nodeset_literal([EGG1])), datatypes.TRUE), ((string_literal('egg2'), nodeset_literal([EGG1])), datatypes.FALSE), ((string_literal('egg1'), nodeset_literal([EGG1, EGG2])), datatypes.TRUE), ): node = equality_expr(left, '=', right) result = node.evaluate_as_boolean(default_context) assert isinstance(result, datatypes.boolean), result assert result == expected, (result, expected)
def test_equality_expr(): for (left, right), expected in ( # `=` tests ((number_literal("5"), number_literal("5")), datatypes.TRUE), ((number_literal("5"), number_literal("-5")), datatypes.FALSE), ((number_literal("-5"), number_literal("-5")), datatypes.TRUE), ((number_literal("0"), number_literal("0")), datatypes.TRUE), ((POSITIVE_INFINITY, POSITIVE_INFINITY), datatypes.TRUE), ((POSITIVE_INFINITY, NEGATIVE_INFINITY), datatypes.FALSE), ((NEGATIVE_INFINITY, POSITIVE_INFINITY), datatypes.FALSE), ((NEGATIVE_INFINITY, NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal("5"), POSITIVE_INFINITY), datatypes.FALSE), ((number_literal("5"), NOT_A_NUMBER), datatypes.FALSE), ((NOT_A_NUMBER, NOT_A_NUMBER), datatypes.FALSE), ((number_literal("5"), nodeset_literal([NUM31])), datatypes.FALSE), ((string_literal("5"), string_literal("5")), datatypes.TRUE), ((string_literal("5"), string_literal("-5")), datatypes.FALSE), ((string_literal("-5"), string_literal("-5")), datatypes.TRUE), ((string_literal("0"), string_literal("0")), datatypes.TRUE), ((string_literal("Hi"), string_literal("Hi")), datatypes.TRUE), ((string_literal("5"), string_literal("Hi")), datatypes.FALSE), ((string_literal("5"), string_literal("NaN")), datatypes.FALSE), ((string_literal("NaN"), string_literal("NaN")), datatypes.TRUE), ((string_literal("5"), nodeset_literal([NUM31])), datatypes.FALSE), ((EMPTY_NODESET, TRUE), datatypes.FALSE), ((EMPTY_NODESET, FALSE), datatypes.TRUE), ((EMPTY_NODESET, nodeset_literal([EGG1])), datatypes.FALSE), ((nodeset_literal([EGG1]), EMPTY_NODESET), datatypes.FALSE), ((nodeset_literal([EGG1]), nodeset_literal([EGG1])), datatypes.TRUE), ((string_literal("egg1"), nodeset_literal([EGG1])), datatypes.TRUE), ((string_literal("egg2"), nodeset_literal([EGG1])), datatypes.FALSE), ((string_literal("egg1"), nodeset_literal([EGG1, EGG2])), datatypes.TRUE), ): node = equality_expr(left, "=", right) result = node.evaluate_as_boolean(default_context) assert isinstance(result, datatypes.boolean), result assert result == expected, (result, expected)
def test_path_exr(): result = path_expr(nodeset_literal([ROOT, CHILD1]), '/', nodeset_literal([ROOT]) ).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT]))
def test_sum_function(): result = function_call('sum', [nodeset_literal([EGG1, EGG2, EGG3, EGG4])]).evaluate_as_number(CONTEXT1) assert isinstance(result, datatypes.number) assert result == datatypes.number(2)
def test_union_exr_new(): result = union_expr(nodeset_literal([ROOT, CHILD1]), nodeset_literal([ROOT]) ).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT, CHILD1]))
def test_name_function(): result = function_call('name', [nodeset_literal([CHILD3])]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) assert result == datatypes.string('foo:CHILD3')
def test_count_function(): node = function_call('count', (nodeset_literal([ROOT, CHILD1]),)) result = node.evaluate_as_number(CONTEXT1) assert isinstance(result, datatypes.number) assert result == datatypes.number(2)
def test_sum_function(): result = function_call('sum', [nodeset_literal([EGG1, EGG2, EGG3, EGG4]) ]).evaluate_as_number(CONTEXT1) assert isinstance(result, datatypes.number) assert result == datatypes.number(2)
def test_count_function(): node = function_call('count', (nodeset_literal([ROOT, CHILD1]), )) result = node.evaluate_as_number(CONTEXT1) assert isinstance(result, datatypes.number) assert result == datatypes.number(2)
def test_union_exr_new(): result = union_expr(nodeset_literal([ROOT, CHILD1]), nodeset_literal([ROOT])).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT, CHILD1]))
def test_path_exr(): result = path_expr(nodeset_literal([ROOT, CHILD1]), '/', nodeset_literal([ROOT])).evaluate_as_nodeset(CONTEXT) _check_nodeset_result(result, datatypes.nodeset([ROOT]))
def test_string_function(): result = function_call( 'string', [nodeset_literal([CHILD1])]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) expected = datatypes.string('\n \n \n Text1\n ') assert result == expected, (result, expected)
def test_relational_expr(): for (left, op, right), expected in ( ((number_literal('5'), '<', number_literal('5')), datatypes.FALSE), ((number_literal('5'), '<=', number_literal('5')), datatypes.TRUE), ((number_literal('5'), '>', number_literal('5')), datatypes.FALSE), ((number_literal('5'), '>=', number_literal('5')), datatypes.TRUE), ((number_literal('5'), '<', number_literal('-5')), datatypes.FALSE), ((number_literal('5'), '<=', number_literal('-5')), datatypes.FALSE), ((number_literal('5'), '>', number_literal('-5')), datatypes.TRUE), ((number_literal('5'), '>=', number_literal('-5')), datatypes.TRUE), ((number_literal('5'), '<', number_literal('0')), datatypes.FALSE), ((number_literal('5'), '<=', number_literal('0')), datatypes.FALSE), ((number_literal('5'), '>', number_literal('0')), datatypes.TRUE), ((number_literal('5'), '>=', number_literal('0')), datatypes.TRUE), ((number_literal('5'), '<', POSITIVE_INFINITY), datatypes.TRUE), ((number_literal('5'), '<=', POSITIVE_INFINITY), datatypes.TRUE), ((number_literal('5'), '>', POSITIVE_INFINITY), datatypes.FALSE), ((number_literal('5'), '>=', POSITIVE_INFINITY), datatypes.FALSE), ((number_literal('5'), '<', NEGATIVE_INFINITY), datatypes.FALSE), ((number_literal('5'), '<=', NEGATIVE_INFINITY), datatypes.FALSE), ((number_literal('5'), '>', NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal('5'), '>=', NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal('5'), '<', NOT_A_NUMBER), datatypes.FALSE), ((number_literal('5'), '<=', NOT_A_NUMBER), datatypes.FALSE), ((number_literal('5'), '>', NOT_A_NUMBER), datatypes.FALSE), ((number_literal('5'), '>=', NOT_A_NUMBER), datatypes.FALSE), ((number_literal('5'), '<', nodeset_literal([NUM31])), datatypes.TRUE), ((number_literal('5'), '<=', nodeset_literal([NUM31])), datatypes.TRUE), ((number_literal('5'), '>', nodeset_literal([NUM31])), datatypes.FALSE), ((number_literal('5'), '>=', nodeset_literal([NUM31])), datatypes.FALSE), ((number_literal('5'), '<', string_literal('5')), datatypes.FALSE), ((number_literal('5'), '<=', string_literal('5')), datatypes.TRUE), ((number_literal('5'), '>', string_literal('5')), datatypes.FALSE), ((number_literal('5'), '>=', string_literal('5')), datatypes.TRUE), ((number_literal('31'), '<', string_literal('5')), datatypes.FALSE), ((number_literal('31'), '<=', string_literal('5')), datatypes.FALSE), ((number_literal('31'), '>', string_literal('5')), datatypes.TRUE), ((number_literal('31'), '>=', string_literal('5')), datatypes.TRUE), ((string_literal('5'), '<', string_literal('5')), datatypes.FALSE), ((string_literal('5'), '<=', string_literal('5')), datatypes.TRUE), ((string_literal('5'), '>', string_literal('5')), datatypes.FALSE), ((string_literal('5'), '>=', string_literal('5')), datatypes.TRUE), ((string_literal('31'), '<', string_literal('5')), datatypes.FALSE), ((string_literal('31'), '<=', string_literal('5')), datatypes.FALSE), ((string_literal('31'), '>', string_literal('5')), datatypes.TRUE), ((string_literal('31'), '>=', string_literal('5')), datatypes.TRUE), ((number_literal('5'), '<', string_literal('-5')), datatypes.FALSE), ((number_literal('5'), '<=', string_literal('-5')), datatypes.FALSE), ((number_literal('5'), '>', string_literal('-5')), datatypes.TRUE), ((number_literal('5'), '>=', string_literal('-5')), datatypes.TRUE), ((number_literal('31'), '<', string_literal('-5')), datatypes.FALSE), ((number_literal('31'), '<=', string_literal('-5')), datatypes.FALSE), ((number_literal('31'), '>', string_literal('-5')), datatypes.TRUE), ((number_literal('31'), '>=', string_literal('-5')), datatypes.TRUE), ((string_literal('5'), '<', string_literal('-5')), datatypes.FALSE), ((string_literal('5'), '<=', string_literal('-5')), datatypes.FALSE), ((string_literal('5'), '>', string_literal('-5')), datatypes.TRUE), ((string_literal('5'), '>=', string_literal('-5')), datatypes.TRUE), ((string_literal('31'), '<', string_literal('-5')), datatypes.FALSE), ((string_literal('31'), '<=', string_literal('-5')), datatypes.FALSE), ((string_literal('31'), '>', string_literal('-5')), datatypes.TRUE), ((string_literal('31'), '>=', string_literal('-5')), datatypes.TRUE), ((string_literal('5'), '<', string_literal('Hi')), datatypes.FALSE), ((string_literal('5'), '<=', string_literal('Hi')), datatypes.FALSE), ((string_literal('5'), '>', string_literal('Hi')), datatypes.FALSE), ((string_literal('5'), '>=', string_literal('Hi')), datatypes.FALSE), ((string_literal('5'), '<', nodeset_literal([NUM31])), datatypes.TRUE), ((string_literal('5'), '<=', nodeset_literal([NUM31])), datatypes.TRUE), ((string_literal('5'), '>', nodeset_literal([NUM31])), datatypes.FALSE), ((string_literal('5'), '>=', nodeset_literal([NUM31])), datatypes.FALSE), ((nodeset_literal([NUM2]), '<', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM2]), '<=', nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM2]), '>', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM2]), '>=', nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), '<', nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), '<=', nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), '>', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM0]), '>=', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), '<', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), '<=', nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), '>', nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM4]), '>=', nodeset_literal([NUM2])), datatypes.TRUE), ): node = relational_expr(left, op, right) result = node.evaluate_as_boolean(default_context) assert isinstance(result, datatypes.boolean), result assert result == expected, (result, expected)
def test_relational_expr(): for (left, op, right), expected in ( ((number_literal("5"), "<", number_literal("5")), datatypes.FALSE), ((number_literal("5"), "<=", number_literal("5")), datatypes.TRUE), ((number_literal("5"), ">", number_literal("5")), datatypes.FALSE), ((number_literal("5"), ">=", number_literal("5")), datatypes.TRUE), ((number_literal("5"), "<", number_literal("-5")), datatypes.FALSE), ((number_literal("5"), "<=", number_literal("-5")), datatypes.FALSE), ((number_literal("5"), ">", number_literal("-5")), datatypes.TRUE), ((number_literal("5"), ">=", number_literal("-5")), datatypes.TRUE), ((number_literal("5"), "<", number_literal("0")), datatypes.FALSE), ((number_literal("5"), "<=", number_literal("0")), datatypes.FALSE), ((number_literal("5"), ">", number_literal("0")), datatypes.TRUE), ((number_literal("5"), ">=", number_literal("0")), datatypes.TRUE), ((number_literal("5"), "<", POSITIVE_INFINITY), datatypes.TRUE), ((number_literal("5"), "<=", POSITIVE_INFINITY), datatypes.TRUE), ((number_literal("5"), ">", POSITIVE_INFINITY), datatypes.FALSE), ((number_literal("5"), ">=", POSITIVE_INFINITY), datatypes.FALSE), ((number_literal("5"), "<", NEGATIVE_INFINITY), datatypes.FALSE), ((number_literal("5"), "<=", NEGATIVE_INFINITY), datatypes.FALSE), ((number_literal("5"), ">", NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal("5"), ">=", NEGATIVE_INFINITY), datatypes.TRUE), ((number_literal("5"), "<", NOT_A_NUMBER), datatypes.FALSE), ((number_literal("5"), "<=", NOT_A_NUMBER), datatypes.FALSE), ((number_literal("5"), ">", NOT_A_NUMBER), datatypes.FALSE), ((number_literal("5"), ">=", NOT_A_NUMBER), datatypes.FALSE), ((number_literal("5"), "<", nodeset_literal([NUM31])), datatypes.TRUE), ((number_literal("5"), "<=", nodeset_literal([NUM31])), datatypes.TRUE), ((number_literal("5"), ">", nodeset_literal([NUM31])), datatypes.FALSE), ((number_literal("5"), ">=", nodeset_literal([NUM31])), datatypes.FALSE), ((number_literal("5"), "<", string_literal("5")), datatypes.FALSE), ((number_literal("5"), "<=", string_literal("5")), datatypes.TRUE), ((number_literal("5"), ">", string_literal("5")), datatypes.FALSE), ((number_literal("5"), ">=", string_literal("5")), datatypes.TRUE), ((number_literal("31"), "<", string_literal("5")), datatypes.FALSE), ((number_literal("31"), "<=", string_literal("5")), datatypes.FALSE), ((number_literal("31"), ">", string_literal("5")), datatypes.TRUE), ((number_literal("31"), ">=", string_literal("5")), datatypes.TRUE), ((string_literal("5"), "<", string_literal("5")), datatypes.FALSE), ((string_literal("5"), "<=", string_literal("5")), datatypes.TRUE), ((string_literal("5"), ">", string_literal("5")), datatypes.FALSE), ((string_literal("5"), ">=", string_literal("5")), datatypes.TRUE), ((string_literal("31"), "<", string_literal("5")), datatypes.FALSE), ((string_literal("31"), "<=", string_literal("5")), datatypes.FALSE), ((string_literal("31"), ">", string_literal("5")), datatypes.TRUE), ((string_literal("31"), ">=", string_literal("5")), datatypes.TRUE), ((number_literal("5"), "<", string_literal("-5")), datatypes.FALSE), ((number_literal("5"), "<=", string_literal("-5")), datatypes.FALSE), ((number_literal("5"), ">", string_literal("-5")), datatypes.TRUE), ((number_literal("5"), ">=", string_literal("-5")), datatypes.TRUE), ((number_literal("31"), "<", string_literal("-5")), datatypes.FALSE), ((number_literal("31"), "<=", string_literal("-5")), datatypes.FALSE), ((number_literal("31"), ">", string_literal("-5")), datatypes.TRUE), ((number_literal("31"), ">=", string_literal("-5")), datatypes.TRUE), ((string_literal("5"), "<", string_literal("-5")), datatypes.FALSE), ((string_literal("5"), "<=", string_literal("-5")), datatypes.FALSE), ((string_literal("5"), ">", string_literal("-5")), datatypes.TRUE), ((string_literal("5"), ">=", string_literal("-5")), datatypes.TRUE), ((string_literal("31"), "<", string_literal("-5")), datatypes.FALSE), ((string_literal("31"), "<=", string_literal("-5")), datatypes.FALSE), ((string_literal("31"), ">", string_literal("-5")), datatypes.TRUE), ((string_literal("31"), ">=", string_literal("-5")), datatypes.TRUE), ((string_literal("5"), "<", string_literal("Hi")), datatypes.FALSE), ((string_literal("5"), "<=", string_literal("Hi")), datatypes.FALSE), ((string_literal("5"), ">", string_literal("Hi")), datatypes.FALSE), ((string_literal("5"), ">=", string_literal("Hi")), datatypes.FALSE), ((string_literal("5"), "<", nodeset_literal([NUM31])), datatypes.TRUE), ((string_literal("5"), "<=", nodeset_literal([NUM31])), datatypes.TRUE), ((string_literal("5"), ">", nodeset_literal([NUM31])), datatypes.FALSE), ((string_literal("5"), ">=", nodeset_literal([NUM31])), datatypes.FALSE), ((nodeset_literal([NUM2]), "<", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM2]), "<=", nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM2]), ">", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM2]), ">=", nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), "<", nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), "<=", nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM0]), ">", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM0]), ">=", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), "<", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), "<=", nodeset_literal([NUM2])), datatypes.FALSE), ((nodeset_literal([NUM4]), ">", nodeset_literal([NUM2])), datatypes.TRUE), ((nodeset_literal([NUM4]), ">=", nodeset_literal([NUM2])), datatypes.TRUE), ): node = relational_expr(left, op, right) result = node.evaluate_as_boolean(default_context) assert isinstance(result, datatypes.boolean), result assert result == expected, (result, expected)
def test_name_function(): result = function_call( 'name', [nodeset_literal([CHILD3])]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) assert result == datatypes.string('foo:CHILD3')
def test_string_function(): result = function_call('string', [nodeset_literal([CHILD1])]).evaluate_as_string(CONTEXT1) assert isinstance(result, datatypes.string) expected = datatypes.string('\n \n \n Text1\n ') assert result == expected, (result, expected)