source: trunk/source/tests/ansi-tests/append.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: 2.0 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 22:36:46 2003
4;;;; Contains: Tests of APPEND
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest append.1
11  (append)
12  nil)
13
14(deftest append.2
15  (append 'x)
16  x)
17
18(deftest append.3
19  (let ((x (list 'a 'b 'c 'd))
20        (y (list 'e 'f 'g)))
21    (let ((xcopy (make-scaffold-copy x))
22          (ycopy (make-scaffold-copy y)))
23      (let ((result (append x y)))
24        (and
25         (check-scaffold-copy x xcopy)
26         (check-scaffold-copy y ycopy)
27         result))))
28  (a b c d e f g))
29
30(deftest append.4
31  (append (list 'a) (list 'b) (list 'c)
32          (list 'd) (list 'e) (list 'f)
33          (list 'g) 'h)
34  (a b c d e f g . h))
35
36(deftest append.5
37  (append nil nil nil nil nil nil nil nil 'a)
38  a)
39
40(deftest append.6
41  (append-6-body)
42  0)
43
44;;; Test suggested by Peter Graves
45(deftest append.7
46  (let ((x (list 'a 'b 'c 'd)))
47    (eq (append x nil) x))
48  nil)
49
50;;; Compiler macro expansion in correct env
51
52(deftest append.8
53  (macrolet ((%m (z) z))
54            (append (expand-in-current-env (%m '(a b c)))))
55  (a b c))
56
57(deftest append.9
58  (macrolet ((%m (z) z))
59            (append (expand-in-current-env (%m (list 1 2 3))) (list 4 5 6)))
60  (1 2 3 4 5 6))
61
62(deftest append.10
63  (macrolet ((%m (z) z))
64            (append (list 1 2 3) (expand-in-current-env (%m (list 4 5 6)))))
65  (1 2 3 4 5 6))
66
67;;; Order of evaluation tests
68
69(deftest append.order.1
70  (let ((i 0) x y z)
71    (values
72     (append (progn (setf x (incf i)) (copy-list '(a b c)))
73             (progn (setf y (incf i)) (copy-list '(d e f)))
74             (progn (setf z (incf i)) (copy-list '(g h i))))
75     i x y z))
76  (a b c d e f g h i) 3 1 2 3)
77
78(deftest append.order.2
79  (let ((i 0)) (values (append (incf i)) i))
80  1 1)
81
82(def-fold-test append.fold.1 (append '(a b c) nil))
83(def-fold-test append.fold.2 (append nil '(x) nil))
84
85;;; Error tests
86
87(deftest append.error.1
88  (signals-error (append '(a . b) '(z))
89                 type-error)
90  t)
91
92(deftest append.error.2
93  (signals-error (append '(x y z) '(a . b) '(z))
94                 type-error)
95  t)
Note: See TracBrowser for help on using the repository browser.