source: trunk/source/tests/ansi-tests/equal.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Oct 17 21:38:16 2002
4;;;; Contains: Tests for EQUAL
5
6(in-package :cl-test)
7
8(deftest equal.1
9  (loop for x in *symbols*
10        always (loop for y in *symbols*
11                     always (if (eq x y) (equal x y)
12                              (not (equal x y)))))
13  t)
14
15(deftest equal.2
16  (equalt (cons 'a 'b) (cons 'a 'b))
17  t)
18
19(deftest equal.3
20  (equalt (cons 'a 'c) (cons 'a 'b))
21  nil)
22
23(deftest equal.4
24  (equalt (vector 1 2 3) (vector 1 2 3))
25  nil)
26
27(deftest equal.5
28  (loop for c in *characters*
29        always (loop for d in *characters*
30                     always (if (eql c d) (equalt c d)
31                              (not (equalt c d)))))
32  t)
33
34(deftest equal.6
35  (equalt (make-pathname :name (copy-seq "foo"))
36          (make-pathname :name (copy-seq "foo")))
37  t)
38
39(deftest equal.7
40  (equalt (make-pathname :name (copy-seq "foo"))
41          (make-pathname :name (copy-seq "bar")))
42  nil)
43
44(deftest equal.8
45  (equalt (copy-seq "abcd") (copy-seq "abcd"))
46  t)
47
48(deftest equal.9
49  (equalt (copy-seq "abcd") (copy-seq "abc"))
50  nil)
51
52(deftest equal.10
53  (equalt (copy-seq "abcd") (copy-seq "ABCD"))
54  nil)
55
56(deftest equal.11
57  (equalt (copy-seq #*000110) (copy-seq #*000110))
58  t)
59
60(deftest equal.12
61  (equalt (copy-seq #*000110) (copy-seq #*000111))
62  nil)
63
64(deftest equal.13
65  :notes (:nil-vectors-are-strings)
66  (let ((x (make-array '(0) :element-type nil))
67        (y (make-array '(0) :element-type nil)))
68    (equalt x y))
69  t)
70
71(deftest equal.14
72  :notes (:nil-vectors-are-strings)
73  (and
74   (equalt (make-array '(0) :element-type nil) "")
75   (equalt "" (make-array '(0) :element-type nil)))
76  t)
77
78(deftest equal.15
79  (equalt (make-array '(0) :element-type 'character)
80          (make-array '(0) :element-type 'base-char))
81  t)
82
83(deftest equal.16
84  (equalt "abc" (make-array '(3) :element-type 'base-char
85                            :initial-contents '(#\a #\b #\c)))
86  t)
87
88(deftest equal.17
89  (let ((s (make-array '(10) :element-type 'character
90                       :initial-contents "0123456789"
91                       :fill-pointer 3)))
92    (values (equalt s "012") (equalt "012" s)))
93  t t)
94
95(deftest equal.18
96  (let ((b (make-array '(10) :element-type 'bit
97                       :initial-contents #*0110001110
98                       :fill-pointer 5)))
99    (values (equalt #*01100 b) (equalt #*01100 b)))
100  t t)
101
102(deftest equal.19
103  (let ((s (make-array '(10) :element-type 'base-char
104                       :initial-contents "0123456789"
105                       :fill-pointer 3)))
106    (values (equalt s "012") (equalt "012" s)))
107  t t)
108
109;;; Should add more pathname equality tests
110
111(deftest equal.order.1
112  (let ((i 0) x y)
113    (values
114     (equal (setf x (incf i)) (setf y (incf i)))
115     i x y))
116  nil 2 1 2)
117
118;;; Error tests
119
120(deftest equal.error.1
121  (signals-error (equal) program-error)
122  t)
123
124(deftest equal.error.2
125  (signals-error (equal nil) program-error)
126  t)
127
128(deftest equal.error.3
129  (signals-error (equal nil nil nil) program-error)
130  t)
Note: See TracBrowser for help on using the repository browser.