source: trunk/source/tests/ansi-tests/log.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: 2.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Feb 11 19:53:33 2004
4;;;; Contains: Tests of LOG
5
6(in-package :cl-test)
7
8(deftest log.1
9  (let ((result (log 1)))
10    (or (eqlt result 0)
11        (eqlt result 0.0)))
12  t)
13
14(deftest log.2
15  (mapcar #'log '(1.0s0 1.0f0 1.0d0 1.0l0))
16  (0.0s0 0.0f0 0.0d0 0.0l0))
17
18(deftest log.3
19  (loop for type in '(short-float single-float double-float long-float)
20        nconc
21        (loop
22         for x = (+ (random (coerce 1 type)) (/ 1 1000))
23         for rlist = (multiple-value-list (log x))
24         for y = (car rlist)
25         repeat 1000
26         unless (and (null (cdr rlist))
27                     (typep y type))
28         collect (list x rlist)))
29  nil)
30
31(deftest log.4
32  (loop for type in '(short-float single-float double-float long-float)
33        nconc
34        (loop
35         for x = (1+ (random (coerce 1000000 type)))
36         for rlist = (multiple-value-list (log x))
37         for y = (car rlist)
38         repeat 1000
39         unless (and (null (cdr rlist))
40                     (typep y type))
41         collect (list x rlist)))
42  nil)
43
44(deftest log.5
45  (loop for type in '(short-float single-float double-float long-float)
46        for zero = (coerce 0 type)
47        nconc
48        (loop
49         for x = (- (random (coerce 1 type)))
50         for rlist = (and (/= x zero) (multiple-value-list (log x)))
51         for y = (car rlist)
52         repeat 1000
53         unless (or (= x zero)
54                    (and (null (cdr rlist))
55                         (typep y `(complex ,type))))
56         collect (list x rlist)))
57  nil)
58
59(deftest log.6
60  (loop for type in '(short-float single-float double-float long-float)
61        for zero = (coerce 0 type)
62        nconc
63        (loop
64         for x = (- (random (coerce 1000000 type)))
65         for rlist = (and (/= x zero) (multiple-value-list (log x)))
66         for y = (car rlist)
67         repeat 1000
68         unless (or (= x zero)
69                    (and (null (cdr rlist))
70                         (typep y `(complex ,type))))
71         collect (list x rlist)))
72  nil)
73
74(deftest log.7
75  (loop for type in '(short-float single-float double-float long-float)
76        for zero = (coerce 0 type)
77        nconc
78        (loop
79         for x1 = (- (random (coerce 2000 type)) 1000)
80         for x2 = (1+ (random (coerce 1000 type)))
81         for rlist = (and (/= x1 zero)
82                          (multiple-value-list (log (complex x1 x2))))
83         for y = (car rlist)
84         repeat 1000
85         unless (or (= x1 zero)
86                    (and (null (cdr rlist))
87                         (typep y `(complex ,type))))
88         collect (list x1 x2 rlist)))
89  nil)
90
91(deftest log.8
92  (loop for type in '(short-float single-float double-float long-float)
93        for zero = (coerce 0 type)
94        nconc
95        (loop
96         for x1 = (- (random (coerce 2000 type)) 1000)
97         for x2 = (- -1 (random (coerce 1000 type)))
98         for rlist = (and (/= x1 zero)
99                          (multiple-value-list (log (complex x1 x2))))
100         for y = (car rlist)
101         repeat 1000
102         unless (or (= x1 zero)
103                    (and (null (cdr rlist))
104                         (typep y `(complex ,type))))
105         collect (list x1 x2 rlist)))
106  nil)
107
108;;; FIXME
109;;; Add tests for two-arg calls
110         
111;;; FIXME
112;;; More accuracy tests here
113
114;;; Error tests
115
116(deftest log.error.1
117  (signals-error (log) program-error)
118  t)
119
120(deftest log.error.2
121  (signals-error (log 1.0 2.0 3.0) program-error)
122  t)
123
Note: See TracBrowser for help on using the repository browser.