Skip to content

Commit

Permalink
move macros to macros.cljc
Browse files Browse the repository at this point in the history
  • Loading branch information
carocad committed Aug 16, 2020
1 parent c51928a commit 4198acc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 13 additions & 1 deletion test/parcera/macros.cljc
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
(ns parcera.macros
"Some of our tests use `slurp`, which ClojureScript lacks"
#?(:clj (:refer-clojure :exclude [slurp]))
#?(:cljs (:require-macros [parcera.macros])))
#?(:cljs (:require-macros [parcera.macros]))
(:require [clojure.test :refer [is]]
[parcera.core :as parcera]))

#?(:clj (defmacro slurp* [file]
(clojure.core/slurp file)))

#?(:clj (defmacro roundtrip
"checks parcera can parse and write back the exact same input code"
[input]
`(is (= ~input (parcera/code (parcera/ast ~input))))))


#?(:clj (defmacro valid?
[input]
`(is (not (parcera/failure? (parcera/ast ~input))))))
13 changes: 1 addition & 12 deletions test/parcera/test_cases.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[clojure.test.check.properties :as prop]
[clojure.test.check :as tc]
[parcera.core :as parcera]
[parcera.macros :refer [slurp*]]))
[parcera.macros :refer [slurp* roundtrip valid?]]))


(defn- nested?
Expand All @@ -32,17 +32,6 @@
(<= (:column end) (:column (last ends))))))


(defmacro roundtrip
"checks parcera can parse and write back the exact same input code"
[input]
`(is (= ~input (parcera/code (parcera/ast ~input)))))


(defmacro valid?
[input]
`(is (not (parcera/failure? (parcera/ast ~input)))))


(def validity
"The grammar definition of parcera is valid for any clojure value. Meaning
that for any clojure value, parcera can create an AST for it"
Expand Down

0 comments on commit 4198acc

Please sign in to comment.