eql.lsp 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Oct 17 19:36:33 2002
;;;; Contains: Tests of EQL

(in-package :cl-test)

;;; EQLT is defined in ansi-aux.lsp
;;; It calls EQL, returning NIL when the result is false and T when it
;;; is true.

(deftest eql.1
13 14
  (check-predicate #'(lambda (x) (eql x x)))
  nil)
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

(deftest eql.2
  (eqlt 2 (1+ 1))
  t)

(deftest eql.3
  (let ((x "abc"))
    (eql x (copy-seq x)))
  nil)

(deftest eql.4
  (eqlt #\a #\a)
  t)

(deftest eql.5
  (eqlt 12345678901234567890 12345678901234567890)
  t)

(deftest eql.7
  (eql 12.0 12)
  nil)

(deftest eql.8
  (eqlt #c(1 -2) #c(1 -2))
  t)

(deftest eql.9
  (let ((x "abc") (y "abc"))
    (if (eq x y) (eqlt x y) (not (eql x y))))
  t)

(deftest eql.10
  (eql (list 'a) (list 'b))
  nil)

(deftest eql.11
  (eqlt #c(1 -2) (- #c(-1 2)))
  t)

54
(deftest eql.order.1
55 56 57 58 59 60
  (let ((i 0) x y)
    (values
     (eql (setf x (incf i)) (setf y (incf i)))
     i x y))
  nil 2 1 2)

61 62
;;; Error tests for EQL

63
(deftest eql.error.1
64 65
  (signals-error (eql) program-error)
  t)
66 67

(deftest eql.error.2
68 69
  (signals-error (eql nil) program-error)
  t)
70 71

(deftest eql.error.3
72 73
  (signals-error (eql nil nil nil) program-error)
  t)
74 75 76 77

;;; Error tests for EQ

(deftest eq.error.1
78 79
  (signals-error (eq) program-error)
  t)
80 81

(deftest eq.error.2
82 83
  (signals-error (eq nil) program-error)
  t)
84 85

(deftest eq.error.3
86 87
  (signals-error (eq nil nil nil) program-error)
  t)