get-properties.lsp 2.01 KB
Newer Older
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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Apr 20 07:37:00 2003
;;;; Contains: Tests of GET-PROPERTIES

(in-package :cl-test)

(deftest get-properties.1
  (get-properties nil nil)
  nil nil nil)

(deftest get-properties.2
  (get-properties '(a b) nil)
  nil nil nil)

(deftest get-properties.3
  (get-properties '(a b c d) '(a))
  a b (a b c d))

(deftest get-properties.4
  (get-properties '(a b c d) '(c))
  c d (c d))

(deftest get-properties.5
  (get-properties '(a b c d) '(c a))
  a b (a b c d))

(deftest get-properties.6
  (get-properties '(a b c d) '(b))
  nil nil nil)

(deftest get-properties.7
  (get-properties '("aa" b c d) (list (copy-seq "aa")))
  nil nil nil)

(deftest get-properties.8
  (get-properties '(1000000000000 b c d) (list (1+ 999999999999)))
  nil nil nil)

(deftest get-properties.9
  (let* ((x (copy-list '(a b c d e f g h a c)))
	 (xcopy (make-scaffold-copy x))
	 (y (copy-list '(x y f g)))
	 (ycopy (make-scaffold-copy y)))
    (multiple-value-bind
	(indicator value tail)
	(get-properties x y)
      (and
       (check-scaffold-copy x xcopy)
       (check-scaffold-copy y ycopy)
       (eqt tail (nthcdr 6 x))
       (values indicator value tail))))
  g h (g h a c))

(deftest get-properties.order.1
  (let ((i 0) x y)
    (values
     (multiple-value-list
      (get-properties (progn (setf x (incf i)) '(a b c d))
		      (progn (setf y (incf i)) '(c))))
     i x y))
  (c d (c d)) 2 1 2)

(deftest get-properties.error.1
65
66
  (signals-error (get-properties) program-error)
  t)
67
68

(deftest get-properties.error.2
69
70
  (signals-error (get-properties nil) program-error)
  t)
71
72

(deftest get-properties.error.3
73
74
  (signals-error (get-properties nil nil nil) program-error)
  t)
75
76

(deftest get-properties.error.4
77
78
  (signals-error (get-properties '(a 1 b 2 c 3) '(x . y)) type-error)
  t)
79
80

(deftest get-properties.error.5
81
82
  (signals-error (get-properties '(a 1 b 2 c 3 . d) '(x y)) type-error)
  t)
83
84

(deftest get-properties.error.6
85
86
  (signals-error (get-properties '(a 1 b 2 c . d) '(x y)) type-error)
  t)