From 91533257d3ddf97a5d9cc670d6ec5d4e824af025 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 20 Mar 2022 09:38:48 -0500 Subject: [feature] added with-stubs, updated [docs] --- examples.lisp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'examples.lisp') 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)))) -- cgit v1.2.3