All Projects → gampleman → Quick_check.js

gampleman / Quick_check.js

A JS implementation of quick_check

Programming Languages

coffeescript
4710 projects

Projects that are alternatives of or similar to Quick check.js

quick.py
Property-based testing library for Python
Stars: ✭ 15 (-68.75%)
Mutual labels:  quickcheck, property-based-testing
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (+41.67%)
Mutual labels:  quickcheck, property-based-testing
fuzz-rest-api
Derive property based testing fast-check into a fuzzer for REST APIs
Stars: ✭ 38 (-20.83%)
Mutual labels:  quickcheck, property-based-testing
Fsharp Hedgehog
Release with confidence, state-of-the-art property testing for .NET.
Stars: ✭ 219 (+356.25%)
Mutual labels:  property-based-testing, quickcheck
Stream data
Data generation and property-based testing for Elixir. 🔮
Stars: ✭ 597 (+1143.75%)
Mutual labels:  property-based-testing, quickcheck
Rantly
Ruby Imperative Random Data Generator and Quickcheck
Stars: ✭ 241 (+402.08%)
Mutual labels:  property-based-testing, quickcheck
efftester
Effect-Driven Compiler Tester for OCaml
Stars: ✭ 37 (-22.92%)
Mutual labels:  quickcheck, property-based-testing
Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+5325%)
Mutual labels:  property-based-testing, quickcheck
Quicktheories
Property based testing for Java 8
Stars: ✭ 483 (+906.25%)
Mutual labels:  property-based-testing, quickcheck
edd
Erlang Declarative Debugger
Stars: ✭ 20 (-58.33%)
Mutual labels:  quickcheck, property-based-testing
Rapid
Rapid is a Go library for property-based testing that supports state machine ("stateful" or "model-based") testing and fully automatic test case minimization ("shrinking")
Stars: ✭ 213 (+343.75%)
Mutual labels:  property-based-testing, quickcheck
Jqf
JQF + Zest: Coverage-guided semantic fuzzing for Java.
Stars: ✭ 340 (+608.33%)
Mutual labels:  property-based-testing, quickcheck
Qcheck
QuickCheck inspired property-based testing for OCaml.
Stars: ✭ 194 (+304.17%)
Mutual labels:  property-based-testing, quickcheck
quickcheck
Randomized testing for Prolog à la QuickCheck
Stars: ✭ 18 (-62.5%)
Mutual labels:  quickcheck, property-based-testing
Quickcheck State Machine
Test monadic programs using state machine based models
Stars: ✭ 192 (+300%)
Mutual labels:  property-based-testing, quickcheck
ava-fast-check
Property based testing for AVA based on fast-check
Stars: ✭ 44 (-8.33%)
Mutual labels:  quickcheck, property-based-testing
Qcstm
A simple state-machine framework for OCaml based on QCheck
Stars: ✭ 50 (+4.17%)
Mutual labels:  property-based-testing, quickcheck
Swiftcheck
QuickCheck for Swift
Stars: ✭ 1,319 (+2647.92%)
Mutual labels:  property-based-testing, quickcheck
pbt-frameworks
An overview of property-based testing functionality
Stars: ✭ 29 (-39.58%)
Mutual labels:  quickcheck, property-based-testing
Junit Quickcheck
Property-based testing, JUnit-style
Stars: ✭ 821 (+1610.42%)
Mutual labels:  property-based-testing, quickcheck

quick_check.js

quick_check.js is an implementation of QuickCheck in JavaScript. (Actually the implementation is written in CoffeeScript, but that doesn't matter much).

Note: I would now recommend new users to look into fast-check which is a more modern alternative to this project.

It works by integrating with existing test libraries. For example Jasmine expectations are written like this:

// implementation
function odd(n) {
  return n % 2 === 1;
}
// tests
it('#odd returns true for odd numbers', function() {
  expect(function(i) {
    return odd(2 * i + 1);
  }).forAll(qc.int)
});

Notice the forAll(qc.int). This indicates that our function (called property) should return true for all integers passed to it. This code in fact contains a bug which quick_check.js will helpfully find for you:

PhantomJS 1.9.7 (Mac OS X) #odd returns true for odd numbers FAILED
  Falsified after 3 attempts. Counter-example: -4

This means that quick_check.js generated 3 random integers and one of them failed the test (in this case -4). (Why? Because modulus operator in JavaScript is botched).

QuickCheck will stop after 100 generated test cases and assume that your code works.

For more information read the docs, check out my talk or read the annotated source code or the introductory blog post.

Installing

Karma + Jasmine combo should be supported easily. Simply npm install quick_check --save-dev, then add 'node_modules/quick_check/dist/quick-check.js' to your files config.

See more integrations

Generators

quick_check.js comes with batteries included. There are plenty of generators included plus it is very easy to write your own. I recommend checking out the docs, but here is a quick rundown:

Basic generators

  • qc.bool
  • qc.byte
  • qc.constructor(cons)
  • qc.fromFunction(fn)

Number generators

Almost all number generators have a large variant for generating larger numbers, as the standard generators tend not to generate numbers bigger than 10,000. The generators prefixed with u generate only positive numbers.

  • qc.ureal and qc.ureal.large
  • qc.real and qc.real.large
  • qc.uint and qc.uint.large
  • qc.int and qc.int.large
  • qc.int.between(min, max)
  • qc.natural and qc.natural.large
  • qc.range([gen])
  • qc.range.inclusive([gen])
  • qc.dice(diceDSL)

String generators

  • qc.char
  • qc.string
  • qc.string.ascii
  • qc.string.concat
  • qc.string.matching

Array generators

  • qc.arrayOf(generator[, options])
  • qc.array
  • qc.array.subsetOf(array[, options])

Object generators

  • qc.object
  • qc.objectLike(template)
  • qc.objectOf(valGen[, keyGen])

Function generators

  • qc.function
  • qc.procedure

Misc generators

  • qc.date
  • qc.any
  • qc.any.simple
  • qc.any.datatype
  • qc.color
  • qc.location

Generator combinators

These combinator functions are meant to create new generators out of other generators.

  • qc.oneOf
  • qc.oneOfByPriority
  • qc.except

Maintained By

Jakub Hampl - http://gampleman.eu

License

The MIT License (MIT)

Copyright (c) 2014 RightScale

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].