1
;;;; symbols.test --- test suite for Guile's symbols -*- scheme -*-
3
;;;; Copyright (C) 2001, 2006 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
(use-modules (ice-9 documentation))
27
;; FIXME: As soon as guile supports immutable strings, this has to be
28
;; replaced with the appropriate error type and message.
29
(define exception:immutable-string
30
(cons 'some-error-type "^trying to modify an immutable string"))
32
(define (documented? object)
33
(not (not (object-documentation object))))
40
(with-test-prefix "symbol?"
42
(pass-if "documented?"
43
(documented? symbol?))
46
(not (symbol? "foo")))
56
(with-test-prefix "symbol->string"
58
(expect-fail-exception "result is an immutable string"
59
exception:immutable-string
60
(string-set! (symbol->string 'abc) 1 #\space)))
67
(with-test-prefix "gensym"
69
(pass-if "documented?"
72
(pass-if "produces a symbol"
75
(pass-if "produces a fresh symbol"
76
(not (eq? (gensym) (gensym))))
78
(pass-if "accepts a string prefix"
79
(symbol? (gensym "foo")))
81
(pass-if-exception "does not accept a symbol prefix"
82
exception:wrong-type-arg
85
(pass-if "accepts long prefices"
86
(symbol? (gensym (make-string 4000 #\!))))
88
(pass-if "accepts embedded NULs"
89
(> (string-length (symbol->string (gensym "foo\0bar\0braz\0foo\0bar\0braz\0foo\0bar\0braz\0foo\0bar\0braz\0foo\0bar\0braz\0foo\0bar\0braz\0"))) 6)))