mirror of
https://github.com/janet-lang/janet
synced 2025-10-22 11:17:40 +00:00
Add with-vars
This helps for temporarily setting vars in a safe manner that is guaranteed not to leave vars in a bad state (assuming that a fiber does not emit debug or use signal and is never resumed).
This commit is contained in:
@@ -184,4 +184,10 @@
|
||||
|
||||
(assert (= (string '()) (string [])) "empty bracket tuple literal")
|
||||
|
||||
# with-vars
|
||||
(var abc 123)
|
||||
(assert (= 356 (with-vars [abc 456] (- abc 100))) "with-vars 1")
|
||||
(assert-error "with-vars 2" (with-vars [abc 456] (error :oops)))
|
||||
(assert (= abc 123) "with-vars 3")
|
||||
|
||||
(end-suite)
|
||||
|
Reference in New Issue
Block a user