This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
/
test-vicare-equality.sps
191 lines (139 loc) · 3.8 KB
/
test-vicare-equality.sps
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
;;; -*- coding: utf-8-unix -*-
;;;
;;;Part of: Vicare
;;;Contents: tests for Vicare equality functions
;;;Date: Thu Nov 3, 2011
;;;
;;;Abstract
;;;
;;;
;;;
;;;Copyright (C) 2011, 2012 Marco Maggi <marco.maggi-ipsu@poste.it>
;;;
;;;This program is free software: you can redistribute it and/or modify
;;;it under the terms of the GNU General Public License as published by
;;;the Free Software Foundation, either version 3 of the License, or (at
;;;your option) any later version.
;;;
;;;This program is distributed in the hope that it will be useful, but
;;;WITHOUT ANY WARRANTY; without even the implied warranty of
;;;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;General Public License for more details.
;;;
;;;You should have received a copy of the GNU General Public License
;;;along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;
#!vicare
(import (vicare)
(vicare checks))
(check-set-mode! 'report-failed)
(check-display "*** testing Vicare equality functions\n")
;;;; constants
(define BIGNUM0 (+ 1 (greatest-fixnum)))
(define BIGNUM1 (+ 2 (greatest-fixnum)))
(define RATNUM0 1/2)
(define RATNUM1 3/4)
(define FLONUM0 1.)
(define FLONUM1 2.)
(define CFLONUM0 1.2+3.4i)
(define CFLONUM1 5.6+7.8i)
(define COMPNUM0 1+3i)
(define COMPNUM1 5+7i)
(parametrise ((check-test-name 'equal))
;;fixnums
(check (equal? 1 1) => #t)
(check (equal? 1 2) => #f)
;;bignums
(check (equal? BIGNUM0 BIGNUM0) => #t)
(check (equal? BIGNUM0 BIGNUM1) => #f)
;;ratnums
(check (equal? RATNUM0 RATNUM0) => #t)
(check (equal? RATNUM0 RATNUM1) => #f)
;;flonums
(check (equal? FLONUM0 FLONUM0) => #t)
(check (equal? FLONUM0 FLONUM1) => #f)
;;cflonums
(check (equal? CFLONUM0 CFLONUM0) => #t)
(check (equal? CFLONUM0 CFLONUM1) => #f)
;;compnums
(check (equal? COMPNUM0 COMPNUM0) => #t)
(check (equal? COMPNUM0 COMPNUM1) => #f)
;;; --------------------------------------------------------------------
;;; null, pairs and lists
(check
(equal? '() '())
=> #t)
(check
(equal? '() '(1 . 2))
=> #f)
(check
(equal? (cons 1 2) (cons 1 2))
=> #t)
(check
(equal? (cons 1 2) (list 1 2))
=> #f)
(check
(equal? (cons 1 2) (cons 1 99))
=> #f)
(check
(equal? (cons (cons 1 2) (cons 1 2))
(let ((p (cons 1 2))) (cons p p)))
=> #t)
(check
(equal? (cons (cons 1 2) (cons 1 99))
(let ((p (cons 1 2))) (cons p p)))
=> #f)
(check
(equal? (let ((x (cons 1 2)))
(set-car! x x)
(set-cdr! x x)
x)
(let ((x (cons 1 2)))
(set-car! x x)
(set-cdr! x x)
(cons x x)))
=> #t)
#t)
(parametrise ((check-test-name 'eqv))
;;fixnums
(check (eqv? 1 1) => #t)
(check (eqv? 1 2) => #f)
;;bignums
(check (eqv? BIGNUM0 BIGNUM0) => #t)
(check (eqv? BIGNUM0 BIGNUM1) => #f)
;;ratnums
(check (eqv? RATNUM0 RATNUM0) => #t)
(check (eqv? RATNUM0 RATNUM1) => #f)
;;flonums
(check (eqv? FLONUM0 FLONUM0) => #t)
(check (eqv? FLONUM0 FLONUM1) => #f)
;;cflonums
(check (eqv? CFLONUM0 CFLONUM0) => #t)
(check (eqv? CFLONUM0 CFLONUM1) => #f)
;;compnums
(check (eqv? COMPNUM0 COMPNUM0) => #t)
(check (eqv? COMPNUM0 COMPNUM1) => #f)
#t)
(parametrise ((check-test-name 'eq))
;;fixnums
(check (eq? 1 1) => #t)
(check (eq? 1 2) => #f)
;;bignums
(check (eq? BIGNUM0 BIGNUM0) => #t)
(check (eq? BIGNUM0 BIGNUM1) => #f)
;;ratnums
(check (eq? RATNUM0 RATNUM0) => #t)
(check (eq? RATNUM0 RATNUM1) => #f)
;;flonums
(check (eq? FLONUM0 FLONUM0) => #t)
(check (eq? FLONUM0 FLONUM1) => #f)
;;cflonums
(check (eq? CFLONUM0 CFLONUM0) => #t)
(check (eq? CFLONUM0 CFLONUM1) => #f)
;;compnums
(check (eq? COMPNUM0 COMPNUM0) => #t)
(check (eq? COMPNUM0 COMPNUM1) => #f)
#t)
;;;; done
(check-report)
;;; end of file