[tracker/wip/carlosg/sparql-corners: 2/12] tests: Add tests for BIND reusing variable names
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-corners: 2/12] tests: Add tests for BIND reusing variable names
- Date: Mon, 1 Mar 2021 23:51:50 +0000 (UTC)
commit 79cfcfd5b9e51e670cad13197ce5b16ff8d71469
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Feb 26 16:09:36 2021 +0100
tests: Add tests for BIND reusing variable names
This is allowed as long as the variable was not previously defined
in the same group graph pattern, forbidden otherwise. Test both
cases.
tests/libtracker-data/bind/bind-reused-different-patterns.out | 2 ++
tests/libtracker-data/bind/bind-reused-different-patterns.rq | 3 +++
tests/libtracker-data/error/bind-reused-same-pattern.out | 0
tests/libtracker-data/error/bind-reused-same-pattern.rq | 3 +++
tests/libtracker-data/tracker-sparql-test.c | 3 +++
5 files changed, 11 insertions(+)
---
diff --git a/tests/libtracker-data/bind/bind-reused-different-patterns.out
b/tests/libtracker-data/bind/bind-reused-different-patterns.out
new file mode 100644
index 000000000..e1c03aad4
--- /dev/null
+++ b/tests/libtracker-data/bind/bind-reused-different-patterns.out
@@ -0,0 +1,2 @@
+"1"
+"2"
diff --git a/tests/libtracker-data/bind/bind-reused-different-patterns.rq
b/tests/libtracker-data/bind/bind-reused-different-patterns.rq
new file mode 100644
index 000000000..24a86d6b4
--- /dev/null
+++ b/tests/libtracker-data/bind/bind-reused-different-patterns.rq
@@ -0,0 +1,3 @@
+# Bound variables are allowed to be reused across different
+# group graph patterns.
+SELECT ?u { { BIND (1 AS ?u) } UNION { BIND (2 AS ?u) } }
diff --git a/tests/libtracker-data/error/bind-reused-same-pattern.out
b/tests/libtracker-data/error/bind-reused-same-pattern.out
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/libtracker-data/error/bind-reused-same-pattern.rq
b/tests/libtracker-data/error/bind-reused-same-pattern.rq
new file mode 100644
index 000000000..37bf436c7
--- /dev/null
+++ b/tests/libtracker-data/error/bind-reused-same-pattern.rq
@@ -0,0 +1,3 @@
+# BIND is not allowed to redefine variables already defined
+# in the same group graph pattern.
+SELECT ?u { BIND (1 AS ?u) . BIND (2 AS ?u) }
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index c2b7d6225..5b61365d5 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -229,6 +229,8 @@ const TestInfo tests[] = {
/* Unknown property */
{ "error/query-error-2", "error/query-error-2", TRUE, FALSE },
{ "error/update-error-query-1", "error/update-error-1", FALSE, TRUE },
+ /* Remapping variables in BIND */
+ { "error/bind-reused-same-pattern", "error/query-error-1", TRUE, FALSE },
{ "turtle/turtle-query-001", "turtle/turtle-data-001", FALSE },
{ "turtle/turtle-query-002", "turtle/turtle-data-002", FALSE },
@@ -243,6 +245,7 @@ const TestInfo tests[] = {
{ "bind/bind5", "bind/data", FALSE },
{ "bind/bind6", "bind/data", FALSE },
{ "bind/bind7", "bind/data", FALSE },
+ { "bind/bind-reused-different-patterns", "bind/data", FALSE },
/* Property paths */
{ "property-paths/inverse-path-1", "property-paths/data", FALSE },
{ "property-paths/inverse-path-2", "property-paths/data", FALSE },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]