aboutsummaryrefslogtreecommitdiff
path: root/examples.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'examples.lisp')
-rw-r--r--examples.lisp25
1 files changed, 24 insertions, 1 deletions
diff --git a/examples.lisp b/examples.lisp
index 9ceb234..831cb09 100644
--- a/examples.lisp
+++ b/examples.lisp
@@ -1,13 +1,18 @@
(defpackage :testiere.examples
(:use #:cl)
(:import-from #:testiere
- #:defun/t))
+ #:defun/t
+ #:with-stubs))
(in-package :testiere.examples)
+(defun test-fibble ()
+ (assert (= 13 (fibble 1 2))))
+
(defun/t fibble (x y &key (z 10))
"Hey, a docstring."
:tests
+ (:program test-fibble)
(= (1 2) 13)
(>= (1 2 :z 1) -5)
(:outputp (0 10 :z 0) (lambda (result) (equalp result 10)))
@@ -52,3 +57,21 @@
(just-a-function))
+(defun make-drakma-request ()
+ "Make an HTTP request using DRAKMA"
+ ;; implemented elsewhere
+ )
+
+(defun test-url-word-counter ()
+ (with-stubs
+ ((make-drakma-request () "one two three four five six seven"))
+ (assert (= (count-words) 7))))
+
+(defun/t count-words ()
+ "Fetches a url and counts now many words the page contains."
+ :tests
+ (:program test-url-word-counter)
+ :end
+ (let ((fetched
+ (make-drakma-request)))
+ (1+ (count #\space fetched))))