OSDN Git Service

Android: add makefile and config.h
[android-x86/external-alsa-lib.git] / alsalisp / test.lisp
1 ;
2 ; Test code for all basic alsa lisp commands.
3 ; The test is indended to find memory leaks.
4 ;
5 ; Copyright (c) 2003 Jaroslav Kysela <perex@perex.cz>
6 ; License: GPL v2 (http://www.gnu.org/licenses/gpl.html)
7 ;
8
9 ;
10 ; Basic commands
11 ;
12
13 (!=)                            (&check-memory)
14 (!= 0)                          (&check-memory)
15 (!= 0 1)                        (&check-memory)
16 (!= 1 1)                        (&check-memory)
17 (!= 0 1 2)                      (&check-memory)
18 (!= 'aaaa 'bbbb)                (&check-memory)
19
20 (%)                             (&check-memory)
21 (% 11)                          (&check-memory)
22 (% 11 5)                        (&check-memory)
23 (% 11.5 5.1)                    (&check-memory)
24 (% 11.5 5.1 2.2)                (&check-memory)
25 (% 'aaaa 'bbbb)                 (&check-memory)
26
27 (&check-memory)                 (&check-memory)
28 (&check-memory "abcd")          (&check-memory)
29 (&dump-memory "-")              (&check-memory)
30 (&dump-memory)                  (&check-memory)
31 (&dump-objects "-")             (&check-memory)
32 (&dump-objects)                 (&check-memory)
33 (&stat-memory)                  (&check-memory)
34 (&stat-memory "abcd")           (&check-memory)
35
36 (*)                             (&check-memory)
37 (* 1)                           (&check-memory)
38 (* 1 2)                         (&check-memory)
39 (* 1.1 2.2)                     (&check-memory)
40 (* 1.1 2.2 3.3)                 (&check-memory)
41 (* 'aaaa)                       (&check-memory)
42
43 (+)                             (&check-memory)
44 (+ 1)                           (&check-memory)
45 (+ 1 2)                         (&check-memory)
46 (+ 1.1 2.2)                     (&check-memory)
47 (+ 1.1 2.2 3.3)                 (&check-memory)
48 (+ 'aaaa)                       (&check-memory)
49 (+ 'aaaa 'bbbb)                 (&check-memory)
50 (+ "aaaa")                      (&check-memory)
51 (+ "aaaa" "bbbb")               (&check-memory)
52 (+ "aaaa" "bbbb" "cccc")        (&check-memory)
53
54 (-)                             (&check-memory)
55 (- 1)                           (&check-memory)
56 (- 1 2)                         (&check-memory)
57 (- 1.1 2.2)                     (&check-memory)
58 (- 1.1 2.2 3.3)                 (&check-memory)
59 (- 'aaaa)                       (&check-memory)
60 (- 'aaaa 'bbbb)                 (&check-memory)
61
62 (/)                             (&check-memory)
63 (/ 1)                           (&check-memory)
64 (/ 1 2)                         (&check-memory)
65 (/ 1.1 2.2)                     (&check-memory)
66 (/ 1.1 2.2 3.3)                 (&check-memory)
67 (/ 'aaaa)                       (&check-memory)
68 (/ 'aaaa 'bbbb)                 (&check-memory)
69
70 (<)                             (&check-memory)
71 (< 0)                           (&check-memory)
72 (< 0 1)                         (&check-memory)
73 (< 1 0)                         (&check-memory)
74 (< 0 1 2)                       (&check-memory)
75
76 (<=)                            (&check-memory)
77 (<= 0)                          (&check-memory)
78 (<= 0 1)                        (&check-memory)
79 (<= 1 0)                        (&check-memory)
80 (<= 0 1 2)                      (&check-memory)
81
82 (=)                             (&check-memory)
83 (= 0)                           (&check-memory)
84 (= 0 1)                         (&check-memory)
85 (= 1 1)                         (&check-memory)
86 (= 0 1 2)                       (&check-memory)
87
88 (>)                             (&check-memory)
89 (> 0)                           (&check-memory)
90 (> 0 1)                         (&check-memory)
91 (> 1 0)                         (&check-memory)
92 (> 0 1 2)                       (&check-memory)
93
94 (>= 0)                          (&check-memory)
95 (>= 0 1)                        (&check-memory)
96 (>= 1 0)                        (&check-memory)
97 (>= 0 1 2)                      (&check-memory)
98
99 (and)                           (&check-memory)
100 (and 0)                         (&check-memory)
101 (and 1)                         (&check-memory)
102 (and 0 0 0)                     (&check-memory)
103
104 (quote a)                       (&check-memory)
105
106 (assoc)                                                 (&check-memory)
107 (assoc 'one)                                            (&check-memory)
108 (assoc 'one '((one . first)))                           (&check-memory)
109 (assoc 'one '((two . second)))                          (&check-memory)
110 (assoc 'one '((one . first) (two . second)))            (&check-memory)
111
112 (assq)                                                  (&check-memory)
113 (assq 'one)                                             (&check-memory)
114 (assq "one" '(("one" . "first")))                       (&check-memory)
115 (assq "one" '(("two" . "second")))                      (&check-memory)
116 (assq "one" '(("one" . "first") ("two" . "second")))    (&check-memory)
117
118 (atom)                          (&check-memory)
119 (atom 'one)                     (&check-memory)
120 (atom "one")                    (&check-memory)
121 (atom "one" 'two)               (&check-memory)
122
123 (funcall)                       (&check-memory)
124
125 (car)                           (&check-memory)
126 (car '(one . two))              (&check-memory)
127
128 (cdr)                           (&check-memory)
129 (cdr '(one . two))              (&check-memory)
130
131 (concat)                        (&check-memory)
132 (concat 'aaaa)                  (&check-memory)
133 (concat 'aaaa 'bbbb)            (&check-memory)
134 (concat "aaaa")                 (&check-memory)
135 (concat "aaaa" "bbbb")          (&check-memory)
136 (concat "aaaa" "bbbb" "cccc")   (&check-memory)
137
138 (cond)                          (&check-memory)
139 (cond 0)                        (&check-memory)
140 (cond 0 1)                      (&check-memory)
141 (cond 0 1 2)                    (&check-memory)
142 (cond 0 1 2 3)                  (&check-memory)
143 (cond (0 'a) (1 'b) (0 'd))     (&check-memory)
144 (cond 1)                        (&check-memory)
145 (cond 1 1)                      (&check-memory)
146 (cond 1 1 2)                    (&check-memory)
147 (cond 1 1 2 3)                  (&check-memory)
148
149 (cons)                          (&check-memory)
150 (cons "a")                      (&check-memory)
151 (cons "a" "b")                  (&check-memory)
152 (cons "a" "b" "c")              (&check-memory)
153
154 (eq)                            (&check-memory)
155 (eq 1)                          (&check-memory)
156 (eq 0 0)                        (&check-memory)
157 (eq "a" "b")                    (&check-memory)
158 (eq "a" "b" "c")                (&check-memory)
159
160 (equal)                         (&check-memory)
161 (equal 1)                       (&check-memory)
162 (equal 0 0)                     (&check-memory)
163 (equal "a" "b")                 (&check-memory)
164 (equal "a" "b" "c")             (&check-memory)
165
166 (exfun)                         (&check-memory)
167 (exfun 'abcd)                   (&check-memory)
168 (exfun 'abcd 'ijkl)             (&check-memory)
169
170 (format)                        (&check-memory)
171 (format 1)                      (&check-memory)
172 (format 'a)                     (&check-memory)
173 (format "a" "b" "c")            (&check-memory)
174 (format "1.2")                  (&check-memory)
175 (format "%c" 43)                (&check-memory)
176 (format "%d" 12)                (&check-memory)
177 (format "%i" 12)                (&check-memory)
178 (format "%f" 12.1)              (&check-memory)
179 (format "%s" "abcd")            (&check-memory)
180 (format "%s %i %i" "abcd" 1 2)  (&check-memory)
181
182 (garbage-collect)               (&check-memory)
183 (gc)                            (&check-memory)
184
185 (if)                            (&check-memory)
186 (if t)                          (&check-memory)
187 (if t 'a)                       (&check-memory)
188 (if t 'a 'b)                    (&check-memory)
189 (if nil)                        (&check-memory)
190 (if nil 'a)                     (&check-memory)
191 (if nil 'a 'b)                  (&check-memory)
192
193 (include "itest.lisp")          (&check-memory)
194
195 (list)                          (&check-memory)
196 (list "a")                      (&check-memory)
197 (list "a" "b")                  (&check-memory)
198 (list "a" "b" "c")              (&check-memory)
199
200 (not)                           (&check-memory)
201 (not 0)                         (&check-memory)
202 (not nil)                       (&check-memory)
203 (not t)                         (&check-memory)
204 (not 'a)                        (&check-memory)
205 (not 'a 'b 'c 'd)               (&check-memory)
206
207 (nth)                           (&check-memory)
208 (nth 2)                         (&check-memory)
209 (nth 2 nil)                     (&check-memory)
210 (nth 2 '(('one 'two 'three)))   (&check-memory)
211
212 (null)                          (&check-memory)
213 (null 0)                        (&check-memory)
214 (null nil)                      (&check-memory)
215 (null t)                        (&check-memory)
216 (null 'a)                       (&check-memory)
217 (null 'a 'b 'c 'd)              (&check-memory)
218
219 (or)                            (&check-memory)
220 (or 0)                          (&check-memory)
221 (or 1)                          (&check-memory)
222 (or 0 0 0)                      (&check-memory)
223
224 (path)                          (&check-memory)
225 (path 0)                        (&check-memory)
226 (path 1)                        (&check-memory)
227 (path 0 0 0)                    (&check-memory)
228 (path "data")                   (&check-memory)
229
230 (princ)                         (&check-memory)
231 (princ "\nabcd\n")              (&check-memory)
232 (princ "a" "b" "c\n")           (&check-memory)
233
234 (prog1)                         (&check-memory)
235 (prog1 1)                       (&check-memory)
236 (prog1 1 2 3 4)                 (&check-memory)
237
238 (prog2)                         (&check-memory)
239 (prog2 1)                       (&check-memory)
240 (prog2 1 2 3 4)                 (&check-memory)
241
242 (progn)                         (&check-memory)
243 (progn 1)                       (&check-memory)
244 (progn 1 2 3 4)                 (&check-memory)
245
246 (quote)                         (&check-memory)
247 (quote a)                       (&check-memory)
248
249 (rassoc)                                                (&check-memory)
250 (rassoc 'first)                                         (&check-memory)
251 (rassoc 'first '((one . first)))                        (&check-memory)
252 (rassoc 'first '((two . second)))                       (&check-memory)
253 (rassoc 'first '((one . first) (two . second)))         (&check-memory)
254
255 (rassq)                                                 (&check-memory)
256 (rassq "first")                                         (&check-memory)
257 (rassq "first" '(("one" . "first")))                    (&check-memory)
258 (rassq "first" '(("two" . "second")))                   (&check-memory)
259 (rassq "first" '(("one" . "first") ("two" . "second"))) (&check-memory)
260
261 (set)                           (&check-memory)
262 (set "a") (unset "a")           (&check-memory)
263 (set "a" 1) (unset "a")         (&check-memory)
264 (set a 1) (unset a)             (&check-memory)
265 (set "a" 1 2) (unset "a")       (&check-memory)
266
267 (setf)                          (&check-memory)
268 (setf a) (unsetf a)             (&check-memory)
269 (setf a 1) (unsetf a)           (&check-memory)
270 (setf a 1 2) (unsetf a)         (&check-memory)
271
272 (setq)                          (&check-memory)
273 (setq a) (unsetq a)             (&check-memory)
274 (setq a 1) (unsetq a)           (&check-memory)
275 (setq a 1 2) (unsetq a)         (&check-memory)
276
277 (string-equal)                  (&check-memory)
278 (string-equal 1)                (&check-memory)
279 (string-equal "a")              (&check-memory)
280 (string-equal "a" "a")          (&check-memory)
281 (string-equal "a" "b")          (&check-memory)
282 (string-equal "a" "b" "c")      (&check-memory)
283
284 (string-to-integer)             (&check-memory)
285 (string-to-integer 1)           (&check-memory)
286 (string-to-integer 1.5)         (&check-memory)
287 (string-to-integer "a")         (&check-memory)
288 (string-to-integer "a" "a")     (&check-memory)
289 (string-to-integer "a" "b")     (&check-memory)
290 (string-to-integer "a" "b" "c") (&check-memory)
291
292 (string-to-float)               (&check-memory)
293 (string-to-float 1)             (&check-memory)
294 (string-to-float 1.5)           (&check-memory)
295 (string-to-float "a")           (&check-memory)
296 (string-to-float "a" "a")       (&check-memory)
297 (string-to-float "a" "b")       (&check-memory)
298 (string-to-float "a" "b" "c")   (&check-memory)
299
300 (string=)                       (&check-memory)
301 (string= 1)                     (&check-memory)
302 (string= "a")                   (&check-memory)
303 (string= "a" "a")               (&check-memory)
304 (string= "a" "b")               (&check-memory)
305 (string= "a" "b" "c")           (&check-memory)
306
307 (unless)                        (&check-memory)
308 (unless 1)                      (&check-memory)
309 (unless 0 1 2)                  (&check-memory)
310 (unless t 2 3 4)                (&check-memory)
311 (unless nil 2 3 4)              (&check-memory)
312
313 (unset)                         (&check-memory)
314 (unset "a")                     (&check-memory)
315
316 (unsetf)                        (&check-memory)
317 (unsetf a)                      (&check-memory)
318 (unsetf a b)                    (&check-memory)
319
320 (unsetq)                        (&check-memory)
321 (unsetq a)                      (&check-memory)
322 (unsetq a b)                    (&check-memory)
323
324 (when)                          (&check-memory)
325 (when 0)                        (&check-memory)
326 (when 0 1)                      (&check-memory)
327 (when t 1)                      (&check-memory)
328 (when nil 1)                    (&check-memory)
329
330 (while)                         (&check-memory)
331 (while nil)                     (&check-memory)
332 (while nil 1)                   (&check-memory)
333 (while nil 1 2 3 4)             (&check-memory)
334
335 ;
336 ; more complex command sequences
337 ;
338
339 (setq abcd "abcd")
340 (unsetq abcd)
341 (&check-memory)
342
343 (setq abcd (("abcd" . "efgh") ("1234" . "5678")))
344 (unsetq abcd)
345 (&check-memory)
346
347 (defun myfun () (princ "a\n"))
348 (exfun 'myfun)
349 (unsetq myfun)
350 (&check-memory)
351
352 (defun myfun () (princ "a\n"))
353 (funcall 'myfun)
354 (funcall 'myfun 'aaaaa)
355 (unsetq myfun)
356 (&check-memory)
357
358 (defun myfun (o) (princ o "a\n"))
359 (funcall 'myfun)
360 (funcall 'myfun 'aaaaa)
361 (unsetq myfun)
362 (&check-memory)
363
364 (defun myfun (o p) (princ o p "\n"))
365 (funcall 'myfun)
366 (funcall 'myfun 'aaaaa)
367 (funcall 'myfun 'aaaaa 'bbbbb)
368 (unsetq myfun)
369 (&check-memory)
370
371 (defun printnum (from to) (while (<= from to) (princ " " from) (setq from (+ from 1))))
372 (princ "Numbers 1-10:") (printnum 1 10) (princ "\n")
373 (unsetq printnum)
374
375 ;
376 ; game over
377 ;
378
379 (princ "*********************\n")
380 (princ "OK, all tests passed!\n")
381 (princ "*********************\n")
382 (&stat-memory)