-
-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Labels
Description
1am is a classic CL testing framework that fits on a page.
1am
is also a good testing framework for beginners because it is easy to learn for small projects.
I'd like to see a tutorial using it.
Here are some draft ideas for relevant content from my notes in discussion with phoe:
(ql:quickload :1am)
(ql:quickload :alexandria)
(add-package-local-nickname :a :alexandria)
(defun my-length (l)
"Takes the length of a list or vector."
(etypecase l
(list (list-length l))
(vector (array-dimension l 0))))
(defun test-my-length ()
"Testing my-length with 1am."
(1am:is (= 12 (my-length (a:iota 12))))
(1am:is (= 12 (my-length (coerce (a:iota 12) 'vector))))
;; Check that passing a keyword signals an error.
(1am:signals type-error (= :hahaha (my-length (coerce (a:iota 12) 'vector))))
(1am:signals type-error (= :hahaha (my-length (a:iota 12)))))
(test-my-length)