Awesome
Claire
Claire is a random testing library for both property-based testing (QuickCheck-like) and random program generation (ScalaCheck command's like), which allows you to express your code's behaviours and invariants in a clear way.
Example
var claire = require('claire')
var _ = claire.data
var forAll = claire.forAll
var commutative_p = forAll( _.Int, _.Int ).satisfy( function(a, b) {
return a + b == b + a
}).asTest()
// + OK passed 100 tests.
var identity_p = forAll(_.Int).satisfy(function(a) {
return a == a + 1
})
identity_p.asTest({ verbose: true, times: 100 })()
// <property failed>: ! Falsified after 1 tests, 1 failed.
//
// : Failure #1 --------------------
//
//
// : The following arguments were provided:
// 0 - 93 (<int>)
//
// (Stack trace)
Installing
The easiest way is to grab it from NPM. If you're running in a Browser environment, you can use Browserify
$ npm install claire
Using with CommonJS
If you're not using NPM, Download the latest release, and require
the claire.umd.js
file:
var claire = require('claire')
Using with AMD
Download the latest release, and require the claire.umd.js
file:
require(['claire'], function(claire) {
( ... )
})
Using without modules
Download the latest release, and load the claire.umd.js
file. The properties are exposed in the global claire
object:
<script src="/path/to/claire.umd.js"></script>
Compiling from source
If you want to compile this library from the source, you'll need Git, Make, Node.js, and run the following commands:
$ git clone git://github.com/robotlolita/claire.git
$ cd claire
$ npm install
$ make bundle
This will generate the dist/claire.umd.js
file, which you can load in
any JavaScript environment.
Documentation
You can read the documentation online or build it yourself:
$ git clone git://github.com/robotlolita/claire.git
$ cd claire
$ npm install
$ make documentation
Then open the file docs/manual/build/html/index.html
in your browser.
Platform support
This library assumes an ES5 environment, but can be easily supported in ES3 platforms by the use of shims. Just include es5-shim :)
Licence
Copyright (c) 2013-2014 Quildreen Motta.
Released under the MIT licence.
<!-- links --> <!-- [release: https://github.com/robotlolita/claire/releases/download/v$VERSION/claire-$VERSION.tar.gz] --> <!-- [/release] -->