diff options
| -rw-r--r-- | .depend.mk | 3 | ||||
| -rw-r--r-- | .editorconfig | 14 | ||||
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | core.fnl | 4 | ||||
| -rw-r--r-- | core_test.fnl | 9 |
5 files changed, 33 insertions, 6 deletions
diff --git a/.depend.mk b/.depend.mk new file mode 100644 index 0000000..72048aa --- /dev/null +++ b/.depend.mk @@ -0,0 +1,3 @@ +core.lua: core.fnl macros/core.fnl macros/fn.fnl +core_test.lua: core_test.fnl macros/core.fnl macros/fn.fnl +macros_test.lua: macros_test.fnl macros/core.fnl macros/fn.fnl diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..14919c3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# Cross-editor formatting rules +# see: https://editorconfig.org + +root = true + +[*] +charset=utf-8 +end_of_line=lf +insert_final_newline=true +trim_trailing_whitespace=true + +[*.lua] +indent_size=4 +indent_style=space @@ -13,9 +13,12 @@ ${LUASOURCES}: $(FNLSOURCES) fennel --lua $(LUA) --compile $< > $@ clean: - rm -f *.lua luacov* + rm -f *.lua -test: +clean-all: clean + rm -f luacov* + +test: clean @fennel --lua $(LUA) core_test.fnl @fennel --lua $(LUA) macros_test.fnl @@ -39,3 +42,5 @@ help: @echo "make luacov -- build coverage report (requires working tests)" >&2 @echo "make luacov-console -- build coverage report (requires working tests)" >&2 @echo "make help -- print this message and exit" >&2 + +-include .depend.mk @@ -380,8 +380,8 @@ oppisite truth value." (when-some [tbl (seq tbl)] (reduce -consj [] tbl))) -(fn& core.inc [x] (+ x 1)) -(fn& core.dec [x] (- x 1)) +(fn* core.inc "Increase number by one" [x] (+ x 1)) +(fn* core.dec "Decrease number by one" [x] (- x 1)) (fn* core.assoc "Associate key `k' with value `v' in `tbl'." diff --git a/core_test.fnl b/core_test.fnl index c618e9e..25f9e1d 100644 --- a/core_test.fnl +++ b/core_test.fnl @@ -423,10 +423,15 @@ (deftest math-functions (testing inc (assert-eq (inc 1) 2) - (assert-eq (inc -1) 0)) + (assert-eq (inc -1) 0) + (assert* (not (pcall inc))) + (assert* (not (pcall inc nil)))) + (testing dec (assert-eq (dec 1) 0) - (assert-eq (dec -1) -2))) + (assert-eq (dec -1) -2) + (assert* (not (pcall dec))) + (assert* (not (pcall dec nil))))) (deftest table-access (testing get |