source: trunk/source/tests/ansi-tests/rplacd.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: 995 bytes
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 21:30:28 2003
4;;;; Contains: Tests of RPLACD
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest rplacd.1
11  (let ((x (cons 'a 'b)))
12    (let ((y x))
13      (and (eqt (rplacd x 'd) y)
14           (eqt x y)
15           (eqt (car x) 'a)
16           (eqt (cdr x) 'd))))
17  t)
18
19(deftest rplacd.order.1
20  (let ((x (cons 'a 'b))
21        (i 0) a b)
22    (values
23     (rplacd (progn (setf a (incf i)) x)
24             (progn (setf b (incf i)) 'c))
25     i a b))
26  (a . c) 2 1 2)
27
28;; rplacd on a non-cons is a type error
29(deftest rplacd.error.1
30  (check-type-error #'(lambda (x) (rplacd x 1)) #'consp)
31  nil)
32
33(deftest rplacd.error.2
34  (signals-error (rplacd) program-error)
35  t)
36
37(deftest rplacd.error.3
38  (signals-error (rplacd (cons 'a 'b)) program-error)
39  t)
40
41(deftest rplacd.error.4
42  (signals-error (rplacd (cons 'a 'b) (cons 'c 'd) 'garbage) program-error)
43  t)
44
45(deftest rplacd.error.6
46  (signals-error (locally (rplacd 'a 1) t) type-error)
47  t)
48
Note: See TracBrowser for help on using the repository browser.