1 ;;;; slib.test --- Test suite for Guile's SLIB glue. -*- scheme -*-
3 ;;;; Copyright 2003, 2004 Free Software Foundation, Inc.
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 ;;;; Boston, MA 02110-1301 USA
20 ;; These tests are run only if slib is available. slib will need to be
21 ;; installed (or linked) under the configured guile $prefix.
24 (lambda () (resolve-module '(ice-9 slib)))
28 (define-module (test-suite test-ice-9-slib)
29 #:use-module (test-suite lib)
30 #:use-module (ice-9 slib))
33 (with-test-prefix "Configuration"
39 (with-test-prefix "char-code-limit"
40 (pass-if "integer" (integer? char-code-limit)))
43 ;; most-positive-fixnum
46 (with-test-prefix "most-positive-fixnum"
47 (pass-if "integer" (integer? most-positive-fixnum)))
53 (with-test-prefix "slib:form-feed"
54 ;; in guile 1.6.4 this wasn't exported
55 (pass-if "char" (char? slib:form-feed)))
61 (with-test-prefix "slib:report"
62 (pass-if "exists" (procedure? slib:report)))
65 ;; slib:report-version
68 (with-test-prefix "slib:report-version"
69 (pass-if "exists" (procedure? slib:report-version)))
75 (with-test-prefix "slib:tab"
76 ;; in guile 1.6.4 this wasn't exported
77 (pass-if "char" (char? slib:tab)))
83 (with-test-prefix "software-type"
84 (pass-if "exists" (procedure? software-type))))
87 (with-test-prefix "Input/Output"
90 ;; call-with-open-ports
93 (with-test-prefix "call-with-open-ports"
94 (pass-if "exists" (procedure? call-with-open-ports))
96 (pass-if "close on return"
97 (let ((port (open-input-file "/dev/null")))
98 (call-with-open-ports port (lambda (port) #f))
99 (port-closed? port))))
105 ;; in guile 1.6.4 and earlier delete-file didn't match the slib spec
106 (with-test-prefix "delete-file"
107 (pass-if "non existant file"
108 (eq? #f (delete-file "nosuchfile")))
109 (pass-if "existing file"
110 (call-with-output-file "slibtest.tmp" noop)
111 (eq? #t (delete-file "slibtest.tmp"))))
114 ;; output-port-height
117 (with-test-prefix "output-port-height"
118 ;; in guile 1.6.4 this wasn't exported
119 (pass-if "exists" (procedure? output-port-height)))
125 (with-test-prefix "output-port-width"
126 ;; in guile 1.6.4 this wasn't exported
127 (pass-if "exists" (procedure? output-port-width)))
133 ;; this style open-file is only a requirement in slib 3a1 and up, but
134 ;; we provide it always
135 (with-test-prefix "open-file"
136 (pass-if "r" (port? (open-file "/dev/null" 'r)))
137 (pass-if "rb" (port? (open-file "/dev/null" 'rb)))
138 (pass-if "w" (port? (open-file "/dev/null" 'w)))
139 (pass-if "wb" (port? (open-file "/dev/null" 'wb)))))
142 (with-test-prefix "System stuff"
148 (with-test-prefix "browse-url"
149 (pass-if "exists" (procedure? browse-url)))
155 (with-test-prefix "slib:error"
156 ;; in guile 1.6.4 this wasn't exported
157 (pass-if "exists" (procedure? slib:error)))
163 (with-test-prefix "slib:eval"
164 ;; in guile 1.6.4 this wasn't exported
165 (pass-if "exists" (procedure? slib:eval)))
171 (with-test-prefix "slib:eval-load"
172 ;; in guile 1.6.4 this wasn't exported
173 (pass-if "exists" (procedure? slib:eval-load)))
179 (with-test-prefix "slib:exit"
180 ;; in guile 1.6.4 this wasn't exported
181 (pass-if "exists" (procedure? slib:exit)))
187 (with-test-prefix "slib:load"
188 (pass-if "exists" (procedure? slib:load)))
194 (with-test-prefix "slib:load-source"
195 ;; in guile 1.6.4 this wasn't exported
196 (pass-if "exists" (procedure? slib:load-source)))
202 (with-test-prefix "slib:warn"
203 ;; in guile 1.6.4 this wasn't exported
204 (pass-if "exists" (procedure? slib:warn))))
207 (with-test-prefix "Miscellany"
213 (with-test-prefix "identity"
214 (pass-if "exists" (procedure? identity)))
216 (with-test-prefix "Legacy"
222 ;; in guile 1.6.4 and earlier this was missing
223 (with-test-prefix "nil"
224 (pass-if "value" (eq? #f nil)))
230 ;; in guile 1.6.4 and earlier this was missing
231 (with-test-prefix "t"
232 (pass-if "value" (eq? #t t)))))
239 ;; in guile 1.6.4 the 'rev2-procedures feature we defined claimed
240 ;; these existed, but they didn't
241 (with-test-prefix "rev2-procedures"
242 (require 'rev2-procedures)
243 (pass-if "-1+" (procedure? -1+))
244 (pass-if "<?" (procedure? <?))
245 (pass-if "<=?" (procedure? <=?))
246 (pass-if "=?" (procedure? =?))
247 (pass-if ">?" (procedure? >?))
248 (pass-if ">=?" (procedure? >=?)))
255 ;; in guile 1.6.4 and earlier system didn't match the slib spec
256 (with-test-prefix "system"
257 (pass-if "exit 0" (= 0 (system "exit 0")))
258 (pass-if "exit 1" (= 1 (system "exit 1")))
259 (pass-if "exit 99" (= 99 (system "exit 99"))))
262 (with-test-prefix "Time"
268 (with-test-prefix "difftime"
269 ;; in guile 1.6.4 this wasn't exported
270 (pass-if "exists" (procedure? difftime)))
276 (with-test-prefix "offset-time"
277 ;; in guile 1.6.4 this wasn't exported
278 (pass-if "exists" (procedure? offset-time))))
282 (with-test-prefix "array"
288 ;; create-array isn't in old slib, but when it exists it should work
289 (if (defined? 'create-array)
290 (with-test-prefix "create-array"
291 (pass-if "As32 create"
292 (array? (create-array (As32 0) '(0 1)))))))))