This repository has been archived by the owner on Mar 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-suite.lisp
76 lines (69 loc) · 2.26 KB
/
test-suite.lisp
1
2
3
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
71
72
73
74
75
76
(fiasco:define-test-package :maxima-interface-test
(:use :maxima-interface))
(in-package :maxima-interface-test)
(deftest test-evaluate ()
(macrolet ((is-identity (&body body)
"Auxiliary macro for TEST-EVALUATE."
(let ((sexp (gensym)))
`(loop :for ,sexp :in ',body :do
(is (equalp (evaluate ,sexp) ,sexp))))))
(is-identity
(= a b)
(/= a b)
(+ a b)
(* a b)
(expt x n)
(log x)
(sin x)
(cos x)
(tan x)
(asin x)
(acos x)
(atan y)
(atan y x)
(sinh x)
(cosh x)
(tanh x)
(asinh x)
(acosh x)
(atanh y)
(abs x)
(signum x)
(mod x p)
pi
e
inf
(f x y)))
(is (equalp (evaluate '(- a b)) '(+ a (* -1 b))))
(is (zerop (evaluate '(- a a))))
(is (equalp (evaluate '(1+ x)) '(+ 1 x)))
(is (equalp (evaluate '(1- x)) '(+ -1 x)))
(is (equalp (evaluate '(exp x)) '(expt (exp 1) x)))
(is (equalp (evaluate '(log x b)) '(* (expt (log b) -1) (log x))))
(is (equalp (evaluate '(/ a b)) '(* a (expt b -1))))
(is (equalp (evaluate '(sqrt x)) '(expt x (/ 1 2))))
(is (equalp (evaluate 'i) '(complex 0 1)))
(is (equalp (evaluate '(diff (f x y) x)) '(diff (f x y) x 1))))
(deftest test-expand ()
(is (equalp (expand '(expt (+ x y) 2))
'(+ (expt x 2) (* 2 x y) (expt y 2)))))
(deftest test-simplify ()
(is (= 1 (simplify '(+ (expt (cos x) 2) (expt (sin x) 2)))))
(is (eql (simplify '(/ (1- (1+ x)) 1)) 'x)))
(deftest test-diff ()
(is (equalp (evaluate '(diff (cos x) x)) '(* -1 (sin x))))
(is (equalp (evaluate '(diff '(expt (exp 1) x) 'x)) '(expt (exp 1) x)))
(is (equalp (diff '(expt (exp 1) x) 'x) '(expt (exp 1) x))))
(deftest test-integrate ()
(is (equalp (integrate 'x 'x)
'(* (/ 1 2) (expt x 2))))
(is (equalp (integrate 'x 'x 0 1)
'(/ 1 2)))
(is (equalp (integrate '(exp (- (expt x 2))) 'x '(- inf) 'inf)
'(expt pi (/ 1 2))))
(is (equalp (integrate '(f x) 'x '(- inf) 'inf)
'(integrate (f x) x (* -1 inf) inf))))
(deftest test-limit ()
(is (eql (limit '(- inf 1)) 'inf))
(is (= 1 (limit '(/ (sin x) x) 'x 0 'plus)))
(is (equalp (limit '(f x) 'x 0 'plus) '(limit (f x) x 0 plus))))