source: trunk/source/tests/ansi-tests/cosh.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Feb 11 06:54:15 2004
4;;;; Contains: Tests of COSH
5
6(in-package :cl-test)
7
8(deftest cosh.1
9  (let ((result (cosh 0)))
10    (or (eqlt result 1)
11        (eqlt result 1.0)))
12  t)
13
14(deftest cosh.2
15  (loop for type in '(short-float single-float double-float long-float)
16        for zero = (coerce 0 type)
17        for one = (coerce 1 type)
18        unless (equal (multiple-value-list (cosh zero))
19                      (list one))
20        collect type)
21  nil)
22
23(deftest cosh.3
24  (loop for type in '(short-float single-float double-float long-float)
25        for zero = (coerce 0 `(complex ,type))
26        for one = (coerce 1 `(complex ,type))
27        unless (equal (multiple-value-list (cosh zero))
28                      (list one))
29        collect type)
30  nil)
31
32(deftest cosh.4
33  (loop for den = (1+ (random 10000))
34        for num = (random (* 10 den))
35        for x = (/ num den)
36        for rlist = (multiple-value-list (cosh x))
37        for y = (car rlist)
38        repeat 1000
39        unless (and (null (cdr rlist))
40                    (numberp y))
41        collect (list x rlist))
42  nil)
43
44(deftest cosh.5
45  (loop for type in '(short-float single-float double-float long-float)
46        nconc
47        (loop
48         for x = (- (random (coerce 20 type)) 10)
49         for rlist = (multiple-value-list (cosh x))
50         for y = (car rlist)
51         repeat 1000
52         unless (and (null (cdr rlist))
53                     (typep y type))
54         collect (list x rlist)))
55  nil)
56
57(deftest cosh.6
58  (loop for type in '(short-float single-float double-float long-float)
59        nconc
60        (loop
61         for x1 = (- (random (coerce 20 type)) 10)
62         for x2 = (- (random (coerce 20 type)) 10)
63         for rlist = (multiple-value-list (cosh (complex x1 x2)))
64         for y = (car rlist)
65         repeat 1000
66         unless (and (null (cdr rlist))
67                     (typep y `(complex ,type)))
68         collect (list x1 x2 rlist)))
69  nil)
70
71;;; FIXME
72;;; Add accuracy tests here
73
74;;; Error tests
75
76(deftest cosh.error.1
77  (signals-error (cosh) program-error)
78  t)
79
80(deftest cosh.error.2
81  (signals-error (cosh 1.0 1.0) program-error)
82  t)
83
84(deftest cosh.error.3
85  (check-type-error #'cosh #'numberp)
86  nil)
87
88
89
90
91
92 
93                           
94 
95
Note: See TracBrowser for help on using the repository browser.