numbers.lisp 3.29 KB
Newer Older
1
2
;; Test math functions on numbers
;; Liam Healy 2010-12-24 13:54:53EST numbers.lisp
3
;; Time-stamp: <2013-11-23 11:17:44EST numbers.lisp>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(in-package :antik)

(lisp-unit:define-test numbers
    (lisp-unit::assert-numerical-equal
     2.0d0
     (+ 1.0d0 1.0d0))
  (lisp-unit::assert-numerical-equal
   1.0d0
   (+ 1.0d0))
  (lisp-unit::assert-numerical-equal
   -1.0d0
   (+ 1.0d0 3.0d0 -5.0d0))
  (lisp-unit::assert-numerical-equal
   0.0d0
   (- 1.0d0 1.0d0))
  (lisp-unit::assert-numerical-equal
   -1.0d0
   (- 1.0d0))
  (lisp-unit::assert-numerical-equal
   3.0d0
   (- 1.0d0 3.0d0 -5.0d0))
  (lisp-unit::assert-numerical-equal
   -15.0d0
   (* 3.0d0 -5.0d0))
  (lisp-unit::assert-numerical-equal
   -30.0d0
   (* 2.0d0 3.0d0 -5.0d0))
  (lisp-unit::assert-numerical-equal
   2.0d0
   (* 2.0d0))
  (lisp-unit::assert-numerical-equal
   0.5d0
   (/ 1.0d0 2.0d0))
  (lisp-unit::assert-numerical-equal
   0.5d0
   (/ 2.0d0))
  (lisp-unit::assert-numerical-equal
   2.0d0
   (sqrt 4.0d0))
  (lisp-unit::assert-numerical-equal
   1.0d0
   (cos 0.0d0))
  (lisp-unit::assert-numerical-equal
   0.0d0
   (sin 0.0d0))
  (lisp-unit::assert-numerical-equal
   0.0d0
   (tan 0.0d0))
  (lisp-unit::assert-numerical-equal
   0.0d0
71
72
   ;; (pqval (asin 0.0d0))
   (asin 0.0d0))
73
74
  (lisp-unit::assert-numerical-equal
   0.0d0
75
76
   ;; (pqval (acos 1.0d0))
   (acos 1.0d0))
77
78
  (lisp-unit::assert-numerical-equal
   0.0d0
79
80
   ;; (pqval (atan 0.0d0))
   (atan 0.0d0))
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  (lisp-unit::assert-numerical-equal
   27.0d0
   (expt 3.0d0 3))
  (lisp-unit:assert-error
   'making-complex-number
   (expt -3.0d0 1/2))
  (lisp-unit::assert-numerical-equal
   2.718281828459045d0
   (exp 1.0d0))
  (lisp-unit::assert-numerical-equal
   1.0d0
   (log 2.718281828459045d0))
  (lisp-unit::assert-numerical-equal
   1.0d0
   (abs -1.0d0))
  (lisp-unit:assert-true
   (> 5.0d0 4.0d0))
  (lisp-unit:assert-false
   (< 5.0d0 4.0d0))
  (lisp-unit:assert-true
   (>= 5.0d0 4.0d0))
  (lisp-unit:assert-false
   (<= 5.0d0 4.0d0))
  (lisp-unit:assert-false
   (= 5.0d0 4.0d0))
  (lisp-unit:assert-true
   (= 4.0d0 4.0d0))
  (lisp-unit:assert-true
   (plusp 4.0d0))
  (lisp-unit:assert-true
   (minusp -4.0d0))
  (lisp-unit:assert-false
   (zerop -4.0d0))
  (lisp-unit:assert-true
   (zerop 0.0d0))
  (lisp-unit::assert-numerical-equal
   2.0d0
   (floor 5.0d0 2.0d0))
  (lisp-unit::assert-numerical-equal
   2.0d0
   (round 5.0d0 3.0d0))
  (lisp-unit::assert-numerical-equal
   -1.0d0
   (signum -5.0d0))
  (lisp-unit::assert-numerical-equal
   -1.0d0
   (min -1.0d0 19.3d0 12.25d0))
  (lisp-unit::assert-numerical-equal
   19.3d0
   (max -1.0d0 19.3d0 12.25d0)))