source: trunk/source/tests/ansi-tests/nconc.lsp @ 8991

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

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

File size: 1.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 22:35:53 2003
4;;;; Contains: Tests of NCONC
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest nconc.1
11  (nconc)
12  nil)
13
14(deftest nconc.2
15  (nconc (copy-tree '(a b c d e f)))
16  (a b c d e f))
17
18;;; (deftest nconc.3
19;;;  (nconc 1)
20;;;  1)
21
22(deftest nconc.4
23  (let ((x (list 'a 'b 'c))
24        (y (list 'd 'e 'f)))
25    (let ((ycopy (make-scaffold-copy y)))
26      (let ((result (nconc x y)))
27        (and
28         (check-scaffold-copy y ycopy)
29         (eqt (cdddr x) y)
30         result))))
31  (a b c d e f))
32
33(deftest nconc.5
34  (let ((x (list 'a 'b 'c)))
35    (nconc x x)
36    (and
37     (eqt (cdddr x) x)
38     (null (list-length x))))
39  t)
40
41(deftest nconc.6
42  (let ((x (list 'a 'b 'c))
43        (y (list 'd 'e 'f 'g 'h))
44        (z (list 'i 'j 'k)))
45    (let ((result (nconc x y z 'foo)))
46      (and
47       (eqt (nthcdr 3 x) y)
48       (eqt (nthcdr 5 y) z)
49       (eqt (nthcdr 3 z) 'foo)
50       result)))
51  (a b c d e f g h i j k . foo))
52
53(deftest nconc.7
54  (nconc (copy-tree '(a . b))
55         (copy-tree '(c . d))
56         (copy-tree '(e . f))
57         'foo)
58  (a c e . foo))
59
60(deftest nconc.order.1
61  (let ((i 0) x y z)
62    (values
63     (nconc (progn (setf x (incf i)) (copy-list '(a b c)))
64            (progn (setf y (incf i)) (copy-list '(d e f)))
65            (progn (setf z (incf i)) (copy-list '(g h i))))
66     i x y z))
67  (a b c d e f g h i) 3 1 2 3)
68
69(deftest nconc.order.2
70  (let ((i 0))
71    (values
72     (nconc (list 'a) (incf i))
73     i))
74  (a . 1) 1)
Note: See TracBrowser for help on using the repository browser.