Skip to content

Commit

Permalink
Test that syntax-quoting symbols is banned
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Feb 9, 2024
1 parent 241d97c commit ddfd8ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/test/com/yetanalytics/flint/spec/axiom_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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\\\""))
Expand Down
7 changes: 6 additions & 1 deletion src/test/com/yetanalytics/flint/spec/expr_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion src/test/com/yetanalytics/flint/spec/path_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))))

0 comments on commit ddfd8ac

Please sign in to comment.