v0.7.0 brings Shrinking and TypeScript
I'm pleased to announce 0.7.0, which very well may be the biggest release to date. I would like to thank Tom Pietrosanti for contributing to this release.
Shrinking
This release brings in Shrinking, which can simplify the test cases being generated. Imagine the following (made up) test:
it('never matches the magic regexp', function() {
var magicRegexp = /a.*b/;
expect(function(string) {
return !magicRegexp.test(string);
}).forAll(qc.string.ascii);
});
it 'never matches the magic regexp', ->
magicRegexp = /a.*b/
expect (string) -> !magicRegexp.test string
.forAll(qc.string.ascii)
it('never matches the magic regexp', function() {
let magicRegexp = /a.*b/;
expect((string) => !magicRegexp.test(string)).forAll(qc.string.ascii);
});
This test will obviously fail as soon as a string where an a
occurs before a b
is encountered. Before shrinking however, you might get a string like this in your error message: OoxGiF6Ah8Bdq6iBWwAI_YKI3E32Q4V1aadb7FlDr0TtWH9b_BTOFgBeqcVxBlD19Nz
. While it certainly does fail the test, it is difficult to see what exactly is going on. In the new version you will see that the test case will be further reduced until you get this lovely string back: ab
(we will show you the original string as well in case something went wrong with the shrinking process). This makes it very easy to find the bug.
TypeScript
If you use TypeScript, you will appreciate this release as it includes a TypeScript typings file that will give you appropriate type hints (with documentation too!). Furthermore all the code in the documentation has been updated to show JavaScript, CoffeeScript and TypeScript (consistently in that order).
I hope you enjoy this release. Please file any bugs encountered.
Changelog
- added: Preliminary Shrinking Support
- added: First Party TypeScript Support
- added: Monad inspired helper functions: qc.of, qc.map and qc.join
- added: Option to generate sparse arrays for array generators
- fixed: A bug that would prevent the integer generators to generate integers larger than size
- improved: qc.forAll now has map semantics, i.e. will return an array of whatever your property returns.
- broken: Removes the deprecated QUnit.forEach
- broken: Removes qc.modify in favour of qc.map
- fixed: An issue with qc.array.subsetOf generating a wrong number of elements
- added: