Commit a40e2ae7 authored by pfdietz's avatar pfdietz

More FLOOR tests, and new FFLOOR tests.

parent c4ff0d90
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Aug 12 07:02:07 2003
;;;; Contains: Aux. functions used in FFLOOR tests
(in-package :cl-test)
(defun ffloor.1-fn ()
(loop for n = (- (random 200000)
100000)
for d = (1+ (random 10000))
for vals = (multiple-value-list (ffloor n d))
for (q r) = vals
for n2 = (+ (* q d) r)
repeat 100
unless (and (eql (length vals) 2)
(floatp q)
(= n n2)
(integerp r)
(< -1 r d))
collect (list n d q r n2)))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Aug 12 06:59:54 2003
;;;; Contains: Tests of FFLOOR
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(compile-and-load "ffloor-aux.lsp")
(deftest ffloor.error.1
(classify-error (ffloor))
program-error)
(deftest ffloor.error.2
(classify-error (ffloor 1.0 1 nil))
program-error)
;;;
(deftest ffloor.1
(ffloor.1-fn)
nil)
(deftest ffloor.10
(loop for x in (remove-if #'zerop *reals*)
for (q r) = (multiple-value-list (ffloor x x))
unless (and (floatp q)
(if (floatp x)
(eql q (float 1 x))
(= q 1))
(zerop r)
(if (floatp x)
(eql r (float 0 x))
(= r 0)))
collect x)
nil)
(deftest ffloor.11
(loop for x in (remove-if-not #'floatp (remove-if #'zerop *reals*))
for (q r) = (multiple-value-list (ffloor (- x) x))
unless (and (floatp q)
(if (floatp x)
(eql q (float -1 x))
(= q -1))
(zerop r)
(if (floatp x)
(eql r (float 0 x))
(= r 0)))
collect x)
nil)
(deftest ffloor.12
(let* ((radix (float-radix 1.0s0))
(rad (float radix 1.0s0))
(rrad (/ 1.0s0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce i 'short-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.13
(let* ((radix (float-radix 1.0s0))
(rad (float radix 1.0s0))
(rrad (/ 1.0s0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce (1- i) 'short-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.14
(let* ((radix (float-radix 1.0f0))
(rad (float radix 1.0f0))
(rrad (/ 1.0f0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce i 'single-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.15
(let* ((radix (float-radix 1.0f0))
(rad (float radix 1.0f0))
(rrad (/ 1.0f0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce (1- i) 'single-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.16
(let* ((radix (float-radix 1.0d0))
(rad (float radix 1.0d0))
(rrad (/ 1.0d0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce i 'double-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.17
(let* ((radix (float-radix 1.0d0))
(rad (float radix 1.0d0))
(rrad (/ 1.0d0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce (1- i) 'double-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.18
(let* ((radix (float-radix 1.0l0))
(rad (float radix 1.0l0))
(rrad (/ 1.0l0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce i 'long-float))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest ffloor.19
(let* ((radix (float-radix 1.0l0))
(rad (float radix 1.0l0))
(rrad (/ 1.0l0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (ffloor x))
unless (and (eql q (coerce (1- i) 'long-float))
(eql r rrad))
collect (list i x q r)))
nil)
;;; To add: tests that involve adding/subtracting EPSILON constants
;;; (suitably scaled) to floated integers.
......@@ -60,6 +60,7 @@
repeat 10000
unless (and (eql (length vals) 2)
(integerp q)
(rationalp r)
(= n n2)
(<= 0 r)
(< r 1)
......@@ -79,6 +80,7 @@
repeat 10000
unless (and (eql (length vals) 2)
(integerp q)
(rationalp r)
(>= 0 r)
(> r d)
(= n n2))
......@@ -97,8 +99,10 @@
repeat 10000
unless (and (eql (length vals) 2)
(integerp q)
(rationalp r)
(>= 0 r)
(> r d)
(= n n2))
collect (list n q d r n2)))
;;; Need float tests
......@@ -74,3 +74,102 @@
collect x)
nil)
(deftest floor.12
(let* ((radix (float-radix 1.0s0))
(rad (float radix 1.0s0))
(rrad (/ 1.0s0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q i)
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.13
(let* ((radix (float-radix 1.0s0))
(rad (float radix 1.0s0))
(rrad (/ 1.0s0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q (1- i))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.14
(let* ((radix (float-radix 1.0f0))
(rad (float radix 1.0f0))
(rrad (/ 1.0f0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q i)
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.15
(let* ((radix (float-radix 1.0f0))
(rad (float radix 1.0f0))
(rrad (/ 1.0f0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q (1- i))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.16
(let* ((radix (float-radix 1.0d0))
(rad (float radix 1.0d0))
(rrad (/ 1.0d0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q i)
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.17
(let* ((radix (float-radix 1.0d0))
(rad (float radix 1.0d0))
(rrad (/ 1.0d0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q (1- i))
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.18
(let* ((radix (float-radix 1.0l0))
(rad (float radix 1.0l0))
(rrad (/ 1.0l0 rad)))
(loop for i from 1 to 1000
for x = (+ i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q i)
(eql r rrad))
collect (list i x q r)))
nil)
(deftest floor.19
(let* ((radix (float-radix 1.0l0))
(rad (float radix 1.0l0))
(rrad (/ 1.0l0 rad)))
(loop for i from 1 to 1000
for x = (- i rrad)
for (q r) = (multiple-value-list (floor x))
unless (and (eql q (1- i))
(eql r rrad))
collect (list i x q r)))
nil)
;;; To add: tests that involve adding/subtracting EPSILON constants
;;; (suitably scaled) to floated integers.
......@@ -13,3 +13,4 @@
(load "plusp.lsp")
(load "zerop.lsp")
(load "floor.lsp")
(load "ffloor.lsp")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment