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 /test/test.fnl | |
| parent | c571f017a0d2c6ce750d97f00f493c48a1859ff3 (diff) | |
fix(testing): do not depend on eq from core
Diffstat (limited to 'test/test.fnl')
| -rw-r--r-- | test/test.fnl | 16 |
1 files changed, 15 insertions, 1 deletions
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] |