Last updated: 2015-11-25 18:02:43 +0000
Upstream URL: git clone http://chriswarbo.net/git/php-easycheck.git
Contents of README follows
= EasyCheck =
A basic property-checking framework, in the spirit of QuickCheck.
EasyCheck defines three functions:
<ul> <li><code>deftest(string $description, callable $test)</code> for defining a test</li> <li><code>deftests([$description => $test])</code> for defining multiple tests</li> <li><code>runtests(null)</code> for running all tests</li> </ul>== Tests ==
Tests can be any callable and can take any number of arguments; EasyCheck will count the required argument number and supply that many random numbers.
Tests can indicate a pass by returning falsy values (false, null, 0, [], ’’). To indicate a failure, return a truthy value; this will usually be an error message or some debugging information.
== Usage ==
Internally, tests are kept in an array and keyed by their descriptions, which can be any unique string.
<code>runtests(null)</code> will execute all tests, returning an array of truthy results (ie. the failures).
== Examples ==
<pre><code>deftest('All ints are > or <=', function($x, $y) { $gt = $x > $y; $lte = $x <= $y; return ($gt || $lte)? 0 : get_defined_vars(); });</code></pre>