sinh.lsp 2.15 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Wed Feb 11 06:29:51 2004
;;;; Contains: Tests for SINH

(in-package :cl-test)

(deftest sinh.1
  (let ((result (sinh 0)))
    (or (eqlt result 0)
sds's avatar
sds committed
11
        (eqlt result 0.0)))
pfdietz's avatar
pfdietz committed
12 13 14 15
  t)

(deftest sinh.2
  (loop for type in '(short-float single-float double-float long-float)
sds's avatar
sds committed
16 17 18 19
        for zero = (coerce 0 type)
        unless (equal (multiple-value-list (sinh zero))
                      (list zero))
        collect type)
pfdietz's avatar
pfdietz committed
20 21 22 23
  nil)

(deftest sinh.3
  (loop for type in '(short-float single-float double-float long-float)
sds's avatar
sds committed
24 25 26 27
        for zero = (coerce 0 `(complex ,type))
        unless (equal (multiple-value-list (sinh zero))
                      (list zero))
        collect type)
pfdietz's avatar
pfdietz committed
28 29 30 31
  nil)

(deftest sinh.4
  (loop for den = (1+ (random 10000))
sds's avatar
sds committed
32 33 34 35 36 37 38 39
        for num = (random (* 10 den))
        for x = (/ num den)
        for rlist = (multiple-value-list (sinh x))
        for y = (car rlist)
        repeat 1000
        unless (and (null (cdr rlist))
                    (numberp y))
        collect (list x rlist))
pfdietz's avatar
pfdietz committed
40 41 42 43
  nil)

(deftest sinh.5
  (loop for type in '(short-float single-float double-float long-float)
sds's avatar
sds committed
44 45 46 47 48 49 50 51 52
        nconc
        (loop
         for x = (- (random (coerce 20 type)) 10)
         for rlist = (multiple-value-list (sinh x))
         for y = (car rlist)
         repeat 1000
         unless (and (null (cdr rlist))
                     (typep y type))
         collect (list x rlist)))
pfdietz's avatar
pfdietz committed
53 54 55 56
  nil)

(deftest sinh.6
  (loop for type in '(short-float single-float double-float long-float)
sds's avatar
sds committed
57 58 59 60 61 62 63 64 65 66
        nconc
        (loop
         for x1 = (- (random (coerce 20 type)) 10)
         for x2 = (- (random (coerce 20 type)) 10)
         for rlist = (multiple-value-list (sinh (complex x1 x2)))
         for y = (car rlist)
         repeat 1000
         unless (and (null (cdr rlist))
                     (typep y `(complex ,type)))
         collect (list x1 x2 rlist)))
pfdietz's avatar
pfdietz committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  nil)

;;; FIXME
;;; Add accuracy tests here

;;; Error tests

(deftest sinh.error.1
  (signals-error (sinh) program-error)
  t)

(deftest sinh.error.2
  (signals-error (sinh 1.0 1.0) program-error)
  t)

(deftest sinh.error.3
83
  (check-type-error #'sinh #'numberp)
pfdietz's avatar
pfdietz committed
84 85 86 87 88 89
  nil)





sds's avatar
sds committed
90 91 92