pop.lsp 1.01 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Apr 19 22:27:18 2003
;;;; Contains: Tests of POP

(in-package :cl-test)

8 9
(compile-and-load "cons-aux.lsp")

10 11 12 13 14 15 16 17 18 19 20 21
(deftest pop.1
  (let ((x (copy-tree '(a b c))))
    (let ((y (pop x)))
      (list x y)))
  ((b c) a))

(deftest pop.2
  (let ((x nil))
    (let ((y (pop x)))
      (list x y)))
  (nil nil))

22 23 24 25 26 27 28 29 30 31 32 33
;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment

(deftest pop.3
  (macrolet
   ((%m (z) z))
   (let ((x (list 'a 'b 'c)))
     (values
      (pop (expand-in-current-env (%m x)))
      x)))
  a (b c))

34 35 36
;;; Confirm argument is executed just once.
(deftest pop.order.1
  (let ((i 0)
sds's avatar
sds committed
37
        (a (vector (list 'a 'b 'c))))
38 39 40 41 42 43
    (pop (aref a (progn (incf i) 0)))
    (values a i))
  #((b c)) 1)

(deftest push-and-pop
  (let* ((x (copy-tree '(a b)))
sds's avatar
sds committed
44
         (y x))
45 46 47 48 49 50
    (push 'c x)
    (and
     (eqt (cdr x) y)
     (pop x)))
  c)

51 52
(def-macro-test pop.error.1 (pop x))

53
;;; Need to add tests of POP vs. various accessors