aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-20 23:06:02 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-20 23:06:02 +0100
commitbc703eef01c912962a502fa676560b2c200d90ca (patch)
treeef56882c97157d59a6cac7447d5bbb6927ae482d /tests
parentfind-extreme on empty list now an error. (diff)
downloadcalp-bc703eef01c912962a502fa676560b2c200d90ca.tar.gz
calp-bc703eef01c912962a502fa676560b2c200d90ca.tar.xz
let-env now handles non-local exits correctly.
Diffstat (limited to 'tests')
-rw-r--r--tests/let-env.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/let-env.scm b/tests/let-env.scm
new file mode 100644
index 00000000..0fe77539
--- /dev/null
+++ b/tests/let-env.scm
@@ -0,0 +1,22 @@
+(((guile) setenv getenv)
+ ((calp util) let-env))
+
+(setenv "CALP_TEST_ENV" "1")
+(test-equal "Ensure we have set value beforehand"
+ "1" (getenv "CALP_TEST_ENV"))
+(let-env ((CALP_TEST_ENV "2"))
+ (test-equal "Test our local override"
+ "2" (getenv "CALP_TEST_ENV")))
+(test-equal "Test that we have returned"
+ "1" (getenv "CALP_TEST_ENV"))
+
+(catch 'test-error
+ (lambda ()
+ (let-env ((CALP_TEST_ENV "2"))
+ (test-equal "Test our local override again"
+ "2" (getenv "CALP_TEST_ENV"))
+ (throw 'test-error)))
+ list)
+
+(test-equal "Test restoration after non-local exit"
+ "1" (getenv "CALP_TEST_ENV"))