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.
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)
The easiest way is to grab it from NPM. If you're running in a Browser environment, you can use Browserify
$ npm install claire
If you're not using NPM, Download the latest release, and require
the claire.umd.js
file:
var claire = require('claire')
Download the latest release, and require the claire.umd.js
file:
require(['claire'], function(claire) {
( ... )
})
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>
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.
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.
This library assumes an ES5 environment, but can be easily supported in ES3 platforms by the use of shims. Just include es5-shim :)
Copyright (c) 2013-2014 Quildreen Motta.
Released under the MIT licence.