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