Added t/examples.lisp to the qbook output
authorMarco Baringer <mb@bese.it>
Sun, 22 Jan 2006 15:27:50 +0000 (16:27 +0100)
committerMarco Baringer <mb@bese.it>
Sun, 22 Jan 2006 15:27:50 +0000 (16:27 +0100)
fiveam.asd
src/packages.lisp
t/example.lisp

index fc0f9ca..372609d 100644 (file)
@@ -30,3 +30,5 @@
   (funcall (intern (string :run!) (string :it.bese.FiveAM)) :it.bese.FiveAM))
 
 ;;;;@include "src/packages.lisp"
+
+;;;;@include "t/example.lisp"
index d880069..608a9d3 100644 (file)
@@ -2,8 +2,6 @@
 
 ;;;; * Introduction
 
-;;;; FiveAM is A simple Common Lisp unit testing library.
-
 ;;;; FiveAM is a testing framework. It takes care of all the boring
 ;;;; bookkeeping associated with managing a test framework allowing
 ;;;; the developer to focus on writing tests and code.
 ;;;; FiveAM was designed with the following premises:
 
 ;;;; - Defining tests should be about writing tests, not
-;;;;   infrastructure. The developer should be able to focus on what
-;;;;   they're testing, not the testing framework.
+;;;; infrastructure. The developer should be able to focus on what
+;;;; they're testing, not the testing framework.
 
 ;;;; - Interactive testing is the norm. Common Lisp is an interactive
-;;;;  development environment, the testing environment should allow
-;;;;  the developer to quickly and easily redefine, change, remove
-;;;;  and run tests.
+;;;; development environment, the testing environment should allow the
+;;;; developer to quickly and easily redefine, change, remove and run
+;;;; tests.
 
 (defpackage :it.bese.FiveAM
   (:use :common-lisp :it.bese.arnesi)
 
 ;;;;@include "check.lisp"
 
-;;;;@include "test.lisp"
+;;;;@include "random.lisp"
 
 ;;;;@include "fixture.lisp"
 
+;;;;@include "test.lisp"
+
 ;;;;@include "suite.lisp"
 
 ;;;;@include "run.lisp"
 
 ;;;;@include "explain.lisp"
 
-;;;; * Examples
-
-#| (def-suite my-suite :description "My Example Suite")
-
- (in-suite my-suite)
-
- (test my-tests
-  "Example"
-  (is (= 4 (+ 2 2)) "2 plus 2 wasn't equal to 4 (using #'= to test equality)")
-  (is (= 0 (+ -1 1)))
-  (throws (error "Trying to add 4 to FOO didn't signal an error")
-     (+ 'foo 4))
-  (is (= 0 (+ 1 1)) "this should have failed"))
-
- (run! 'my-suite)
-;; Running suite MY-SUITE
-..F.
-Suite My Example Suite ran 4 tests (3/0/1) - 1 FAILED -
-Failed Tests:
-MY-TESTS FAILED: (+ 1 1) was not = to 0 (returned 2 instead)
-   Description: Example.
-   Message:     this should have failed
-NIL |#
-
 ;;;; * Colophon
 
 ;;;; This documentaion was written by Edward Marco Baringer
index 87c89f7..5424f49 100644 (file)
@@ -1,4 +1,6 @@
-;;;; -*- lisp -*-
+;; -*- lisp -*-
+
+;;;; * FiveAM Example (poor man's tutorial)
 
 (asdf:oos 'asdf:load-op :FiveAM)
 
@@ -8,7 +10,7 @@
 
 (in-package :it.bese.FiveAM.example)
 
-;;; First we need some functions to test.
+;;;; First we need some functions to test.
 
 (defun add-2 (n)
   (+ n 2))
 (defun add-4 (n) 
   (+ n 4))
 
-;;; Now we need to create a test which makes sure that add-2 and add-4
-;;; work as specified.
+;;;; Now we need to create a test which makes sure that add-2 and add-4
+;;;; work as specified.
 
-;; we create a test named ADD-2 and supply a short description.
+;;;; we create a test named ADD-2 and supply a short description.
 (test add-2
  "Test the ADD-2 function" ;; a short description
  ;; the checks
  (is (= 2 (add-2 0)))
  (is (= 0 (add-2 -2))))
 
-;; we can already run add-2. This will return the list of test
-;; results, it should be a list of two test-passed objects.
+;;;; we can already run add-2. This will return the list of test
+;;;; results, it should be a list of two test-passed objects.
 
 (run 'add-2) 
 
-;; since we'd like to have some kind of readbale output we'll explain
-;; the results
+;;;; since we'd like to have some kind of readbale output we'll explain
+;;;; the results
 
-(explain *)
+(explain! (run 'add-2))
 
-;; or we could do both at once:
+;;;; or we could do both at once:
 
 (run! 'add-2)
 
-;;; So now we've defined and run a single test. Since we plan on
-;;; having more than one test and we'd like to run them together let's
-;;; create a simple test suite.
+;;;; So now we've defined and run a single test. Since we plan on
+;;;; having more than one test and we'd like to run them together let's
+;;;; create a simple test suite.
 
 (def-suite example-suite :description "The example test suite.")
 
-;; we could explictly specify that every test we create is in the the
-;; example-suite suite, but it's easier to just change the default
-;; suite:
+;;;; we could explictly specify that every test we create is in the the
+;;;; example-suite suite, but it's easier to just change the default
+;;;; suite:
 
 (in-suite example-suite)
 
-;; now we'll create a new test for the add-4 function.
+;;;; now we'll create a new test for the add-4 function.
 
 (test add-4
   (is (= 0 (add-4 -4))))
 
-;; now let's run the test
+;;;; now let's run the test
 
 (run! 'add-4)
 
-;; we can get the same effect by running the suite:
+;;;; we can get the same effect by running the suite:
 
 (run! 'example-suite)
 
-;; since we'd like both add-2 and add-4 to be in the same suite, let's
-;; redefine add-2 to be in this suite:
+;;;; since we'd like both add-2 and add-4 to be in the same suite, let's
+;;;; redefine add-2 to be in this suite:
 
 (test add-2 "Test the ADD-2 function"
  (is (= 2 (add-2 0)))
  (is (= 0 (add-2 -2))))
 
-;; now we can run the suite and we'll see that both add-2 and add-4
-;; have been run (we know this since we no get 4 checks as opposed to
-;; 2 as before.
+;;;; now we can run the suite and we'll see that both add-2 and add-4
+;;;; have been run (we know this since we no get 4 checks as opposed to
+;;;; 2 as before.
 
 (run! 'example-suite)
 
-;; Just for fun let's see what happens when a test fails. Again we'll
-;; redefine add-2, but add in a third, failing, check:
+;;;; Just for fun let's see what happens when a test fails. Again we'll
+;;;; redefine add-2, but add in a third, failing, check:
 
 (test add-2 "Test the ADD-2 function"
  (is (= 2 (add-2 0)))
  (is (= 0 (add-2 -2)))
  (is (= 0 (add-2 0))))
 
-;; Finally let's try out the specification based testing.
+;;;; Finally let's try out the specification based testing.
 
 (defun dummy-add (a b)
   (+ a b))
   (for-all ((result (gen-integer :min 0 :max 1)))
     (is (plusp result))
     (is (= result 0))))
+
+(run! 'example-suite)