update function tests
This commit is contained in:
parent
8ff0d555c6
commit
8efdee0319
|
@ -14,6 +14,14 @@
|
||||||
; Some of the variable passing and return / iteration verification tests might be a bit
|
; Some of the variable passing and return / iteration verification tests might be a bit
|
||||||
; overkill, but better safe than sorry. :)
|
; overkill, but better safe than sorry. :)
|
||||||
|
|
||||||
|
; TODO: is there a better way to test that something is an instance of some object generated by reify?
|
||||||
|
(defn valid-function-handler? [x]
|
||||||
|
(and (not (nil? x))
|
||||||
|
(-> x
|
||||||
|
(class)
|
||||||
|
(.getName)
|
||||||
|
(.startsWith "clj_jtwig.core$add_function"))))
|
||||||
|
|
||||||
(deftest string-template
|
(deftest string-template
|
||||||
(testing "Evaluating templates in string vars"
|
(testing "Evaluating templates in string vars"
|
||||||
(is (= (render "Hello {{ name }}!"
|
(is (= (render "Hello {{ name }}!"
|
||||||
|
@ -123,7 +131,8 @@
|
||||||
(do
|
(do
|
||||||
(reset-functions!)
|
(reset-functions!)
|
||||||
|
|
||||||
(is (nil? (deftwigfn "add" [a b]
|
(is (valid-function-handler?
|
||||||
|
(deftwigfn "add" [a b]
|
||||||
(+ a b))))
|
(+ a b))))
|
||||||
|
|
||||||
(is (true? (function-exists? "add")))
|
(is (true? (function-exists? "add")))
|
||||||
|
@ -150,10 +159,12 @@
|
||||||
(do
|
(do
|
||||||
(reset-functions!)
|
(reset-functions!)
|
||||||
|
|
||||||
(is (nil? (deftwigfn "add2" [a b]
|
(is (valid-function-handler?
|
||||||
|
(deftwigfn "add2" [a b]
|
||||||
(+ a b))))
|
(+ a b))))
|
||||||
(is (true? (function-exists? "add2")))
|
(is (true? (function-exists? "add2")))
|
||||||
(is (nil? (deftwigfn "addAll" [& numbers]
|
(is (valid-function-handler?
|
||||||
|
(deftwigfn "addAll" [& numbers]
|
||||||
(apply + numbers))))
|
(apply + numbers))))
|
||||||
(is (true? (function-exists? "addAll")))
|
(is (true? (function-exists? "addAll")))
|
||||||
|
|
||||||
|
@ -176,10 +187,12 @@
|
||||||
(do
|
(do
|
||||||
(reset-functions!)
|
(reset-functions!)
|
||||||
|
|
||||||
(is (nil? (deftwigfn "identity" [x]
|
(is (valid-function-handler?
|
||||||
|
(deftwigfn "identity" [x]
|
||||||
x)))
|
x)))
|
||||||
(is (true? (function-exists? "identity")))
|
(is (true? (function-exists? "identity")))
|
||||||
(is (nil? (deftwigfn "typename" [x]
|
(is (valid-function-handler?
|
||||||
|
(deftwigfn "typename" [x]
|
||||||
(.getName (type x)))))
|
(.getName (type x)))))
|
||||||
(is (true? (function-exists? "typename")))
|
(is (true? (function-exists? "typename")))
|
||||||
|
|
||||||
|
|
Reference in a new issue