summaryrefslogtreecommitdiff
path: root/cl/tests
diff options
context:
space:
mode:
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))))
+