source: trunk/source/tests/ansi-tests/tree-equal.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: 3.0 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Jun 14 07:23:03 2003
4;;;; Contains: Tests of TREE-EQUAL
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest tree-equal.1
11  (notnot-mv (tree-equal 'a 'a))
12  t)
13
14(deftest tree-equal.2
15  (tree-equal 'a 'b)
16  nil)
17
18(deftest tree-equal.3
19  (notnot-mv (tree-equal (list 'a 'b (list 'c 'd))
20                         (list 'a 'b (list 'c 'd))))
21  t)
22
23(deftest tree-equal.4
24  (tree-equal '(a b c d) '(a b c e))
25  nil)
26
27(deftest tree-equal.5
28  (notnot-mv (tree-equal 1 2 :test #'<))
29  t)
30 
31(deftest tree-equal.6
32  (notnot-mv (tree-equal 1 2 :test #'(lambda (x y) (values (< x y) t))))
33  t)
34
35(deftest tree-equal.7
36  (tree-equal 1 2 :test #'>)
37  nil)
38 
39(deftest tree-equal.8
40  (tree-equal (list 1) 2 :test (constantly t))
41  nil)
42
43(deftest tree-equal.9
44  (tree-equal (list 1) (list 2)
45              :test #'(lambda (x y) (or (and (consp x) (consp y))
46                                        (eql x y))))
47  nil)
48
49(deftest tree-equal.10
50  (notnot-mv (tree-equal '(10 20 . 30) '(11 22 . 34) :test #'<))
51  t)
52
53(deftest tree-equal.11
54  (let* ((x (list 'a 'b))
55         (y (list x x))
56         (z (list (list 'a 'b) (list 'a 'b))))
57    (notnot-mv (tree-equal y z)))
58  t)
59
60(deftest tree-equal.12
61  (tree-equal 'a '(a b))
62  nil)
63
64(deftest tree-equal.13
65  (tree-equal '(a) '(a b))
66  nil)
67
68(deftest tree-equal.14
69  (tree-equal '(a b) '(a))
70  nil)
71
72(deftest tree-equal.15
73  (let ((x (vector 'a 'b 'c))
74        (y (vector 'a' 'b 'c)))
75    (tree-equal x y))
76  nil)
77
78(deftest tree-equal.16
79  (let ((x (copy-seq ""))
80        (y (copy-seq "")))
81    (tree-equal x y))
82  nil)
83
84(defharmless tree-equal.test-and-test-not.1
85  (tree-equal '(a b) '(a b) :test #'eql :test-not #'eql))
86
87(defharmless tree-equal.test-and-test-not.2
88  (tree-equal '(a b) '(a b) :test-not #'eql :test #'eql))
89
90;;; Keywords tests
91
92(deftest tree-equal.allow-other-keys.1
93  (notnot-mv (tree-equal '(a b) (list 'a 'b) :allow-other-keys nil))
94  t)
95
96(deftest tree-equal.allow-other-keys.2
97  (tree-equal '(a b) (list 'a 'c) :allow-other-keys nil :test #'eql)
98  nil)
99
100(deftest tree-equal.allow-other-keys.3
101  (tree-equal '(a b) (list 'a 'z) :allow-other-keys t :foo t)
102  nil)
103
104(deftest tree-equal.allow-other-keys.4
105  (notnot-mv (tree-equal '(a b) (list 'a 'b) :allow-other-keys t
106                         :allow-other-keys nil :foo t))
107  t)
108
109(deftest tree-equal.keywords.1
110  (notnot-mv (tree-equal '(a . b) '(b . a)
111                         :test (complement #'eql)
112                         :test #'eql))
113  t)
114
115
116;;; Error tests
117
118(deftest tree-equal.error.1
119  (signals-error (tree-equal) program-error)
120  t)
121
122(deftest tree-equal.error.2
123  (signals-error (tree-equal '(a b)) program-error)
124  t)
125
126(deftest tree-equal.error.3
127  (signals-error (tree-equal '(a b) '(a b) (gensym) t) program-error)
128  t)
129
130(deftest tree-equal.error.4
131  (signals-error (tree-equal '(a b) '(a b) (gensym) t :allow-other-keys nil) program-error)
132  t)
133
134(deftest tree-equal.error.5
135  (signals-error (tree-equal '(a b) '(a b) :test #'identity) program-error)
136  t)
137
138(deftest tree-equal.error.6
139  (signals-error (tree-equal '(a b) '(a b) :test #'(lambda (x y z) (eq x y))) program-error)
140  t)
Note: See TracBrowser for help on using the repository browser.