From ddfd8ac4b0922dafff3b2ebe4a2d03759d73369f Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Fri, 9 Feb 2024 11:47:52 -0500 Subject: [PATCH] Test that syntax-quoting symbols is banned --- src/test/com/yetanalytics/flint/spec/axiom_test.cljc | 7 +++++-- src/test/com/yetanalytics/flint/spec/expr_test.cljc | 7 ++++++- src/test/com/yetanalytics/flint/spec/path_test.cljc | 10 +++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/test/com/yetanalytics/flint/spec/axiom_test.cljc b/src/test/com/yetanalytics/flint/spec/axiom_test.cljc index 588d2c3..0534fdf 100644 --- a/src/test/com/yetanalytics/flint/spec/axiom_test.cljc +++ b/src/test/com/yetanalytics/flint/spec/axiom_test.cljc @@ -240,11 +240,14 @@ (testing "variables" (is (s/valid? ax/variable-spec '?foo)) (is (not (s/valid? ax/variable-spec "?foo"))) - (is (not (s/valid? ax/variable-spec 'foo)))) + (is (not (s/valid? ax/variable-spec 'foo))) + (is (not (s/valid? ax/variable-spec `?foo)))) (testing "blank nodes" (is (s/valid? ax/bnode-spec '_)) (is (s/valid? ax/bnode-spec '_foo)) - (is (not (s/valid? ax/bnode-spec 'foo)))) + (is (not (s/valid? ax/bnode-spec 'foo))) + (is (not (s/valid? ax/bnode-spec `_))) + (is (not (s/valid? ax/bnode-spec `_foo)))) (testing "string literals" (is (s/valid? ax/literal-spec "foo bar")) (is (s/valid? ax/literal-spec "\\\"\\n\\r\\t\\\"")) diff --git a/src/test/com/yetanalytics/flint/spec/expr_test.cljc b/src/test/com/yetanalytics/flint/spec/expr_test.cljc index 649ad60..cdeccbf 100644 --- a/src/test/com/yetanalytics/flint/spec/expr_test.cljc +++ b/src/test/com/yetanalytics/flint/spec/expr_test.cljc @@ -184,7 +184,12 @@ :in []}] ::s/spec ::es/expr ::s/value '(+)} - (s/explain-data ::es/expr '(+)))))) + (s/explain-data ::es/expr '(+))))) + (testing "Invalid expressions due to syntax quoting" + (is (not (s/valid? ::es/expr `(+ 2 2)))) + (is (not (s/valid? ::es/expr `(and true true)))) + (is (not (s/valid? ::es/expr `(if true 1 0)))) + (is (not (s/valid? ::es/expr `(contains "foo" "foobar")))))) (deftest conform-expr-as-var-test (testing "Conforming expr AS var clauses" diff --git a/src/test/com/yetanalytics/flint/spec/path_test.cljc b/src/test/com/yetanalytics/flint/spec/path_test.cljc index ab8fbee..eda96f9 100644 --- a/src/test/com/yetanalytics/flint/spec/path_test.cljc +++ b/src/test/com/yetanalytics/flint/spec/path_test.cljc @@ -139,4 +139,12 @@ :in [1]}] ::s/spec ::ps/path ::s/value '(not (cat :foo/bar :bar/baz))} - (s/explain-data ::ps/path '(not (cat :foo/bar :bar/baz))))))) + (s/explain-data ::ps/path '(not (cat :foo/bar :bar/baz))))) + (testing "Invalid expressions due to syntax quoting" + (is (not (s/valid? ::ps/path `(alt :foo/bar :baz/qux)))) + (is (not (s/valid? ::ps/path `(cat :foo/bar :baz/qux)))) + (is (not (s/valid? ::ps/path `(inv :foo/bar)))) + (is (not (s/valid? ::ps/path `(not :foo/bar)))) + (is (not (s/valid? ::ps/path `(? :foo/bar)))) + (is (not (s/valid? ::ps/path `(* :foo/bar)))) + (is (not (s/valid? ::ps/path `(+ :foo/bar)))))))