Skip to content
Snippets Groups Projects
Commit f15b5f19 authored by pfdietz's avatar pfdietz
Browse files

Added tests for EQL. Also, added T-versions of EQL, EQUAL, EQUALP.

parent 5d7f0d72
No related branches found
No related tags found
No related merge requests found
......@@ -9,19 +9,33 @@
(declaim (optimize (safety 3)))
(defun eqt (x y)
"Function like EQ, but guaranteed to return T for true."
"Like EQ, but guaranteed to return T for true."
(if (eq x y) t nil))
(defun eqlt (x y)
"Like EQL, but guaranteed to return T for true."
(if (eql x y) t nil))
(defun equalt (x y)
"Like EQUAL, but guaranteed to return T for true."
(if (equal x y) t nil))
(defun equalpt (x y)
"Like EQUALP, but guaranteed to return T for true."
(if (equalp x y) t nil))
(defun =t (x &rest args)
"Like =, but guaranteed to return T for true."
(if (apply #'= x args) t nil))
(defun notnot (x) (not (not x)))
(defun make-int-list (n)
(loop for i from 0 to (1- n) collect i))
(loop for i from 0 below n collect i))
(defun make-int-array (n &optional (fn #'make-array))
(let ((a (funcall fn n)))
(loop
for i from 0 to (1- n) do
(setf (aref a i) i))
(loop for i from 0 below n do (setf (aref a i) i))
a))
(defun equal-array (a1 a2)
......@@ -33,12 +47,12 @@
(if (= (array-rank a1) 1)
(let ((as (first ad)))
(loop
for i from 0 to (1- as)
for i from 0 below as
always (equal (aref a1 i) (aref a2 i))))
(let ((as (array-total-size a1)))
(and (= as (array-total-size a2))
(loop
for i from 0 to (1- as)
for i from 0 below as
always (equal (row-major-aref a1 i)
(row-major-aref a2 i))))))))))
......
;-*- 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
(loop for x in *universe* always (eql x x))
t)
(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)
;;; There are many other uses of EQL in other files.
......@@ -19,6 +19,7 @@
(load "defparameter.lsp")
(load "defvar.lsp")
(load "destructuring-bind.lsp")
(load "eql.lsp")
(load "fboundp.lsp")
(load "flet.lsp")
(load "fmakunbound.lsp")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment