remprop.lsp 1.72 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Jul 12 18:25:53 2004
;;;; Contains: Tests for REMPROP

(in-package :cl-test)

(deftest remprop.1
  (let ((sym (gensym)))
    (values
     (symbol-plist sym)
     (multiple-value-list (remprop sym :foo))
     (symbol-plist sym)))
  nil (nil) nil)

(deftest remprop.2
  (let ((sym (gensym)))
    (values
     (symbol-plist sym)
     (copy-list (setf (symbol-plist sym) '(:foo 0)))
     (multiple-value-list (notnot-mv (remprop sym :foo)))
     (symbol-plist sym)))
  nil (:foo 0) (t) nil)

(deftest remprop.3
  (let ((sym (gensym)))
    (values
     (symbol-plist sym)
     (copy-list (setf (symbol-plist sym) (list :bar 1 :foo 0 :baz 2)))
     (multiple-value-list (notnot-mv (remprop sym :foo)))
     (copy-list (symbol-plist sym))
     (multiple-value-list (notnot-mv (remprop sym :foo)))
     (symbol-plist sym)))     
  nil
  (:bar 1 :foo 0 :baz 2)
  (t)
  (:bar 1 :baz 2)
  (nil)
  (:bar 1 :baz 2))

(deftest remprop.4
  (let ((sym (gensym)))
    (values
     (symbol-plist sym)
     (copy-list (setf (symbol-plist sym) (list :bar 1 :foo 0 :baz 2 :foo 3)))
     (multiple-value-list (notnot-mv (remprop sym :foo)))
     (copy-list (symbol-plist sym))
     (multiple-value-list (notnot-mv (remprop sym :foo)))
     (symbol-plist sym)))
  nil
  (:bar 1 :foo 0 :baz 2 :foo 3)
  (t)
  (:bar 1 :baz 2 :foo 3)
  (t)
  (:bar 1 :baz 2))

;;; Error tests

(deftest remprop.error.1
  (signals-error (remprop) program-error)
  t)

(deftest remprop.error.2
  (signals-error (remprop (gensym)) program-error)
  t)

(deftest remprop.error.3
  (signals-error (remprop (gensym) nil nil) program-error)
  t)

(deftest remprop.error.4
72
  (check-type-error #'(lambda (x) (remprop x nil)) #'symbolp)
pfdietz's avatar
pfdietz committed
73
  nil)