New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsverify

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsverify - npm Package Compare versions

Comparing version 0.5.0-beta.1 to 0.5.0-beta.2

CHANGELOG.md

23

lib/arbitrary.js

@@ -39,3 +39,3 @@ /* @flow weak */

shrink: shrink.array(arb.shrink),
show: show.array.bind(null, arb.show),
show: show.array(arb.show),
};

@@ -53,3 +53,3 @@ }

shrink: shrink.nearray(arb.shrink),
show: show.array.bind(null, arb.show),
show: show.array(arb.show),
};

@@ -68,5 +68,5 @@ }

return {
generator: generator.tuple([a.generator, b.generator]),
shrink: shrink.tuple([a.shrink, b.shrink]),
show: show.def,
generator: generator.pair(a.generator, b.generator),
shrink: shrink.pair(a.shrink, b.shrink),
show: show.pair(a.show, b.show),
};

@@ -76,2 +76,14 @@ }

/**
- `tuple(arbs: (arbitrary a, arbitrary b...)): arbitrary (a, b...)`
*/
function tuple(arbs) {
arbs = arbs.map(utils.force);
return {
generator: generator.tuple(utils.pluck(arbs, "generator")),
shrink: shrink.tuple(utils.pluck(arbs, "shrink")),
show: show.tuple(utils.pluck(arbs, "show")),
};
}
/**
- `map(arb: arbitrary a): arbitrary (map a)`

@@ -182,2 +194,3 @@

pair: pair,
tuple: tuple,
array: array,

@@ -184,0 +197,0 @@ nearray: nearray,

@@ -51,2 +51,13 @@ /* @flow weak */

/**
- `generator.pair(genA: gen a, genB: gen b, size: nat): gen (a, b)`
*/
function generatePair(genA, genB) {
var result = generatorBless(function (size) {
return [genA(size), genB(size)];
});
return utils.curried3(result, arguments);
}
/**
- `generator.tuple(gens: (gen a, gen b...), size: nat): gen (a, b...)`

@@ -174,3 +185,3 @@ */

/**
- `generator.recursive(genZ: gen a, genS: gen a -> gen a): gen a<
- `generator.recursive(genZ: gen a, genS: gen a -> gen a): gen a`
*/

@@ -215,2 +226,3 @@ function generatorRecursive(genZ, genS) {

module.exports = {
pair: generatePair,
tuple: generateTuple,

@@ -217,0 +229,0 @@ array: generateArray,

@@ -312,3 +312,3 @@ /* @flow weak */

/**
- `property(name: string, ...)
- `property(name: string, ...)`

@@ -413,9 +413,2 @@ Assuming there is globally defined `it`, the same as:

// generators
pair: arbitrary.pair,
array: arbitrary.array,
nearray: arbitrary.nearray,
map: arbitrary.map,
oneof: arbitrary.oneof,
record: arbitrary.record,
nonshrink: arbitrary.nonshrink,
fn: fn.fn,

@@ -444,5 +437,9 @@ fun: fn.fn,

/* primitives */
for (var k in primitive) {
var k;
for (k in primitive) {
jsc[k] = primitive[k];
}
for (k in arbitrary) {
jsc[k] = arbitrary[k];
}

@@ -449,0 +446,0 @@ module.exports = jsc;

@@ -231,3 +231,3 @@ /* @flow weak */

shrink: function (x) {
shrink: shrink.bless(function (x) {
var idx = args.indexOf(x);

@@ -239,3 +239,3 @@ if (idx <= 0) {

}
},
}),
show: show.def,

@@ -242,0 +242,0 @@ };

@@ -8,2 +8,4 @@ /* @flow weak */

var utils = require("./utils.js");
/**

@@ -17,10 +19,25 @@ - `show.def(x : a): string`

/**
- `show.pair(showA: a -> string, showB: b -> string, x: (a, b)): string`
*/
function showPair(showA, showB) {
var result = function (p) {
return "(" + showA(p[0]) + ", " + showB(p[1]) + ")";
};
return utils.curried3(result, arguments);
}
/**
- `show.tuple(shrinks: (a -> string, b -> string...), x: (a, b...)): string`
*/
function showTuple(shows, objs) {
var strs = [];
for (var i = 0; i < shows.length; i++) {
strs.push(shows[i](objs[i]));
}
return strs.join("; ");
function showTuple(shows) {
var result = function (objs) {
var strs = [];
for (var i = 0; i < shows.length; i++) {
strs.push(shows[i](objs[i]));
}
return strs.join("; ");
};
return utils.curried2(result, arguments);
}

@@ -31,4 +48,8 @@

*/
function showArray(show, arr) {
return "[" + arr.map(show).join(", ") + "]";
function showArray(show) {
var result = function (arr) {
return "[" + arr.map(show).join(", ") + "]";
};
return utils.curried2(result, arguments);
}

@@ -38,4 +59,5 @@

def: showDef,
pair: showPair,
tuple: showTuple,
array: showArray,
};

@@ -35,25 +35,64 @@ /* @flow weak */

/**
- `shrink.tuple(shrinks: (a -> array a, b -> array b...), x: (a, b...)): array (a, b...)`
- `shrink.pair(shrA: a -> array a, shrB: b -> array, x: (a, b)): array (a, b)`
*/
function shrinkTuple(shrinks) {
var result = shrinkBless(function (tup) {
assert(shrinks.length === tup.length, "there should be as much shrinks as values in the tuple");
function shrinkPair(shrinkA, shrinkB) {
var result = shrinkBless(function (pair) {
assert(pair.length === 2, "shrinkPair: pair should be an Array of length 2");
var shrinked = new Array(tup.length);
var a = pair[0];
var b = pair[1];
for (var i = 0; i < tup.length; i++) {
/* jshint -W083 */
/* eslint-disable no-loop-func */
shrinked[i] = shrinks[i](tup[i]).map(function (x) {
var c = tup.slice(); // clone array
c[i] = x;
return c;
});
/* eslint-enable no-loop-func */
/* jshint +W083 */
}
var shrinkedA = shrinkA(a);
var shrinkedB = shrinkB(b);
return Array.prototype.concat.apply([], shrinked);
var pairA = shrinkedA.map(function (ap) {
return [ap, b];
});
var pairB = shrinkedB.map(function (bp) {
return [a, bp];
});
return pairA.concat(pairB);
});
return utils.curried3(result, arguments);
}
// a → Vec a 1
function toSingleton(x) {
return [x];
}
// Vec a 1 → a
function fromSingleton(a) {
return a[0];
}
// a × HList b → HList (a ∷ b)
function toHList(p) {
return [p[0]].concat(p[1]);
}
// HList (a ∷ b) → a × HList b
function fromHList(h) {
return [h[0], h.slice(1)];
}
function shrinkTupleImpl(shrinks, n) {
if (n + 1 === shrinks.length) {
return shrinks[n].isomap(toSingleton, fromSingleton);
} else {
var shrinkA = shrinks[0];
var shrinkB = shrinkTupleImpl(shrinks, n + 1);
return shrinkPair(shrinkA, shrinkB).isomap(toHList, fromHList);
}
}
/**
- `shrink.tuple(shrinks: (a -> array a, b -> array b...), x: (a, b...)): array (a, b...)`
*/
function shrinkTuple(shrinks) {
assert(shrinks.length > 0, "shrinkTuple needs > 0 values");
var result = shrinkTupleImpl(shrinks, 0);
return utils.curried2(result, arguments);

@@ -119,2 +158,3 @@ }

noop: shrinkNoop,
pair: shrinkPair,
tuple: shrinkTuple,

@@ -121,0 +161,0 @@ array: shrinkArray,

@@ -14,4 +14,4 @@ /* @flow weak */

Utility functions are exposed (and documented) only to make contributions to jsverify easy.
The changes here don't follow semver, i.e. ther might backward-incompatible changes even in patch releases.
Utility functions are exposed (and documented) only to make contributions to jsverify more easy.
The changes here don't follow semver, i.e. there might be backward-incompatible changes even in patch releases.

@@ -78,3 +78,3 @@ Use [underscore.js](http://underscorejs.org/), [lodash](https://lodash.com/), [ramda](http://ramda.github.io/ramdocs/docs/), [lazy.js](http://danieltao.com/lazy.js/) or some other utility belt.

Merge two objects, a bit like `_.extend({}, x, y)`
Merge two objects, a bit like `_.extend({}, x, y)`.
*/

@@ -96,10 +96,16 @@ function merge(x, y) {

function curried2(result, args) {
if (args.length === 2) {
return result(args[1]);
} else {
return result;
}
function curriedN(n) {
var n1 = n - 1;
return function curriedNInstance(result, args) {
if (args.length === n) {
return result(args[n1]);
} else {
return result;
}
};
}
var curried2 = curriedN(2);
var curried3 = curriedN(3);
function charArrayToString(arr) {

@@ -123,4 +129,5 @@ return arr.join("");

curried2: curried2,
curried3: curried3,
charArrayToString: charArrayToString,
stringToCharArray: stringToCharArray,
};
{
"name": "jsverify",
"description": "Property-based testing for JavaScript.",
"version": "0.5.0-beta.1",
"version": "0.5.0-beta.2",
"homepage": "http://jsverify.github.io/",

@@ -6,0 +6,0 @@ "author": {

@@ -115,3 +115,3 @@ # JSVerify

- `property(name: string, ...)
- `property(name: string, ...)`

@@ -285,2 +285,5 @@ Assuming there is globally defined `it`, the same as:

- `tuple(arbs: (arbitrary a, arbitrary b...)): arbitrary (a, b...)`
- `map(arb: arbitrary a): arbitrary (map a)`

@@ -314,2 +317,5 @@

- `generator.pair(genA: gen a, genB: gen b, size: nat): gen (a, b)`
- `generator.tuple(gens: (gen a, gen b...), size: nat): gen (a, b...)`

@@ -348,3 +354,3 @@

- `generator.recursive(genZ: gen a, genS: gen a -> gen a): gen a<
- `generator.recursive(genZ: gen a, genS: gen a -> gen a): gen a`

@@ -362,2 +368,5 @@

- `shrink.pair(shrA: a -> array a, shrB: b -> array, x: (a, b)): array (a, b)`
- `shrink.tuple(shrinks: (a -> array a, b -> array b...), x: (a, b...)): array (a, b...)`

@@ -382,2 +391,5 @@

- `show.pair(showA: a -> string, showB: b -> string, x: (a, b)): string`
- `show.tuple(shrinks: (a -> string, b -> string...), x: (a, b...)): string`

@@ -410,4 +422,4 @@

Utility functions are exposed (and documented) only to make contributions to jsverify easy.
The changes here don't follow semver, i.e. ther might backward-incompatible changes even in patch releases.
Utility functions are exposed (and documented) only to make contributions to jsverify more easy.
The changes here don't follow semver, i.e. there might be backward-incompatible changes even in patch releases.

@@ -429,3 +441,3 @@ Use [underscore.js](http://underscorejs.org/), [lodash](https://lodash.com/), [ramda](http://ramda.github.io/ramdocs/docs/), [lazy.js](http://danieltao.com/lazy.js/) or some other utility belt.

Merge two objects, a bit like `_.extend({}, x, y)`
Merge two objects, a bit like `_.extend({}, x, y)`.

@@ -436,19 +448,14 @@

In lieu of a formal styleguide, take care to maintain the existing coding style.
- `README.md` is generated from the source with [ljs](https://github.com/phadej/ljs)
- `jsverify.standalone.js` is also generated by the build process
- Before creating a pull request run `make test`, yet travis will do it for you.
- Add unit tests for any new or changed functionality.
- Lint and test your code using `make test`.
- Use `make istanbul` to run tests with coverage with [istanbul](http://gotwarlost.github.io/istanbul/).
- Create a pull request
### Before release
Don't add `README.md` or `jsverify.standalone.js` into pull requests.
They will be regenerated before each release.
- run `make dist`
## Release History
- **0.5.0-beta.1**; &mdash; *2014-12-20* &mdash; Almost there!
- **0.5.0-beta.2** &mdash; *2014-12-21* &mdash; Beta 2!
- Pair &amp; tuple related code cleanup
- Update `CONTRIBUTING.md`
- Small documentation type fixes
- Bless `jsc.elements` shrink
- **0.5.0-beta.1** &mdash; *2014-12-20* &mdash; Beta!
- `bless` don't close over (uses `this`)

@@ -455,0 +462,0 @@ - Cleanup generator module

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc