Carp/test/control_macros.carp
Scott Olsen c9967ddf6e
feat: Add additional ignore macros (#1300)
* 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>
2021-08-23 20:31:10 +02:00

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")
)