Skip to content

Commit dfeb021

Browse files
Tptafs
authored andcommitted
Add some tests covering regex quantifiers and options
Based on XPath spec: https://www.w3.org/TR/xpath-functions/#regex-syntax Issue #46
1 parent a77cdf0 commit dfeb021

36 files changed

+1011
-0
lines changed

sparql/sparql10/regex/index.html

+442
Large diffs are not rendered by default.

sparql/sparql10/regex/manifest.ttl

+135
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@
1010
rdfs:comment "SPARQL regex test cases" ;
1111
mf:entries (
1212
:dawg-regex-001 :dawg-regex-002 :dawg-regex-003 :dawg-regex-004
13+
:regex-quantifier-optional
14+
:regex-quantifier-zero-or-more
15+
:regex-quantifier-one-or-more
16+
:regex-quantifier-counted-exact
17+
:regex-quantifier-counted-lower-bound
18+
:regex-quantifier-counted-lower-upper-bounds
19+
:regex-dot
20+
:regex-dot-all
21+
:regex-case-insensitive
22+
:regex-no-metacharacters
23+
:regex-no-metacharacters-case-insensitive
24+
:regex-start-end
25+
:regex-start-end-multiline
26+
:regex-char-class-expression
27+
:regex-negative-char-class-expression
28+
:regex-ignore-whitespaces
29+
:regex-ignore-whitespaces-class-expression
1330
).
1431

1532
:dawg-regex-001 a mf:QueryEvaluationTest ;
@@ -56,3 +73,121 @@
5673
qt:data <regex-data-01.ttl> ] ;
5774
mf:result <regex-result-004.ttl> .
5875

76+
:regex-quantifier-optional a mf:QueryEvaluationTest ;
77+
mf:name "REGEX with an ? quantifier" ;
78+
mf:action
79+
[ qt:query <regex-quantifier-optional.rq> ;
80+
qt:data <regex-data-quantifiers.ttl> ] ;
81+
mf:result <regex-quantifier-optional.srx> .
82+
83+
:regex-quantifier-zero-or-more a mf:QueryEvaluationTest ;
84+
mf:name "REGEX with an * quantifier" ;
85+
mf:action
86+
[ qt:query <regex-quantifier-zero-or-more.rq> ;
87+
qt:data <regex-data-quantifiers.ttl> ] ;
88+
mf:result <regex-quantifier-zero-or-more.srx> .
89+
90+
:regex-quantifier-one-or-more a mf:QueryEvaluationTest ;
91+
mf:name "REGEX with a + quantifier" ;
92+
mf:action
93+
[ qt:query <regex-quantifier-one-or-more.rq> ;
94+
qt:data <regex-data-quantifiers.ttl> ] ;
95+
mf:result <regex-quantifier-one-or-more.srx> .
96+
97+
:regex-quantifier-counted-exact a mf:QueryEvaluationTest ;
98+
mf:name "REGEX with an {2} quantifier" ;
99+
mf:action
100+
[ qt:query <regex-quantifier-counted-exact.rq> ;
101+
qt:data <regex-data-quantifiers.ttl> ] ;
102+
mf:result <regex-quantifier-counted-exact.srx> .
103+
104+
:regex-quantifier-counted-lower-bound a mf:QueryEvaluationTest ;
105+
mf:name "REGEX with an {,2} quantifier" ;
106+
mf:action
107+
[ qt:query <regex-quantifier-counted-lower-bound.rq> ;
108+
qt:data <regex-data-quantifiers.ttl> ] ;
109+
mf:result <regex-quantifier-counted-lower-bound.srx> .
110+
111+
:regex-quantifier-counted-lower-upper-bounds a mf:QueryEvaluationTest ;
112+
mf:name "REGEX with an {2,} quantifier" ;
113+
mf:action
114+
[ qt:query <regex-quantifier-counted-lower-upper-bounds.rq> ;
115+
qt:data <regex-data-quantifiers.ttl> ] ;
116+
mf:result <regex-quantifier-counted-lower-upper-bounds.srx> .
117+
118+
:regex-dot a mf:QueryEvaluationTest ;
119+
mf:name "REGEX with an . operator" ;
120+
mf:action
121+
[ qt:query <regex-dot.rq> ;
122+
qt:data <regex-data-quantifiers.ttl> ] ;
123+
mf:result <regex-dot.srx> .
124+
125+
:regex-dot-all a mf:QueryEvaluationTest ;
126+
mf:name "REGEX with an . operator and the s option" ;
127+
mf:action
128+
[ qt:query <regex-dot-all.rq> ;
129+
qt:data <regex-data-quantifiers.ttl> ] ;
130+
mf:result <regex-dot-all.srx> .
131+
132+
:regex-case-insensitive a mf:QueryEvaluationTest ;
133+
mf:name "REGEX with the i option" ;
134+
mf:action
135+
[ qt:query <regex-case-insensitive.rq> ;
136+
qt:data <regex-data-quantifiers.ttl> ] ;
137+
mf:result <regex-case-insensitive.srx> .
138+
139+
:regex-no-metacharacters a mf:QueryEvaluationTest ;
140+
mf:name "REGEX with the q option" ;
141+
mf:action
142+
[ qt:query <regex-no-metacharacters.rq> ;
143+
qt:data <regex-data-quantifiers.ttl> ] ;
144+
mf:result <regex-no-metacharacters.srx> .
145+
146+
:regex-no-metacharacters-case-insensitive a mf:QueryEvaluationTest ;
147+
mf:name "REGEX with the iq option" ;
148+
mf:action
149+
[ qt:query <regex-no-metacharacters-case-insensitive.rq> ;
150+
qt:data <regex-data-quantifiers.ttl> ] ;
151+
mf:result <regex-no-metacharacters.srx> .
152+
153+
:regex-start-end a mf:QueryEvaluationTest ;
154+
mf:name "REGEX with ^ and $" ;
155+
mf:action
156+
[ qt:query <regex-start-end.rq> ;
157+
qt:data <regex-data-quantifiers.ttl> ] ;
158+
mf:result <regex-start-end.srx> .
159+
160+
:regex-start-end-multiline a mf:QueryEvaluationTest ;
161+
mf:name "REGEX with ^ and $ and m option" ;
162+
mf:action
163+
[ qt:query <regex-start-end-multiline.rq> ;
164+
qt:data <regex-data-quantifiers.ttl> ] ;
165+
mf:result <regex-start-end-multiline.srx> .
166+
167+
:regex-char-class-expression a mf:QueryEvaluationTest ;
168+
mf:name "REGEX with [] expression" ;
169+
mf:action
170+
[ qt:query <regex-char-class-expression.rq> ;
171+
qt:data <regex-data-quantifiers.ttl> ] ;
172+
mf:result <regex-char-class-expression.srx> .
173+
174+
:regex-negative-char-class-expression a mf:QueryEvaluationTest ;
175+
mf:name "REGEX with a [^] expression" ;
176+
mf:action
177+
[ qt:query <regex-negative-char-class-expression.rq> ;
178+
qt:data <regex-data-quantifiers.ttl> ] ;
179+
mf:result <regex-negative-char-class-expression.srx> .
180+
181+
:regex-ignore-whitespaces a mf:QueryEvaluationTest ;
182+
mf:name "REGEX with the ignore spacing (x) option" ;
183+
mf:action
184+
[ qt:query <regex-ignore-whitespaces.rq> ;
185+
qt:data <regex-data-quantifiers.ttl> ] ;
186+
mf:result <regex-ignore-whitespaces.srx> .
187+
188+
:regex-ignore-whitespaces-class-expression a mf:QueryEvaluationTest ;
189+
mf:name "REGEX with the ignore spacing (x) option with class expression" ;
190+
mf:action
191+
[ qt:query <regex-ignore-whitespaces-class-expression.rq> ;
192+
qt:data <regex-data-quantifiers.ttl> ] ;
193+
mf:result <regex-ignore-whitespaces-class-expression.srx> .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "abc", "i")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>abc</literal>
10+
</binding>
11+
</result>
12+
<result>
13+
<binding name="val">
14+
<literal>ABC</literal>
15+
</binding>
16+
</result>
17+
</results>
18+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a[b\\n]c")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>abc</literal>
10+
</binding>
11+
</result>
12+
<result>
13+
<binding name="val">
14+
<literal>a
15+
c</literal>
16+
</binding>
17+
</result>
18+
</results>
19+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2+
@prefix ex: <http://example.com/#> .
3+
4+
ex:foo rdf:value "ac" , "abc" , "abbc" , "abbbc" , "a\nc", "a\nb\nc" , "a.c" , "ABC" , "a?+*.{}()[]c" , "b" .
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a.c", "s")
8+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>abc</literal>
10+
</binding>
11+
</result>
12+
<result>
13+
<binding name="val">
14+
<literal>a
15+
c</literal>
16+
</binding>
17+
</result>
18+
<result>
19+
<binding name="val">
20+
<literal>a.c</literal>
21+
</binding>
22+
</result>
23+
</results>
24+
</sparql>

sparql/sparql10/regex/regex-dot.rq

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a.c")
8+
}

sparql/sparql10/regex/regex-dot.srx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>abc</literal>
10+
</binding>
11+
</result>
12+
<result>
13+
<binding name="val">
14+
<literal>a.c</literal>
15+
</binding>
16+
</result>
17+
</results>
18+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, " a\n\r\t[\\n]c ", "x")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>a
10+
c</literal>
11+
</binding>
12+
</result>
13+
</results>
14+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, " a\n\tc ", "x")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>ac</literal>
10+
</binding>
11+
</result>
12+
</results>
13+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a[^b]c")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>a
10+
c</literal>
11+
</binding>
12+
</result>
13+
<result>
14+
<binding name="val">
15+
<literal>a.c</literal>
16+
</binding>
17+
</result>
18+
</results>
19+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a?+*.{}()[]C", "iq")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "a?+*.{}()[]c", "q")
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="val"/>
5+
</head>
6+
<results>
7+
<result>
8+
<binding name="val">
9+
<literal>a?+*.{}()[]c</literal>
10+
</binding>
11+
</result>
12+
</results>
13+
</sparql>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX ex: <http://example.com/#>
3+
4+
SELECT ?val
5+
WHERE {
6+
ex:foo rdf:value ?val .
7+
FILTER regex(?val, "ab{2}c")
8+
}

0 commit comments

Comments
 (0)