source: trunk/source/tests/ansi-tests/acons.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.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Apr 20 07:26:48 2003
4;;;; Contains: Tests of ACONS
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest acons.1
11  (let* ((x (copy-tree '((c . d) (e . f))))
12         (xcopy (make-scaffold-copy x))
13         (result (acons 'a 'b x)))
14    (and
15     (check-scaffold-copy x xcopy)
16     (eqt (cdr result) x)
17     result))
18  ((a . b) (c . d) (e . f)))
19
20(deftest acons.2
21  (acons 'a 'b nil)
22  ((a . b)))
23
24(deftest acons.3
25  (acons 'a 'b 'c)
26  ((a . b) . c))
27
28(deftest acons.4
29  (acons '((a b)) '(((c d) e) f) '((1 . 2)))
30  (( ((a b)) . (((c d) e) f)) (1 . 2)))
31
32(deftest acons.5
33  (acons "ancd" 1.143 nil)
34  (("ancd" . 1.143)))
35
36(deftest acons.6
37  (acons #\R :foo :bar)
38  ((#\R . :foo) . :bar))
39
40(deftest acons.7
41  (macrolet ((%m (z) z)) (acons (expand-in-current-env (%m 'a)) 'b '(c)))
42  ((a . b) c))
43
44(deftest acons.8
45  (macrolet ((%m (z) z)) (acons 'a (expand-in-current-env (%m 'b)) '(c)))
46  ((a . b) c))
47
48(deftest acons.9
49  (macrolet ((%m (z) z)) (acons 'a 'b (expand-in-current-env (%m '(c)))))
50  ((a . b) c))
51
52(deftest acons.order.1
53  (let ((i 0) x y z)
54    (values
55     (acons (progn (setf x (incf i)) 'a)
56            (progn (setf y (incf i)) 'b)
57            (progn (setf z (incf i)) '((c . d))))
58     i x y z))
59  ((a . b)(c . d))
60  3 1 2 3)
61
62(def-fold-test acons.fold.1 (acons 'x 'y nil))
63(def-fold-test acons.fold.2 (acons 1 2 '((3 . 4) (5 . 6))))
64
65;;; Error tests
66
67(deftest acons.error.1
68  (signals-error (acons) program-error)
69  t)
70
71(deftest acons.error.2
72  (signals-error (acons 'a) program-error)
73  t)
74
75(deftest acons.error.3
76  (signals-error (acons 'a 'b) program-error)
77  t)
78
79(deftest acons.error.4
80  (signals-error (acons 'a 'b 'c 'd) program-error)
81  t)
Note: See TracBrowser for help on using the repository browser.