Comparing version 0.6.1 to 0.6.2
## Release History | ||
- **0.6.2** &madsh; *2015-07-13* — Trampolines | ||
- **0.6.1** — *2015-07-13* — Bug fixes | ||
@@ -4,0 +5,0 @@ - Print stacktrace of catched exceptions |
/* @flow weak */ | ||
"use strict"; | ||
var trampa = require("trampa"); | ||
/** | ||
@@ -25,3 +27,9 @@ #### isPromise p : bool | ||
if (isPromise(p)) { | ||
return p.then(g); | ||
return p.then(function (x) { | ||
return map(x, g); | ||
}); | ||
} else if (trampa.isTrampoline(p)) { | ||
return p.jump(function (x) { | ||
return map(x, g); | ||
}); | ||
} else { | ||
@@ -60,6 +68,27 @@ return g(p); | ||
// recursively unwrap trampoline and promises | ||
function run(x) { | ||
if (isPromise(x)) { | ||
return x.then(run); | ||
} else if (trampa.isTrampoline(x)) { | ||
return run(x.run()); | ||
} else { | ||
return x; | ||
} | ||
} | ||
function pure(x) { | ||
if (isPromise(x)) { | ||
return x; | ||
} else { | ||
return trampa.wrap(x); | ||
} | ||
} | ||
module.exports = { | ||
isPromise: isPromise, | ||
map: map, | ||
pure: pure, | ||
bind: bind, | ||
run: run, | ||
}; |
@@ -296,3 +296,5 @@ /* @flow weak */ | ||
var r = property(size); | ||
// wrap non-promises in trampoline | ||
var r = functor.pure(property(size)); | ||
return functor.map(r, function (rPrime) { | ||
@@ -312,3 +314,3 @@ if (rPrime === true) { | ||
return functor.map(loop(1), function (r) { | ||
return functor.run(functor.map(loop(1), function (r) { | ||
if (r === true) { | ||
@@ -321,3 +323,3 @@ if (!opts.quiet) { console.info("OK, passed " + opts.tests + " tests"); } | ||
return r; | ||
}); | ||
})); | ||
} | ||
@@ -336,7 +338,7 @@ | ||
return functor.map(check(property, opts), function (r) { | ||
return functor.run(functor.map(check(property, opts), function (r) { | ||
if (r !== true) { | ||
throw new Error(formatFailedCase(r)); | ||
} | ||
}); | ||
})); | ||
} | ||
@@ -367,3 +369,3 @@ | ||
it(name, function () { | ||
return functor.map(args[0](), function (result) { | ||
return functor.run(functor.map(args[0](), function (result) { | ||
if (typeof result === "function") { | ||
@@ -374,3 +376,3 @@ return checkThrow(result); | ||
} | ||
}); | ||
})); | ||
}); | ||
@@ -377,0 +379,0 @@ } else { |
{ | ||
"name": "jsverify", | ||
"description": "Property-based testing for JavaScript.", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"homepage": "http://jsverify.github.io/", | ||
@@ -62,4 +62,5 @@ "author": { | ||
"rc4": "~0.1.5", | ||
"trampa": "^1.0.0", | ||
"typify-parser": "0.0.1" | ||
} | ||
} |
@@ -582,2 +582,3 @@ # JSVerify | ||
- **0.6.2** &madsh; *2015-07-13* — Trampolines | ||
- **0.6.1** — *2015-07-13* — Bug fixes | ||
@@ -584,0 +585,0 @@ - Print stacktrace of catched exceptions |
Sorry, the diff of this file is too big to display
224097
6129
774
4
+ Addedtrampa@^1.0.0
+ Addedtrampa@1.0.1(transitive)