From b649f2467897fe7d55b56d8bf3e03132ac335943 Mon Sep 17 00:00:00 2001
From: pfdietz
Date: Thu, 12 Feb 2004 02:14:41 +0000
Subject: [PATCH] Added tests for LOG (not complete)
---
ansi-tests/load-numbers.lsp | 1 +
ansi-tests/log.lsp | 113 ++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+)
create mode 100644 ansi-tests/log.lsp
diff --git a/ansi-tests/load-numbers.lsp b/ansi-tests/load-numbers.lsp
index a3a64e6..2b4a8c0 100644
--- a/ansi-tests/load-numbers.lsp
+++ b/ansi-tests/load-numbers.lsp
@@ -51,6 +51,7 @@
(load "incf.lsp")
(load "decf.lsp")
(load "lcm.lsp")
+(load "log.lsp")
(load "signum.lsp")
(load "sqrt.lsp")
(load "isqrt.lsp")
diff --git a/ansi-tests/log.lsp b/ansi-tests/log.lsp
new file mode 100644
index 0000000..8e2ec85
--- /dev/null
+++ b/ansi-tests/log.lsp
@@ -0,0 +1,113 @@
+;-*- Mode: Lisp -*-
+;;;; Author: Paul Dietz
+;;;; Created: Wed Feb 11 19:53:33 2004
+;;;; Contains: Tests of LOG
+
+(in-package :cl-test)
+
+(deftest log.1
+ (let ((result (log 1)))
+ (or (eqlt result 0)
+ (eqlt result 0.0)))
+ t)
+
+(deftest log.2
+ (mapcar #'log '(1.0s0 1.0f0 1.0d0 1.0l0))
+ (0.0s0 0.0f0 0.0d0 0.0l0))
+
+(deftest log.3
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x = (+ (random (coerce 1 type)) (/ 1 1000))
+ for rlist = (multiple-value-list (log x))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y type))
+ collect (list x rlist)))
+ nil)
+
+(deftest log.4
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x = (1+ (random (coerce 1000000 type)))
+ for rlist = (multiple-value-list (log x))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y type))
+ collect (list x rlist)))
+ nil)
+
+(deftest log.5
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x = (- (random (coerce 1 type)))
+ for rlist = (multiple-value-list (log x))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y `(complex ,type)))
+ collect (list x rlist)))
+ nil)
+
+(deftest log.6
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x = (- (random (coerce 1000000 type)))
+ for rlist = (multiple-value-list (log x))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y `(complex ,type)))
+ collect (list x rlist)))
+ nil)
+
+(deftest log.7
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x1 = (- (random (coerce 2000 type)) 1000)
+ for x2 = (1+ (random (coerce 1000 type)))
+ for rlist = (multiple-value-list (log (complex x1 x2)))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y `(complex ,type)))
+ collect (list x rlist)))
+ nil)
+
+(deftest log.8
+ (loop for type in '(short-float single-float double-float long-float)
+ nconc
+ (loop
+ for x1 = (- (random (coerce 2000 type)) 1000)
+ for x2 = (- -1 (random (coerce 1000 type)))
+ for rlist = (multiple-value-list (log (complex x1 x2)))
+ for y = (car rlist)
+ repeat 1000
+ unless (and (null (cdr rlist))
+ (typep y `(complex ,type)))
+ collect (list x rlist)))
+ nil)
+
+;;; FIXME
+;;; Add tests for two-arg calls
+
+;;; FIXME
+;;; More accuracy tests here
+
+;;; Error tests
+
+(deftest log.error.1
+ (signals-error (log) program-error)
+ t)
+
+(deftest log.error.2
+ (signals-error (log 1.0 2.0 3.0) program-error)
+ t)
+
--
2.22.0