Commit | Line | Data |
---|---|---|
0d2cf5b5 KR |
1 | ;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*- |
2 | ;;;; | |
3 | ;;;; Copyright 2003 Free Software Foundation, Inc. | |
4 | ;;;; | |
5 | ;;;; This program is free software; you can redistribute it and/or modify | |
6 | ;;;; it under the terms of the GNU General Public License as published by | |
7 | ;;;; the Free Software Foundation; either version 2, or (at your option) | |
8 | ;;;; any later version. | |
9 | ;;;; | |
10 | ;;;; This program is distributed in the hope that it will be useful, | |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ;;;; GNU General Public License for more details. | |
14 | ;;;; | |
15 | ;;;; You should have received a copy of the GNU General Public License | |
16 | ;;;; along with this software; see the file COPYING. If not, write to | |
17 | ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
18 | ;;;; Boston, MA 02111-1307 USA | |
19 | ||
20 | (use-modules (test-suite lib)) | |
21 | ||
22 | ||
23 | ;; | |
24 | ;; putenv | |
25 | ;; | |
26 | ||
27 | (with-test-prefix "putenv" | |
28 | ||
29 | (pass-if "something" | |
30 | (putenv "FOO=something") | |
31 | (equal? "something" (getenv "FOO"))) | |
32 | ||
33 | (pass-if "replacing" | |
34 | (putenv "FOO=one") | |
35 | (putenv "FOO=two") | |
36 | (equal? "two" (getenv "FOO"))) | |
37 | ||
38 | (pass-if "empty" | |
39 | (putenv "FOO=") | |
40 | (equal? "" (getenv "FOO"))) | |
41 | ||
42 | (pass-if "removing" | |
43 | (putenv "FOO=bar") | |
44 | (putenv "FOO") | |
45 | (not (getenv "FOO"))) | |
46 | ||
47 | (pass-if "modifying string doesn't change env" | |
48 | (let ((s (string-copy "FOO=bar"))) | |
49 | (putenv s) | |
50 | (string-set! s 5 #\x) | |
51 | (equal? "bar" (getenv "FOO"))))) | |
52 | ||
53 | ;; | |
54 | ;; setenv | |
55 | ;; | |
56 | ||
57 | (with-test-prefix "setenv" | |
58 | ||
59 | (pass-if "something" | |
60 | (setenv "FOO" "something") | |
61 | (equal? "something" (getenv "FOO"))) | |
62 | ||
63 | (pass-if "replacing" | |
64 | (setenv "FOO" "one") | |
65 | (setenv "FOO" "two") | |
66 | (equal? "two" (getenv "FOO"))) | |
67 | ||
68 | (pass-if "empty" | |
69 | (setenv "FOO" "") | |
70 | (equal? "" (getenv "FOO"))) | |
71 | ||
72 | (pass-if "removing" | |
73 | (setenv "FOO" "something") | |
74 | (setenv "FOO" #f) | |
75 | (not (getenv "FOO")))) | |
76 | ||
77 | ;; | |
78 | ;; unsetenv | |
79 | ;; | |
80 | ||
81 | (with-test-prefix "unsetenv" | |
82 | ||
83 | (pass-if "something" | |
84 | (putenv "FOO=something") | |
85 | (unsetenv "FOO") | |
86 | (not (getenv "FOO"))) | |
87 | ||
88 | (pass-if "empty" | |
89 | (putenv "FOO=") | |
90 | (unsetenv "FOO") | |
91 | (not (getenv "FOO")))) |