summaryrefslogtreecommitdiff
path: root/tests/core.fnl
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-11-13 22:54:12 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-11-13 22:54:12 +0300
commit1b309ac016d806d2f9b44540ed5020f5c60c4256 (patch)
treefca18ab2e0153a1462da473cd2fe5c9cc0de6a69 /tests/core.fnl
parent8493fa29b1848bf93e899e8930c6e8c1c723eece (diff)
fix(core): refactoring
- Rename `fn*` to `defn`, `fn&` to `fn+`. - Do not use `fn+` in the core at all, provide it for convenience. - Fix bug in `filter` due to incorrect `cons` implementation. - Update `seq` and `eq` functions in macros
Diffstat (limited to 'tests/core.fnl')
-rw-r--r--tests/core.fnl18
1 files changed, 6 insertions, 12 deletions
diff --git a/tests/core.fnl b/tests/core.fnl
index 992627d..ae7b3b4 100644
--- a/tests/core.fnl
+++ b/tests/core.fnl
@@ -54,12 +54,6 @@
(assert-ne a b))
(assert-eq [1 2 3] {1 1 2 2 3 3})
-
- ;; TODO: decide if this is right or not. Looking from `seq'
- ;; perspective, it is correct, as `(seq {4 1})' and `(seq [nil nil
- ;; nil 1])' both yield `{4 1}'. From Lua's point this is not the
- ;; same thing, for example because the sizes of these tables are
- ;; different.
(assert-eq {4 1} [nil nil nil 1]))
(testing "eq metadata preservation"
@@ -214,7 +208,7 @@
(assert-eq (table.concat (mapv string.upper "vaiv")) "VAIV"))
(testing "reduce"
- (fn* add
+ (defn add
([] 0)
([a] a)
([a b] (+ a b))
@@ -241,12 +235,12 @@
(fn [result input]
(reducing result (f input)))))
- (fn reduce- [f init [x & tbl]]
- (if x (reduce- f (f init x) tbl) init))
+ (fn -reduce [f init [x & tbl]]
+ (if x (-reduce f (f init x) tbl) init))
- (assert-eq (reduce add (range 10)) (reduce- add 0 (range 10)))
+ (assert-eq (reduce add (range 10)) (-reduce add 0 (range 10)))
(assert-eq (reduce ((mapping inc) add) 0 (range 10))
- (reduce- ((mapping inc) add) 0 (range 10))))
+ (-reduce ((mapping inc) add) 0 (range 10))))
(testing "filter"
(assert-not (pcall filter))
@@ -346,7 +340,7 @@
(assert* ((complement #(= $1 $2)) 1 2)))
(testing "apply"
- (fn* add
+ (defn add
([x] x)
([x y] (+ x y))
([x y & zs]