diff options
| -rw-r--r-- | test/fn.fnl | 2 | ||||
| -rw-r--r-- | test/macros.fnl | 2 | ||||
| -rw-r--r-- | test/test.fnl | 16 |
3 files changed, 16 insertions, 4 deletions
diff --git a/test/fn.fnl b/test/fn.fnl index 44e280d..aae0382 100644 --- a/test/fn.fnl +++ b/test/fn.fnl @@ -1,7 +1,5 @@ (require-macros :test.test) (require-macros :macros.core) -(local {: eq} (require :core)) ;; required for testing - (require-macros :macros.fn) (deftest fn* diff --git a/test/macros.fnl b/test/macros.fnl index 53de853..5b06c42 100644 --- a/test/macros.fnl +++ b/test/macros.fnl @@ -1,5 +1,5 @@ (require-macros :test.test) -(local {: eq : identity} (require :core)) ;; required for testing +(local {: identity} (require :core)) (require-macros :macros.core) diff --git a/test/test.fnl b/test/test.fnl index ff7c8bc..9ee23c1 100644 --- a/test/test.fnl +++ b/test/test.fnl @@ -1,5 +1,19 @@ (require-macros :macros.fn) -;; requires `eq' from core.fnl to be available at runtime + +(fn eq-fn [] + `(fn eq# [a# b#] + (if (and (= (type a#) :table) (= (type b#) :table)) + (do (var [res# count-a# count-b#] [true 0 0]) + (each [k# v# (pairs a#)] + (set res# (eq# v# (. b# k#))) + (set count-a# (+ count-a# 1)) + (when (not res#) (lua :break))) + (when res# + (each [_# _# (pairs b#)] + (set count-b# (+ count-b# 1))) + (set res# (and res# (= count-a# count-b#)))) + res#) + (= a# b#)))) (fn* assert-eq ([expr1 expr2] |