Commit b350ad71 authored by pfdietz's avatar pfdietz

Added EXPT tests. Some files for EXP tests, but they are not loaded yet as I...

Added EXPT tests.  Some files for EXP tests, but they are not loaded yet as I figure out just how to test this.
parent 2c8f3375
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Mon Sep 1 21:30:38 2003
;;;; Contains: Aux. functions for testing EXP, EXPT
(in-package :cl-test)
(defun my-exp (x n)
"Compute e^x in the appropriate float result type, summing
the first n terms of the Taylor series."
(assert (realp x))
(let ((result 1)
(xrat (rational x)))
(loop
for i from (1- n) downto 1
do (setq result (+ 1 (/ (* xrat result) i))))
(if (floatp x)
(float result x)
(float result 1.0f0))))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Mon Sep 1 21:24:44 2003
;;;; Contains: Tests of EXP
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(compile-and-load "exp-aux.lsp")
(deftest exp.error.1
(classify-error (exp))
program-error)
(deftest exp.error.2
(classify-error (exp 0 nil))
program-error)
(deftest exp.error.3
(classify-error (exp 0 0 0))
program-error)
(deftest exp.1
(let ((result (exp 0)))
(or (eqlt result 1)
(eqlt result 1.0f0)))
t)
(deftest exp.2
(mapcar #'exp '(0.0s0 0.0f0 0.0d0 0.0l0))
(1.0s0 1.0f0 1.0d0 1.0l0))
(deftest exp.3
(mapcar #'exp '(-0.0s0 -0.0f0 -0.0d0 -0.0l0))
(1.0s0 1.0f0 1.0d0 1.0l0))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Sep 2 19:36:22 2003
;;;; Contains: Tests of EXPT
(in-package :cl-test)
(deftest expt.error.1
(classify-error (expt))
program-error)
(deftest expt.error.2
(classify-error (expt 1 1 1))
program-error)
(deftest expt.error.3
(classify-error (expt 1 1 nil nil))
program-error)
(deftest expt.1
(expt 0 0)
1)
(deftest expt.2
(loop for i from -1000 to 1000
always (eql (expt i 0) 1))
t)
(deftest expt.3
(loop for i = (random 10000.0s0)
repeat 1000
always (eql (expt i 0) 1.0s0))
t)
(deftest expt.4
(loop for i = (random 1.0f6)
repeat 1000
always (eql (expt i 0) 1.0f0))
t)
(deftest expt.5
(loop for i = (random 1.0d20)
repeat 1000
always (eql (expt i 0) 1.0d0))
t)
(deftest expt.6
(loop for i = (random 1.0l50)
repeat 1000
always (eql (expt i 0) 1.0l0))
t)
......@@ -30,6 +30,8 @@
(load "oneplus.lsp")
(load "oneminus.lsp")
(load "abs.lsp")
;;(load "exp.lsp")
(load "expt.lsp")
(load "rational.lsp")
(load "rationalize.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