summaryrefslogtreecommitdiff
path: root/cl/tests
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-13 09:54:12 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-13 09:54:12 -0600
commit2e284b71500a1f8dc6cc46ecf21eb1e9389ea780 (patch)
treee9227f4ad4e9987dcc64055803ab3e70a5e801ce /cl/tests
parent2cb14ebf79dd43aa96d54e65a0841d195d07bdf9 (diff)
downloadcmath-2e284b71500a1f8dc6cc46ecf21eb1e9389ea780.tar.gz
cmath-2e284b71500a1f8dc6cc46ecf21eb1e9389ea780.zip
new table macro, notes for 9/11
Diffstat (limited to 'cl/tests')
-rw-r--r--cl/tests/approx.lisp3
-rw-r--r--cl/tests/table.lisp31
2 files changed, 33 insertions, 1 deletions
diff --git a/cl/tests/approx.lisp b/cl/tests/approx.lisp
index a458e66..2fd8124 100644
--- a/cl/tests/approx.lisp
+++ b/cl/tests/approx.lisp
@@ -15,9 +15,10 @@
:description "derivative at is within bounds"
(let ((f (lambda (x) (* x x)))
(x 2)
+ (accepted-delta 0.02)
(f-prime-at-x 4)
(delta 0.01))
(is (within-range-p
(derivative-at f x delta)
f-prime-at-x
- 0.1))))
+ accepted-delta))))
diff --git a/cl/tests/table.lisp b/cl/tests/table.lisp
new file mode 100644
index 0000000..33d4e86
--- /dev/null
+++ b/cl/tests/table.lisp
@@ -0,0 +1,31 @@
+(defpackage lizfcm/tests.table
+ (:use :cl
+ :fiveam
+ :lizfcm.utils
+ :lizfcm/tests)
+ (:export :approx-suite))
+(in-package :lizfcm/tests.table)
+
+(def-suite table-suite
+ :in lizfcm-test-suite)
+(in-suite table-suite)
+
+(defun fib (n)
+ (cond ((< n 2) n)
+ (t (+ (fib (- n 1)) (fib (- n 2))))))
+
+(test table-of-fib-vals
+ :description "table generates correctly"
+ (let* ((headers '("n" "fib(n)"))
+ (n-values '((1) (2) (3) (4)))
+ (expected `(("n" "fib(n)")
+ (1 ,(fib 1))
+ (2 ,(fib 2))
+ (3 ,(fib 3))
+ (4 ,(fib 4))))
+ (tabled (lizfcm.utils:table (:headers headers
+ :domain-order (n)
+ :domain-values n-values)
+ (fib n))))
+ (is (equal expected tabled))))
+