diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-11-09 21:26:25 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-11-09 21:27:35 +0300 |
| commit | 1f88cd3b8eadeab2518519a97683067ec777eb6e (patch) | |
| tree | 605c188b6846b949b3df08a64a4ec2226ee46354 | |
| parent | c571f017a0d2c6ce750d97f00f493c48a1859ff3 (diff) | |
fix(testing): do not depend on eq from core
| -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] |