Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some tests covering regex quantifiers and options #155

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
442 changes: 442 additions & 0 deletions sparql/sparql10/regex/index.html

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions sparql/sparql10/regex/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
rdfs:comment "SPARQL regex test cases" ;
mf:entries (
:dawg-regex-001 :dawg-regex-002 :dawg-regex-003 :dawg-regex-004
:regex-quantifier-optional
:regex-quantifier-zero-or-more
:regex-quantifier-one-or-more
:regex-quantifier-counted-exact
:regex-quantifier-counted-lower-bound
:regex-quantifier-counted-lower-upper-bounds
:regex-dot
:regex-dot-all
:regex-case-insensitive
:regex-no-metacharacters
:regex-no-metacharacters-case-insensitive
:regex-start-end
:regex-start-end-multiline
:regex-char-class-expression
:regex-negative-char-class-expression
:regex-ignore-whitespaces
:regex-ignore-whitespaces-class-expression
).

:dawg-regex-001 a mf:QueryEvaluationTest ;
Expand Down Expand Up @@ -56,3 +73,121 @@
qt:data <regex-data-01.ttl> ] ;
mf:result <regex-result-004.ttl> .

:regex-quantifier-optional a mf:QueryEvaluationTest ;
mf:name "REGEX with an ? quantifier" ;
mf:action
[ qt:query <regex-quantifier-optional.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-optional.srx> .

:regex-quantifier-zero-or-more a mf:QueryEvaluationTest ;
mf:name "REGEX with an * quantifier" ;
mf:action
[ qt:query <regex-quantifier-zero-or-more.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-zero-or-more.srx> .

:regex-quantifier-one-or-more a mf:QueryEvaluationTest ;
mf:name "REGEX with a + quantifier" ;
mf:action
[ qt:query <regex-quantifier-one-or-more.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-one-or-more.srx> .

:regex-quantifier-counted-exact a mf:QueryEvaluationTest ;
mf:name "REGEX with an {2} quantifier" ;
mf:action
[ qt:query <regex-quantifier-counted-exact.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-counted-exact.srx> .

:regex-quantifier-counted-lower-bound a mf:QueryEvaluationTest ;
mf:name "REGEX with an {,2} quantifier" ;
mf:action
[ qt:query <regex-quantifier-counted-lower-bound.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-counted-lower-bound.srx> .

:regex-quantifier-counted-lower-upper-bounds a mf:QueryEvaluationTest ;
mf:name "REGEX with an {2,} quantifier" ;
mf:action
[ qt:query <regex-quantifier-counted-lower-upper-bounds.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-quantifier-counted-lower-upper-bounds.srx> .

:regex-dot a mf:QueryEvaluationTest ;
mf:name "REGEX with an . operator" ;
mf:action
[ qt:query <regex-dot.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-dot.srx> .

:regex-dot-all a mf:QueryEvaluationTest ;
mf:name "REGEX with an . operator and the s option" ;
mf:action
[ qt:query <regex-dot-all.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-dot-all.srx> .

:regex-case-insensitive a mf:QueryEvaluationTest ;
mf:name "REGEX with the i option" ;
mf:action
[ qt:query <regex-case-insensitive.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-case-insensitive.srx> .

:regex-no-metacharacters a mf:QueryEvaluationTest ;
mf:name "REGEX with the q option" ;
mf:action
[ qt:query <regex-no-metacharacters.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-no-metacharacters.srx> .

:regex-no-metacharacters-case-insensitive a mf:QueryEvaluationTest ;
mf:name "REGEX with the iq option" ;
mf:action
[ qt:query <regex-no-metacharacters-case-insensitive.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-no-metacharacters.srx> .

:regex-start-end a mf:QueryEvaluationTest ;
mf:name "REGEX with ^ and $" ;
mf:action
[ qt:query <regex-start-end.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-start-end.srx> .

:regex-start-end-multiline a mf:QueryEvaluationTest ;
mf:name "REGEX with ^ and $ and m option" ;
mf:action
[ qt:query <regex-start-end-multiline.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-start-end-multiline.srx> .

:regex-char-class-expression a mf:QueryEvaluationTest ;
mf:name "REGEX with [] expression" ;
mf:action
[ qt:query <regex-char-class-expression.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-char-class-expression.srx> .

:regex-negative-char-class-expression a mf:QueryEvaluationTest ;
mf:name "REGEX with a [^] expression" ;
mf:action
[ qt:query <regex-negative-char-class-expression.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-negative-char-class-expression.srx> .

:regex-ignore-whitespaces a mf:QueryEvaluationTest ;
mf:name "REGEX with the ignore spacing (x) option" ;
mf:action
[ qt:query <regex-ignore-whitespaces.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-ignore-whitespaces.srx> .

:regex-ignore-whitespaces-class-expression a mf:QueryEvaluationTest ;
mf:name "REGEX with the ignore spacing (x) option with class expression" ;
mf:action
[ qt:query <regex-ignore-whitespaces-class-expression.rq> ;
qt:data <regex-data-quantifiers.ttl> ] ;
mf:result <regex-ignore-whitespaces-class-expression.srx> .
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-case-insensitive.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "abc", "i")
}
18 changes: 18 additions & 0 deletions sparql/sparql10/regex/regex-case-insensitive.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>abc</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>ABC</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-char-class-expression.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a[b\\n]c")
}
19 changes: 19 additions & 0 deletions sparql/sparql10/regex/regex-char-class-expression.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>abc</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>a
c</literal>
</binding>
</result>
</results>
</sparql>
4 changes: 4 additions & 0 deletions sparql/sparql10/regex/regex-data-quantifiers.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/#> .

ex:foo rdf:value "ac" , "abc" , "abbc" , "abbbc" , "a\nc", "a\nb\nc" , "a.c" , "ABC" , "a?+*.{}()[]c" , "b" .
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-dot-all.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a.c", "s")
}
24 changes: 24 additions & 0 deletions sparql/sparql10/regex/regex-dot-all.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>abc</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>a
c</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>a.c</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-dot.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a.c")
}
18 changes: 18 additions & 0 deletions sparql/sparql10/regex/regex-dot.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>abc</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>a.c</literal>
</binding>
</result>
</results>
</sparql>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, " a\n\r\t[\\n]c ", "x")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>a
c</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-ignore-whitespaces.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, " a\n\tc ", "x")
}
13 changes: 13 additions & 0 deletions sparql/sparql10/regex/regex-ignore-whitespaces.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>ac</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-negative-char-class-expression.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a[^b]c")
}
19 changes: 19 additions & 0 deletions sparql/sparql10/regex/regex-negative-char-class-expression.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>a
c</literal>
</binding>
</result>
<result>
<binding name="val">
<literal>a.c</literal>
</binding>
</result>
</results>
</sparql>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a?+*.{}()[]C", "iq")
}
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-no-metacharacters.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "a?+*.{}()[]c", "q")
}
13 changes: 13 additions & 0 deletions sparql/sparql10/regex/regex-no-metacharacters.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="val"/>
</head>
<results>
<result>
<binding name="val">
<literal>a?+*.{}()[]c</literal>
</binding>
</result>
</results>
</sparql>
8 changes: 8 additions & 0 deletions sparql/sparql10/regex/regex-quantifier-counted-exact.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>

SELECT ?val
WHERE {
ex:foo rdf:value ?val .
FILTER regex(?val, "ab{2}c")
}
Loading
Loading