diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-10-29 20:22:40 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-10-29 20:22:40 +0300 |
| commit | c1db15d8d29ee900725d235016365f68d9d29721 (patch) | |
| tree | 0454ba4fed896627db13560f080228dfd1e7d60b /core_test.fnl | |
| parent | fd7f79aa10345307be0b02ead6300a2a83f73c89 (diff) | |
fix: fix get-in function and tests
Diffstat (limited to 'core_test.fnl')
| -rw-r--r-- | core_test.fnl | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/core_test.fnl b/core_test.fnl index d607935..c618e9e 100644 --- a/core_test.fnl +++ b/core_test.fnl @@ -433,13 +433,18 @@ (assert-eq (get {:key1 10 :key2 20} :key1) 10) (assert-eq (get {:key1 10 :key2 20} :key1 false) 10) (assert-eq (get {:key1 10 :key2 20} :key3 false) false) - (assert-eq (get {:key1 10 :key2 20} :key3) nil)) + (assert-eq (get {:key1 10 :key2 20} :key3) nil) + (assert* (not (pcall get))) + (assert* (not (pcall get {})))) - (testing get + (testing get-in (local t {:a {:b {:c 10}}}) - (assert-eq (get t [:a]) {:b {:c 10}}) - (assert-eq (get t [:a :b]) {:c 10}) - (assert-eq (get t [:a :b :c]) 10) - (assert-eq (get t [:a :b :c] false) 10) - (assert-eq (get t [:a :b :d] false) false) - (assert-eq (get t [:a :b :d]) nil))) + (assert-eq (get-in t [:a]) {:b {:c 10}}) + (assert-eq (get-in t [:a :b]) {:c 10}) + (assert-eq (get-in t [:a :b :c]) 10) + (assert-eq (get-in t [:a :b :c] false) 10) + (assert-eq (get-in t [:a :b :d] false) false) + (assert-eq (get-in t [:a :b :d]) nil) + (assert-eq (get-in t []) t) + (assert* (not (pcall get-in))) + (assert* (not (pcall get-in {}))))) |