summaryrefslogtreecommitdiff
path: root/test/test_parser_helpers.py
blob: 58d083cbf7ca868757e88452485e686e438df861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from rdflib.plugins.sparql.parser import TriplesSameSubject
# from rdflib.plugins.sparql.algebra import triples


def pt(ts):
    for t in ts:
        print(t)


def test_1():

    t0 = TriplesSameSubject.parseString("[] ?p ?o ")
    print(t0, len(t0))
    assert len(t0) % 3 == 0

    # t=BlankNodePropertyList.parseString("[ :p ?o ]")
    t1 = TriplesSameSubject.parseString("[ ?p ?o ]")
    print(t1, len(t1))
    assert len(t1) % 3 == 0

    t2 = TriplesSameSubject.parseString("[ ?p1 ?o1 ] ?p2 ?o2 ")
    print(t2, len(t2))
    assert len(t2) % 3 == 0

    t3 = TriplesSameSubject.parseString("?s ?p1 [ ] ")
    print(t3, len(t3))
    assert len(t3) % 3 == 0

    t4 = TriplesSameSubject.parseString("?s ?p1 [ ?p2 ?o2 ] ")
    print(t4, len(t4))
    assert len(t4) % 3 == 0

    t5 = TriplesSameSubject.parseString("[ ] ?p2 [ ] ")
    print(t5, len(t5))
    assert len(t5) % 3 == 0

    t6 = TriplesSameSubject.parseString("[ ?p1 ?o1 ] ?p2 [ ?p3 ?o2 ] ")
    print(t6, len(t6))
    assert len(t6) % 3 == 0