File: tree-equal.lsp

package info (click to toggle)
cl-ansi-tests 20071218-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,000 kB
  • ctags: 22,025
  • sloc: lisp: 134,798; makefile: 144
file content (140 lines) | stat: -rw-r--r-- 3,028 bytes parent folder | download | duplicates (7)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Jun 14 07:23:03 2003
;;;; Contains: Tests of TREE-EQUAL

(in-package :cl-test)

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

(deftest tree-equal.1
  (notnot-mv (tree-equal 'a 'a))
  t)

(deftest tree-equal.2
  (tree-equal 'a 'b)
  nil)

(deftest tree-equal.3
  (notnot-mv (tree-equal (list 'a 'b (list 'c 'd))
			 (list 'a 'b (list 'c 'd))))
  t)

(deftest tree-equal.4
  (tree-equal '(a b c d) '(a b c e))
  nil)

(deftest tree-equal.5
  (notnot-mv (tree-equal 1 2 :test #'<))
  t)
  
(deftest tree-equal.6
  (notnot-mv (tree-equal 1 2 :test #'(lambda (x y) (values (< x y) t))))
  t)

(deftest tree-equal.7
  (tree-equal 1 2 :test #'>)
  nil)
  
(deftest tree-equal.8
  (tree-equal (list 1) 2 :test (constantly t))
  nil)

(deftest tree-equal.9
  (tree-equal (list 1) (list 2)
	      :test #'(lambda (x y) (or (and (consp x) (consp y))
					(eql x y))))
  nil)

(deftest tree-equal.10
  (notnot-mv (tree-equal '(10 20 . 30) '(11 22 . 34) :test #'<))
  t)

(deftest tree-equal.11
  (let* ((x (list 'a 'b))
	 (y (list x x))
	 (z (list (list 'a 'b) (list 'a 'b))))
    (notnot-mv (tree-equal y z)))
  t)

(deftest tree-equal.12
  (tree-equal 'a '(a b))
  nil)

(deftest tree-equal.13
  (tree-equal '(a) '(a b))
  nil)

(deftest tree-equal.14
  (tree-equal '(a b) '(a))
  nil)

(deftest tree-equal.15
  (let ((x (vector 'a 'b 'c))
	(y (vector 'a' 'b 'c)))
    (tree-equal x y))
  nil)

(deftest tree-equal.16
  (let ((x (copy-seq ""))
	(y (copy-seq "")))
    (tree-equal x y))
  nil)

(defharmless tree-equal.test-and-test-not.1
  (tree-equal '(a b) '(a b) :test #'eql :test-not #'eql))

(defharmless tree-equal.test-and-test-not.2
  (tree-equal '(a b) '(a b) :test-not #'eql :test #'eql))

;;; Keywords tests

(deftest tree-equal.allow-other-keys.1
  (notnot-mv (tree-equal '(a b) (list 'a 'b) :allow-other-keys nil))
  t)

(deftest tree-equal.allow-other-keys.2
  (tree-equal '(a b) (list 'a 'c) :allow-other-keys nil :test #'eql)
  nil)

(deftest tree-equal.allow-other-keys.3
  (tree-equal '(a b) (list 'a 'z) :allow-other-keys t :foo t)
  nil)

(deftest tree-equal.allow-other-keys.4
  (notnot-mv (tree-equal '(a b) (list 'a 'b) :allow-other-keys t
			 :allow-other-keys nil :foo t))
  t)

(deftest tree-equal.keywords.1
  (notnot-mv (tree-equal '(a . b) '(b . a)
			 :test (complement #'eql)
			 :test #'eql))
  t)


;;; Error tests

(deftest tree-equal.error.1
  (signals-error (tree-equal) program-error)
  t)

(deftest tree-equal.error.2
  (signals-error (tree-equal '(a b)) program-error)
  t)

(deftest tree-equal.error.3
  (signals-error (tree-equal '(a b) '(a b) (gensym) t) program-error)
  t)

(deftest tree-equal.error.4
  (signals-error (tree-equal '(a b) '(a b) (gensym) t :allow-other-keys nil) program-error)
  t)

(deftest tree-equal.error.5
  (signals-error (tree-equal '(a b) '(a b) :test #'identity) program-error)
  t)

(deftest tree-equal.error.6
  (signals-error (tree-equal '(a b) '(a b) :test #'(lambda (x y z) (eq x y))) program-error)
  t)