Make tests run in both clj and cljs.
This commit is contained in:
parent
60aa3df5b0
commit
c4f2e00112
6 changed files with 39 additions and 31 deletions
|
@ -9,7 +9,7 @@
|
|||
(defn var->sql-var
|
||||
"Turns '?xyz into :xyz."
|
||||
[x]
|
||||
(when-not (and (symbol? x)
|
||||
(str/starts-with? (name x) "?"))
|
||||
(raise (str x " is not a Datalog var.")))
|
||||
(keyword (subs (name x) 1)))
|
||||
(if (and (symbol? x)
|
||||
(str/starts-with? (name x) "?"))
|
||||
(keyword (subs (name x) 1))
|
||||
(raise (str x " is not a Datalog var."))))
|
||||
|
|
9
test/datomish/test/query.cljc
Normal file
9
test/datomish/test/query.cljc
Normal file
|
@ -0,0 +1,9 @@
|
|||
(ns datomish.test.query
|
||||
(:require
|
||||
[datomish.query :as dq]
|
||||
#?(:clj [clojure.test :as t :refer [is are deftest testing]])
|
||||
#?(:cljs [cljs.test :as t :refer-macros [is are deftest testing]])
|
||||
))
|
||||
|
||||
(deftest test-query
|
||||
(is (= 1 1)))
|
|
@ -1,7 +0,0 @@
|
|||
(ns datomish.test.query
|
||||
(:require
|
||||
[cljs.test :as t :refer-macros [is are deftest testing]]
|
||||
[datomish.query :as dq]))
|
||||
|
||||
(deftest test-query
|
||||
(is (= 1 1)))
|
|
@ -1,7 +1,9 @@
|
|||
(ns datomish.test.transforms
|
||||
(:require
|
||||
[cljs.test :as t :refer-macros [is are deftest testing]]
|
||||
[datomish.transforms :as transforms]))
|
||||
[datomish.transforms :as transforms]
|
||||
#?(:clj [clojure.test :as t :refer [is are deftest testing]])
|
||||
#?(:cljs [cljs.test :as t :refer-macros [is are deftest testing]])
|
||||
))
|
||||
|
||||
(deftest test-attribute-transform-string
|
||||
(is (= "p/foo"
|
||||
|
@ -16,7 +18,8 @@
|
|||
(is (= 0 (transforms/constant-transform-default false)))
|
||||
|
||||
;; Numbers and strings.
|
||||
(is (= 1 (transforms/constant-transform-default 1.0)))
|
||||
#?(:cljs (is (= 1 (transforms/constant-transform-default 1.0))))
|
||||
#?(:clj (is (= 1.0 (transforms/constant-transform-default 1.0))))
|
||||
(is (= -1 (transforms/constant-transform-default -1)))
|
||||
(is (= 42 (transforms/constant-transform-default 42)))
|
||||
(is (= "" (transforms/constant-transform-default "")))
|
20
test/datomish/test/util.cljc
Normal file
20
test/datomish/test/util.cljc
Normal file
|
@ -0,0 +1,20 @@
|
|||
(ns datomish.test.util
|
||||
(:require
|
||||
[datomish.util :as util]
|
||||
#?(:clj [clojure.test :as t :refer [is are deftest testing]])
|
||||
#?(:cljs [cljs.test :as t :refer-macros [is are deftest testing]])
|
||||
))
|
||||
|
||||
(deftest test-var-translation
|
||||
(is (= :x (util/var->sql-var '?x)))
|
||||
(is (= :XX (util/var->sql-var '?XX))))
|
||||
|
||||
#?(:cljs
|
||||
(deftest test-raise
|
||||
(let [caught
|
||||
(try
|
||||
(do
|
||||
(util/raise "succeed")
|
||||
"fail")
|
||||
(catch :default e e))]
|
||||
(is (= "succeed" (aget caught "message"))))))
|
|
@ -1,17 +0,0 @@
|
|||
(ns datomish.test.util
|
||||
(:require
|
||||
[cljs.test :as t :refer-macros [is are deftest testing]]
|
||||
[datomish.util :as util]))
|
||||
|
||||
(deftest test-var-translation
|
||||
(is (= :x (util/var->sql-var '?x)))
|
||||
(is (= :XX (util/var->sql-var '?XX))))
|
||||
|
||||
(deftest test-raise
|
||||
(let [caught
|
||||
(try
|
||||
(do
|
||||
(util/raise "succeed")
|
||||
"fail")
|
||||
(catch :default e e))]
|
||||
(is (= "succeed" (aget caught "message")))))
|
Loading…
Reference in a new issue