((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/test-generative" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "test-generative" (toc) (section 3 "Requirements" (p (int-link "/egg/test" "test"))) (section 3 "Repository" (p (link "https://bitbucket.org/certainty/test-generative/overview"))) (section 3 "Authors" (p (int-link "/users/david-krentzlin" "David Krentzlin"))) (section 3 "Introduction" (p "This egg integrates " (link "http://www.cse.chalmers.se/~rjmh/QuickCheck/" "quickcheck-like") " testing on top of our very excellent " (int-link "/egg/test" "test egg") ".") (p "It allows you to throw a bunch of random inputs at your " (b "pure") " code and use the well known test macros to verify its behavior. This way you don't have to learn a new testing API but still get the benefits of random testing for your pure code.") (p "This library is not meant to replace traditional manual unit tests but shall serve as an additional way to test your code.")) (section 3 "Examples " (highlight scheme "(use test test-generative)\n\n(test-generative ((the-number (lambda () (random 100))))\n   (test-assert \"it's numeric\"  (number? the-number))\n   (test-assert \"it's positive\" (positive? the-number))\n   (test-assert \"it's smaller than 50\" (< the-number 50)))") (p "Which outputs something like:") (highlight raw "it's numeric ......................................................... [ PASS]\nit's positive ........................................................ [ PASS]\nit's smaller than 50 ................................................. [ FAIL]\n    assertion failed\n    (< the-number 50)\n    iteration: 4\n    seeds: ((the-number 68))") (p "As you can see, the last assertion failed after the 4th iteration with the value 68 which is obviously not smaller than 50.")) (section 3 "API" (def (sig (parameter "current-test-generative-iterations" (id current-test-generative-iterations))) (p "The number of iterations each test shall use. This means that this amout of random inputs will be chosen to exercise your test code. This also means that your test code will be run at least that amount of times. That's why you probably want to avoid side-effecting code with these kinds of tests. The current default is '" (i "100") ".")) (def (sig (syntax "(test-generative ((binding gen) ...) body ...)" (id test-generative))) (p "This allows you to declare a set of generators specified by " (b "gen") " and refer to them by names that are specified as " (b "binding") "s in your test code. It will exercise the code at most " (b "current-test-generative-iterations") " + 1 amount of times with your random data and stop as soon as one of your tests fails. If a test has failed it shows the iteration in which it failed and the seed-values that have been used in that iteration.") (p (b "What is a generator?:") " A generator is just a thunk that is expected to return the data upon invokation."))) (section 3 "See also" (p "If you want to use predefined generators for a lot of common types, have a look at " (int-link "/egg/data-generators" "data-generators"))) (section 3 "License" (pre "This program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or (at\nyour option) any later version.") (pre "This program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nGeneral Public License for more details.") (pre "A full copy of the GPL license can be found at\n<http://www.gnu.org/licenses/>."))))