Commit | Line | Data |
---|---|---|
04bb321a NJ |
1 | ;;;; elisp.test --- tests guile's elisp support -*- scheme -*- |
2 | ;;;; Copyright (C) 2002 Free Software Foundation, Inc. | |
3 | ;;;; | |
4 | ;;;; This program is free software; you can redistribute it and/or modify | |
5 | ;;;; it under the terms of the GNU General Public License as published by | |
6 | ;;;; the Free Software Foundation; either version 2, or (at your option) | |
7 | ;;;; any later version. | |
8 | ;;;; | |
9 | ;;;; This program is distributed in the hope that it will be useful, | |
10 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | ;;;; GNU General Public License for more details. | |
13 | ;;;; | |
14 | ;;;; You should have received a copy of the GNU General Public License | |
15 | ;;;; along with this software; see the file COPYING. If not, write to | |
16 | ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
17 | ;;;; Boston, MA 02111-1307 USA | |
18 | ;;;; | |
19 | ;;;; As a special exception, the Free Software Foundation gives permission | |
20 | ;;;; for additional uses of the text contained in its release of GUILE. | |
21 | ;;;; | |
22 | ;;;; The exception is that, if you link the GUILE library with other files | |
23 | ;;;; to produce an executable, this does not by itself cause the | |
24 | ;;;; resulting executable to be covered by the GNU General Public License. | |
25 | ;;;; Your use of that executable is in no way restricted on account of | |
26 | ;;;; linking the GUILE library code into it. | |
27 | ;;;; | |
28 | ;;;; This exception does not however invalidate any other reasons why | |
29 | ;;;; the executable file might be covered by the GNU General Public License. | |
30 | ;;;; | |
31 | ;;;; This exception applies only to the code released by the | |
32 | ;;;; Free Software Foundation under the name GUILE. If you copy | |
33 | ;;;; code from other Free Software Foundation releases into a copy of | |
34 | ;;;; GUILE, as the General Public License permits, the exception does | |
35 | ;;;; not apply to the code that you add in this way. To avoid misleading | |
36 | ;;;; anyone as to the status of such modified files, you must delete | |
37 | ;;;; this exception notice from them. | |
38 | ;;;; | |
39 | ;;;; If you write modifications of your own for GUILE, it is your choice | |
40 | ;;;; whether to permit this exception to apply to your modifications. | |
41 | ;;;; If you do not wish that, delete this exception notice. | |
42 | ||
43 | ;;; | |
44 | ;;; elisp | |
45 | ;;; | |
46 | ||
47 | (if (defined? '%nil) | |
48 | ||
49 | (with-test-prefix "scheme" | |
50 | ||
51 | (with-test-prefix "nil value is a boolean" | |
52 | ||
53 | (pass-if "boolean?" | |
54 | (boolean? %nil)) | |
55 | ||
56 | ) | |
57 | ||
58 | (with-test-prefix "nil value is false" | |
59 | ||
60 | (pass-if "not" | |
61 | (eq? (not %nil) #t)) | |
62 | ||
63 | (pass-if "if" | |
64 | (if %nil #f #t)) | |
65 | ||
66 | (pass-if "and" | |
67 | (eq? (and %nil #t) #f)) | |
68 | ||
69 | (pass-if "or" | |
70 | (eq? (or %nil #f) #f)) | |
71 | ||
72 | (pass-if "cond" | |
73 | (cond (%nil #f) (else #t))) | |
74 | ||
75 | (pass-if "do" | |
76 | (call-with-current-continuation | |
77 | (lambda (exit) | |
78 | (do ((i 0 (+ i 1))) | |
79 | (%nil (exit #f)) | |
80 | (if (> i 10) | |
81 | (exit #t)))))) | |
82 | ||
83 | ) | |
84 | ||
85 | (with-test-prefix "nil value as an empty list" | |
86 | ||
87 | (pass-if "list?" | |
88 | (list? %nil)) | |
89 | ||
90 | (pass-if "null?" | |
91 | (null? %nil)) | |
92 | ||
93 | (pass-if "sort" | |
94 | (eq? (sort %nil <) %nil)) | |
95 | ||
96 | ) | |
97 | ||
98 | (with-test-prefix "lists formed using nil value" | |
99 | ||
100 | (pass-if "list?" | |
101 | (list? (cons 'a %nil))) | |
102 | ||
103 | (pass-if "length" | |
104 | (= (length (cons 'a (cons 'b (cons 'c %nil)))) 3)) | |
105 | ||
106 | (pass-if "length (with backquoted list)" | |
107 | (= (length `(a b c . ,%nil)) 3)) | |
108 | ||
109 | (pass-if "write" | |
110 | (string=? (with-output-to-string | |
111 | (lambda () (write (cons 'a %nil)))) | |
112 | "(a)")) | |
113 | ||
114 | (pass-if "display" | |
115 | (string=? (with-output-to-string | |
116 | (lambda () (display (cons 'a %nil)))) | |
117 | "(a)")) | |
118 | ||
119 | ) | |
120 | ||
121 | (with-test-prefix "value preservation" | |
122 | ||
123 | (pass-if "car" | |
124 | (eq? (car (cons %nil 'a)) %nil)) | |
125 | ||
126 | (pass-if "cdr" | |
127 | (eq? (cdr (cons 'a %nil)) %nil)) | |
128 | ||
129 | (pass-if "vector-ref" | |
130 | (eq? (vector-ref (vector %nil) 0) %nil)) | |
131 | ||
132 | ) | |
133 | ||
134 | )) | |
135 | ||
136 | ;;; elisp.test ends here |