source: trunk/source/tests/ansi-tests/list-length.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 22:03:01 2003
4;;;; Contains: Tests of LIST-LENGTH
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest list-length-nil
11  (list-length nil)
12  0)
13
14(deftest list-length-list
15  (list-length '(a b c d e f))
16  6)
17
18;; check that list-length returns nil
19;; on a circular list
20
21(deftest list-length-circular-list
22  (let ((x (cons nil nil)))
23    (let ((y (list* 1 2 3 4 5 6 7 8 9 x)))
24      (setf (cdr x) y)
25      (let ((z (list* 'a 'b 'c 'd 'e y)))
26        (list-length z))))
27  nil)
28
29(deftest list-length.order.1
30  (let ((i 0))
31    (values (list-length (progn (incf i) '(a b c))) i))
32  3 1)
33
34
35(deftest list-length.4
36  (list-length (copy-tree '(a b c)))
37  3)
38
39;; Check that list-length produces a type-error
40;; on arguments that are not proper lists or circular lists
41
42(deftest list-length.error.1
43  (loop
44   for x in (list 'a 1 1.0 #\w (make-array '(10))
45                  '(a b . c) (symbol-package 'cons))
46   count (not (eval `(signals-type-error x ',x (list-length x)))))
47  0)
48
49(deftest list-length.error.2
50  (signals-error (list-length) program-error)
51  t)
52
53(deftest list-length.error.3
54  (signals-error (list-length nil nil) program-error)
55  t)
56
57(deftest list-length.error.4
58  (signals-error (list-length 'a) type-error)
59  t)
60
61(deftest list-length.error.5
62  (signals-error (locally (list-length 'a) t) type-error)
63  t)
64
65(deftest list-length-symbol
66  (signals-error (list-length 'a) type-error)
67  t)
68
69(deftest list-length-dotted-list
70  (signals-error (list-length (copy-tree '(a b c d . e))) type-error)
71  t)
Note: See TracBrowser for help on using the repository browser.