diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-11-02 21:43:46 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-11-02 21:43:46 +0300 |
| commit | d7ebb3e607da6444d8215b1ee273c4247489f862 (patch) | |
| tree | 343392e6e5a081bd980fd865f2d54d9fbac8bb9e /macros_test.fnl | |
| parent | 9878bb3f75db689e44f0b11cef926c7a39bc6dd5 (diff) | |
feature(macros): add def and defonce macros
Diffstat (limited to 'macros_test.fnl')
| -rw-r--r-- | macros_test.fnl | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/macros_test.fnl b/macros_test.fnl index 8da9e7f..b8556e8 100644 --- a/macros_test.fnl +++ b/macros_test.fnl @@ -1,4 +1,4 @@ -(import-macros {: if-let : when-let : if-some : when-some : into : defmethod : defmulti} :macros.core) +(import-macros {: if-let : when-let : if-some : when-some : into : defmethod : defmulti : defonce : def} :macros.core) (import-macros {: assert-eq : assert-ne : assert* : testing : deftest} :test) (local {: eq : identity} (require :core)) ;; required for testing @@ -91,3 +91,23 @@ "sending ваыв over HTTP") (assert-eq (send-message {:protocol :icap :message 42}) "sending 42 over ICAP"))) + +(deftest def-macros + (testing def + (def a 10) + (assert-eq a 10) + (def a {}) + (assert-eq a {}) + (def a.b 10) + (assert-eq a.b 10) + (assert-eq b 10)) + + (testing defonce + (defonce a 10) + (assert-eq a 10) + (defonce a {}) + (assert-eq a 10) + (defonce b {}) + (defonce b.a 10) + (assert-eq b.a 10) + (assert-eq a 10))) |