mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
* feat: Add additional ignore macros This commit adds two new ignore macros, ignore*, which wraps an arbitrary number of forms in calls to `ignore` and ignore-do, which wraps an arbitrary number of forms in ignore, then bundles the whole in a do call, effectively executing each form only for side effects and ignoring all results. * docs: Update ignore* docs Link to `ignore` doc Co-authored-by: Veit Heller <veit@veitheller.de> * fix: Call ignore* in ignore-do ignore-all was an old name that no longer exists! * test: Add test for ignore-do Co-authored-by: Veit Heller <veit@veitheller.de>
16 lines
381 B
Plaintext
16 lines
381 B
Plaintext
(load "Test.carp")
|
|
(use Test)
|
|
|
|
(def test-string @"")
|
|
|
|
(defn test-ignore-do []
|
|
(ignore-do (+ 2 2) ;; ignored
|
|
(set! test-string @"new-string") ;; ignored, but side-effect performed
|
|
(- 4 4)))
|
|
|
|
(deftest test
|
|
(assert-true test
|
|
(and (= () (test-ignore-do)) (= &test-string "new-string"))
|
|
"ignore-do performs side effects and ignores all results")
|
|
)
|