X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Frandom.lisp;h=9b94f40e8f5b95e7dce93e61674c180b9dea39e7;hb=3f3b31a89b5019d7a4c020de6eab33e409395b46;hp=0f66f84ec41191b5911aa2129492b73fec47578c;hpb=7eaa508b294d8a3d3fa96c1b9ef78f45feec8417;p=fiveam.git diff --git a/src/random.lisp b/src/random.lisp index 0f66f84..9b94f40 100644 --- a/src/random.lisp +++ b/src/random.lisp @@ -2,7 +2,7 @@ (in-package :it.bese.FiveAM) -;;;; * Random (QuickCheck-ish) testing +;;;; ** Random (QuickCheck-ish) testing ;;;; FiveAM provides the ability to automatically generate a ;;;; collection of random input data for a specific test and run a @@ -104,7 +104,7 @@ returning true. This second run limit prevents that.") (defclass for-all-test-never-run (test-failure for-all-test-result) ()) -;;;; ** Generators. +;;;; *** Generators ;;;; Since this is random testing we need some way of creating random ;;;; data to feed to our code. Generators are regular functions whcih @@ -120,8 +120,14 @@ returning true. This second run limit prevents that.") (min (1+ most-negative-fixnum))) (+ min (random (1+ (- max min))))) -(defgenerator gen-character (&key (code (gen-integer :min 0 :max (1- char-code-limit)))) - (code-char (funcall code))) +(defgenerator gen-character (&key (code (gen-integer :min 0 :max (1- char-code-limit))) + (alphanumericp nil)) + (if alphanumericp + (code-char (funcall code)) + (loop + for char = (code-char (funcall code)) + until (alphanumericp char) + finally (return char)))) (defun gen-string (&key (length (gen-integer :min 0 :max 80))