aboutsummaryrefslogtreecommitdiff
path: root/tests/let-env.scm
blob: 0fe775394bee0e4c9d6794942e4452e2b4d7bf88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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"))