Comparing version 0.7.1 to 0.7.2
## Release History | ||
- **0.7.2** — *2016-08-25* — One year since the last release | ||
- `jsc.utils.isEqual` returns true if both arguments are `NaN`. | ||
- Add `jsc.assertForall` and `jsc.checkForall` | ||
- **0.7.1** — *2015-08-24* — jsc.throws | ||
@@ -4,0 +7,0 @@ - Add `jsc.throws` [#133](https://github.com/jsverify/jsverify/pull/133) |
@@ -83,3 +83,3 @@ /* @flow weak */ | ||
/** | ||
- `sum(arbs: (arbitrary a, arbitrary b...)): arbitrary (a | b ...) | ||
- `sum(arbs: (arbitrary a, arbitrary b...)): arbitrary (a | b ...)` | ||
*/ | ||
@@ -86,0 +86,0 @@ function sum(arbs) { |
@@ -43,3 +43,3 @@ /* @flow weak */ | ||
FMap.prototype.get = function FMapGet(key) { | ||
FMap.prototype.get = function FMapGet(key) { // eslint-disable-line consistent-return | ||
for (var i = 0; i < this.data.length; i++) { | ||
@@ -46,0 +46,0 @@ if (this.eq(this.data[i][0], key)) { |
@@ -164,3 +164,3 @@ /* @flow weak */ | ||
function generateEither(genA, genB) { | ||
var result = generatorBless(function (size) { | ||
var result = generatorBless(function (size) { // eslint-disable-line consistent-return | ||
var n = random(0, 1); | ||
@@ -167,0 +167,0 @@ switch (n) { |
@@ -212,3 +212,3 @@ /* @flow weak */ | ||
counterexample: rr.counterexample.concat(rRecPrime.counterexample), | ||
counterexamplestr: rr.counterexamplestr ,// + "; " + rRec.counterexamplestr, | ||
counterexamplestr: rr.counterexamplestr, // + "; " + rRec.counterexamplestr, | ||
shrinks: rr.shrinks, | ||
@@ -233,3 +233,3 @@ exc: rr.exc || rRecPrime.exc, | ||
function formatFailedCase(r, state) { | ||
function formatFailedCase(r, state, includeStack) { | ||
var msg = "Failed after " + r.tests + " tests and " + r.shrinks + " shrinks. "; | ||
@@ -241,3 +241,5 @@ msg += "rngState: " + (r.rngState || state) + "; "; | ||
msg += "Exception: " + r.exc.message; | ||
msg += "\nStack trace: " + r.exc.stack; | ||
if (includeStack) { | ||
msg += "\nStack trace: " + r.exc.stack; | ||
} | ||
} else { | ||
@@ -250,3 +252,3 @@ msg += "Error: " + r.exc; | ||
function findRngState(argv) { | ||
function findRngState(argv) { // eslint-disable-line consistent-return | ||
for (var i = 0; i < argv.length - 1; i++) { | ||
@@ -314,3 +316,3 @@ if (argv[i] === "--jsverifyRngState") { | ||
if (!opts.quiet) { | ||
console.error(formatFailedCase(rPrime, state), rPrime.counterexample); | ||
console.error(formatFailedCase(rPrime, state, true), rPrime.counterexample); | ||
} | ||
@@ -346,3 +348,8 @@ return rPrime; | ||
if (r !== true) { | ||
throw new Error(formatFailedCase(r)); | ||
if (r.exc instanceof Error) { | ||
r.exc.message = formatFailedCase(r); | ||
throw r.exc; | ||
} else { | ||
throw new Error(formatFailedCase(r)); | ||
} | ||
} | ||
@@ -375,3 +382,3 @@ })); | ||
it(name, function () { | ||
return functor.run(functor.map(args[0](), function (result) { | ||
return functor.run(functor.map(args[0](), function (result) { // eslint-disable-line consistent-return | ||
if (typeof result === "function") { | ||
@@ -465,2 +472,26 @@ return checkThrow(result); | ||
/** | ||
- `assertForall(arbs: arbitrary a ..., userenv: (map arbitrary)?, prop : a -> property): void` | ||
Combines 'assert' and 'forall'. | ||
Constructs a property with forall from arguments, then throws an exception if the property doesn't hold. | ||
Options for 'assert' cannot be set here - use assert(forall(...)) if you need that. | ||
*/ | ||
function assertForall() { | ||
return checkThrow(forall.apply(null, arguments)); | ||
} | ||
/** | ||
- `checkForall(arbs: arbitrary a ..., userenv: (map arbitrary)?, prop : a -> property): result` | ||
Combines 'check' and 'forall'. | ||
Constructs a property with forall from arguments, and returns a value based on if the property holds or not. | ||
See 'check' for description of return value. | ||
Options for 'check' cannot be set here - use check(forall(...)) if you need that. | ||
*/ | ||
function checkForall() { | ||
return check(forall.apply(null, arguments)); | ||
} | ||
/** | ||
### Types | ||
@@ -508,2 +539,4 @@ | ||
assert: checkThrow, | ||
assertForall: assertForall, | ||
checkForall: checkForall, | ||
property: bddProperty, | ||
@@ -510,0 +543,0 @@ sampler: sampler, |
@@ -10,3 +10,3 @@ /* @flow weak */ | ||
var bool_fn_applied_thrice = jsc.forall("bool -> bool", "bool", check); | ||
var bool_fn_applied_thrice = jsc.forall(jsc.fn(jsc.bool()), jsc.bool(), check); | ||
var bool_fn_applied_thrice = jsc.forall(jsc.fn(jsc.bool), jsc.bool, check); | ||
``` | ||
@@ -19,7 +19,7 @@ | ||
- *square brackets* are treated as a shorthand for the array type: `"[nat]"` is evaluated to `jsc.array(jsc.nat)`. | ||
- *union*: `"bool | nat"` is evaluated to `jsc.sum(jsc.bool, jsc.nat)`. | ||
- *union*: `"bool | nat"` is evaluated to `jsc.sum([jsc.bool, jsc.nat])`. | ||
- **Note** `oneof` cannot be shrinked, because the union is untagged, we don't know which shrink to use. | ||
- *conjunction*: `"bool & nat"` is evaluated to `jsc.tuple(jsc.bool, jsc.nat)`. | ||
- *anonymous records*: `"{ b: bool; n: nat }"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`. | ||
- *EXPRIMENTAL: recursive types*: `"rec list -> unit | (nat & list)"`. | ||
- *anonymous records*: `"{ b: bool; n: nat }"` is evaluated to `jsc.record({ b: jsc.bool, n: jsc.nat })`. | ||
- *EXPERIMENTAL: recursive types*: `"rec list -> unit | (nat & list)"`. | ||
*/ | ||
@@ -26,0 +26,0 @@ |
/* @flow weak */ | ||
"use strict"; | ||
var _ = require("lodash"); | ||
var isArray = Array.isArray; | ||
@@ -35,2 +37,6 @@ function isObject(o) { | ||
if (_.isNaN(a) && _.isNaN(b)) { | ||
return true; | ||
} | ||
if (a === b) { | ||
@@ -68,2 +74,3 @@ return true; | ||
Returns `false` only if they are distinguisable not equal. | ||
Returns `true` when `x` and `y` are `NaN`. | ||
This function works with cyclic data. | ||
@@ -85,2 +92,6 @@ | ||
function loop(a, b, n) { | ||
if (_.isNaN(a) && _.isNaN(b)) { | ||
return true; | ||
} | ||
// trivial check | ||
@@ -87,0 +98,0 @@ if (a === b) { |
{ | ||
"name": "jsverify", | ||
"description": "Property-based testing for JavaScript.", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"homepage": "http://jsverify.github.io/", | ||
@@ -27,20 +27,21 @@ "author": { | ||
"devDependencies": { | ||
"bluebird": "^2.9.14", | ||
"browserify": "^11.0.0", | ||
"bluebird": "^3.1.1", | ||
"browserify": "^13.0.0", | ||
"chai": "^3.0.0", | ||
"david": "^6.0.1", | ||
"eslint": "^1.2.1", | ||
"david": "^8.0.0", | ||
"eslint": "^3.3.1", | ||
"esprima": "^2.2.0", | ||
"istanbul": "~0.3.0", | ||
"jscs": "^2.0.0", | ||
"istanbul": "^0.4.1", | ||
"jasmine-core": "^2.4.1", | ||
"jscs": "^3.0.7", | ||
"jshint": "^2.7.0", | ||
"karma": "^0.13.3", | ||
"karma-chrome-launcher": "^0.2.0", | ||
"karma-cli": "^0.1.0", | ||
"karma-firefox-launcher": "~0.1.3", | ||
"karma-jasmine": "~0.3.1", | ||
"karma-mocha": "^0.2.0", | ||
"karma": "^1.2.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-cli": "^1.0.1", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-mocha": "^1.1.1", | ||
"ljs": "~0.3.0", | ||
"lodash": "^3.9.3", | ||
"mocha": "^2.1.0", | ||
"lodash": "^4.4.0", | ||
"mocha": "^3.0.2", | ||
"npm-freeze": "^0.1.3", | ||
@@ -47,0 +48,0 @@ "q": "~2.0.2", |
@@ -171,2 +171,16 @@ # JSVerify | ||
- `assertForall(arbs: arbitrary a ..., userenv: (map arbitrary)?, prop : a -> property): void` | ||
Combines 'assert' and 'forall'. | ||
Constructs a property with forall from arguments, then throws an exception if the property doesn't hold. | ||
Options for 'assert' cannot be set here - use assert(forall(...)) if you need that. | ||
- `checkForall(arbs: arbitrary a ..., userenv: (map arbitrary)?, prop : a -> property): result` | ||
Combines 'check' and 'forall'. | ||
Constructs a property with forall from arguments, and returns a value based on if the property holds or not. | ||
See 'check' for description of return value. | ||
Options for 'check' cannot be set here - use check(forall(...)) if you need that. | ||
### Types | ||
@@ -196,3 +210,3 @@ | ||
var bool_fn_applied_thrice = jsc.forall("bool -> bool", "bool", check); | ||
var bool_fn_applied_thrice = jsc.forall(jsc.fn(jsc.bool()), jsc.bool(), check); | ||
var bool_fn_applied_thrice = jsc.forall(jsc.fn(jsc.bool), jsc.bool, check); | ||
``` | ||
@@ -205,7 +219,7 @@ | ||
- *square brackets* are treated as a shorthand for the array type: `"[nat]"` is evaluated to `jsc.array(jsc.nat)`. | ||
- *union*: `"bool | nat"` is evaluated to `jsc.sum(jsc.bool, jsc.nat)`. | ||
- *union*: `"bool | nat"` is evaluated to `jsc.sum([jsc.bool, jsc.nat])`. | ||
- **Note** `oneof` cannot be shrinked, because the union is untagged, we don't know which shrink to use. | ||
- *conjunction*: `"bool & nat"` is evaluated to `jsc.tuple(jsc.bool, jsc.nat)`. | ||
- *anonymous records*: `"{ b: bool; n: nat }"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`. | ||
- *EXPRIMENTAL: recursive types*: `"rec list -> unit | (nat & list)"`. | ||
- *anonymous records*: `"{ b: bool; n: nat }"` is evaluated to `jsc.record({ b: jsc.bool, n: jsc.nat })`. | ||
- *EXPERIMENTAL: recursive types*: `"rec list -> unit | (nat & list)"`. | ||
@@ -324,3 +338,3 @@ ### Arbitrary data | ||
- `sum(arbs: (arbitrary a, arbitrary b...)): arbitrary (a | b ...) | ||
- `sum(arbs: (arbitrary a, arbitrary b...)): arbitrary (a | b ...)` | ||
@@ -563,2 +577,3 @@ - `dict(arb: arbitrary a): arbitrary (dict a)` | ||
Returns `false` only if they are distinguisable not equal. | ||
Returns `true` when `x` and `y` are `NaN`. | ||
This function works with cyclic data. | ||
@@ -601,2 +616,5 @@ | ||
- **0.7.2** — *2016-08-25* — One year since the last release | ||
- `jsc.utils.isEqual` returns true if both arguments are `NaN`. | ||
- Add `jsc.assertForall` and `jsc.checkForall` | ||
- **0.7.1** — *2015-08-24* — jsc.throws | ||
@@ -603,0 +621,0 @@ - Add `jsc.throws` [#133](https://github.com/jsverify/jsverify/pull/133) |
Sorry, the diff of this file is too big to display
282503
7824
818
23