claire
Property-based testing library (à lá QuickCheck/ScalaCheck).
Last updated 14 years ago by killdream .
MIT · Repository · Original npm · Tarball · package.json
$ npm install claire 
SYNC missed versions from official npm registry.

Claire Build Status

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.

Platform support

Claire should work neatly in all ES5 platforms. ES3 platforms (IE8-, etc) can use es5-shim to provide the fallbacks necessary.

Things are frozen to ensure immutability, but legacy engines can do without, so Object.freeze = function(a) { return a } is okay.

browser support

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

Just grab it from NPM:

npm install claire

Documentation

A reference of the API can be built using Calliope:

$ npm install -g calliope
$ calliope build

A fully narrated documentation explaining the concepts behind the library is planned for a future release. Current WIP can be found at http://claire.readthedocs.org/.

Tests

You can run all tests using Mocha:

$ npm test

Licence

MIT/X11. ie.: do whatever you want.

Current Tags

  • 0.4.1                                ...           latest (14 years ago)

7 Versions

  • 0.4.1                                ...           14 years ago
  • 0.3.4                                ...           14 years ago
  • 0.3.3                                ...           14 years ago
  • 0.3.2                                ...           14 years ago
  • 0.3.0                                ...           14 years ago
  • 0.2.0                                ...           14 years ago
  • 0.1.0                                ...           14 years ago
Maintainers (1)
Downloads
Total 22
Today 0
This Week 0
This Month 14
Last Day 0
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE