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.4.3 to 0.4.4

14

lib/arbitrary.js

@@ -43,2 +43,15 @@ "use strict";

/**
- `nearray(arb: arbitrary a): arbitrary (array a)`
*/
function nearray(arb) {
arb = utils.force(arb || primitive.json);
return {
generator: generator.nearray(arb.generator),
shrink: shrink.noop, // TODO: implement me
show: show.array.bind(null, arb.show),
};
}
/**
- `pair(arbA: arbitrary a, arbB : arbitrary b): arbitrary (pair a b)`

@@ -169,2 +182,3 @@

array: array,
nearray: nearray,
map: map,

@@ -171,0 +185,0 @@ oneof: oneof,

23

lib/environment.js

@@ -6,23 +6,8 @@ "use strict";

var primitive = require("./primitive.js");
var utils = require("./utils.js");
var environment = {
nat: primitive.nat,
integer: primitive.integer,
number: primitive.number,
bool: primitive.bool,
falsy: primitive.falsy,
char: primitive.char,
string: primitive.string,
json: primitive.json,
value: primitive.json,
asciichar: primitive.asciichar,
asciistring: primitive.asciistring,
uint8: primitive.uint8,
uint16: primitive.uint16,
uint32: primitive.uint32,
int8: primitive.int8,
int16: primitive.int16,
int32: primitive.int32,
var environment = utils.merge(primitive, {
pair: arbitrary.pair,
array: arbitrary.array,
nearray: arbitrary.nearray,
map: arbitrary.map,

@@ -32,4 +17,4 @@ fn: fn.fn,

nonshrink: arbitrary.nonshrink,
};
});
module.exports = environment;

@@ -26,2 +26,11 @@ "use strict";

/**
- `generator.constant(x: a): gen a`
*/
function generateConstant(x) {
return generatorBless(function () {
return x;
});
}
/**
- `generator.array(gen: Gen a, size: nat): gen (array a)`

@@ -47,2 +56,22 @@ */

/**
- `generator.nearray(gen: Gen a, size: nat): gen (array a)`
*/
function generateNEArray(gen) {
var result = generatorBless(function (size) {
var arrsize = random(1, Math.max(size, 1));
var arr = new Array(arrsize);
for (var i = 0; i < arrsize; i++) {
arr[i] = gen(size);
}
return arr;
});
if (arguments.length === 2) {
return result(arguments[1]);
} else {
return result;
}
}
/**
- `generator.string(size: nat): gen string`

@@ -57,2 +86,11 @@ */

/**
- `generator.nestring(size: nat): gen string`
*/
function generateNEString(size) {
return generateNEArray(function () {
return String.fromCharCode(random(0, 0xff));
}, size).join("");
}
/**
- `generator.map(gen: gen a, size: nat): gen (map a)`

@@ -125,7 +163,10 @@ */

array: generateArray,
nearray: generateNEArray,
string: generateString,
nestring: generateNEString,
map: generateMap,
json: generateJson,
oneof: generateOneof,
constant: generateConstant,
bless: generatorBless,
};

@@ -321,2 +321,9 @@ /**

```
You can use `property` to write facts too:
```js
jsc.property("+0 === -0", function () {
return +0 === -0;
});
```
*/

@@ -326,6 +333,14 @@ function bddProperty(name) {

var args = Array.prototype.slice.call(arguments, 1);
var prop = forall.apply(undefined, args);
it(name, function () {
checkThrow(prop);
});
if (args.length === 1) {
it(name, function () {
if (args[0]() !== true) {
throw new Error(name + " doesn't hold");
}
});
} else {
var prop = forall.apply(undefined, args);
it(name, function () {
checkThrow(prop);
});
}
/* global it: false */

@@ -335,2 +350,38 @@ }

/**
- `sampler(arb: arbitrary a, genSize: nat = 10): (sampleSize: nat?) -> a`
Create a sampler for a given arbitrary with an optional size. Handy when used in
a REPL:
```
> jsc = require('jsverify') // or require('./lib/jsverify') w/in the project
...
> jsonSampler = jsc.sampler(jsc.json, 4)
[Function]
> jsonSampler()
0.08467432763427496
> jsonSampler()
[ [ [] ] ]
> jsonSampler()
''
> sampledJson(2)
[-0.4199344692751765, false]
```
*/
function sampler(arb, size) {
size = typeof size === "number" ? Math.abs(size) : 10;
return function (count) {
if (typeof count === "number") {
var acc = [];
count = Math.abs(count);
for (var i = 0; i < count; i++) {
acc.push(arb.generator(size));
}
return acc;
} else {
return arb.generator(size);
}
};
}
/**
### Types

@@ -361,2 +412,3 @@

property: bddProperty,
sampler: sampler,

@@ -366,2 +418,3 @@ // generators

array: arbitrary.array,
nearray: arbitrary.nearray,
map: arbitrary.map,

@@ -368,0 +421,0 @@ oneof: arbitrary.oneof,

@@ -115,2 +115,19 @@ "use strict";

/**
- `datetime: generator datetime`
Random datetime
*/
var datetimeConst = 1416499879495; // arbitrary datetime
var datetime = {
generator: generator.bless(function (size) {
// TODO: if size === 0 return datetimeConst or distantPast or distantFuture
return new Date(random.number(-size, size) * 768000000 + datetimeConst);
}),
// TODO: implement datetime shrink
shrink: shrink.noop,
show: show.def,
};
/**
- `elements(args: array a): generator a`

@@ -175,2 +192,13 @@

/**
- `notEmptyString: arbitrary string`
Generates strings which are not empty.
*/
var nestring = {
generator: generator.nestring,
shrink: shrink.noop, // todo implement me
show: show.def,
};
/**
- `asciistring: generator string`

@@ -204,3 +232,3 @@ */

/**
- `falsy: generator *
- `falsy: arbitrary *`

@@ -222,2 +250,15 @@ Generates falsy values: `false`, `null`, `undefined`, `""`, `0`, and `NaN`.

/**
- `constant(x: a): arbitrary a`
Returns an unshrinkable arbitrary that yields the given object.
*/
function constant(x) {
return {
generator: generator.constant(x),
shrink: shrink.noop,
show: show.def
};
}
module.exports = {

@@ -241,2 +282,5 @@ integer: integer,

falsy: falsy,
constant: constant,
nestring: nestring,
datetime: datetime,
};

@@ -6,2 +6,4 @@ "use strict";

var utils = require("./utils.js");
var generator = require("./generator.js");
var shrink = require("./shrink.js");

@@ -25,3 +27,3 @@ /**

return {
generator: function (size) {
generator: generator.bless(function (size) {
for (var i = 0; ; i++) {

@@ -39,7 +41,7 @@ // if 5 tries failed, increase size

}
},
}),
shrink: function (x) {
shrink: shrink.bless(function (x) {
return arb.shrink(x).filter(predicate);
},
}),

@@ -46,0 +48,0 @@ show: arb.show,

@@ -12,2 +12,7 @@ "use strict";

### Utility functions
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.
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.
*/

@@ -14,0 +19,0 @@

{
"version": "0.4.0-beta.2",
"version": "0.4.4",
"dependencies": {
"browserify": {
"version": "6.2.0",
"version": "6.3.2",
"dependencies": {

@@ -56,3 +56,3 @@ "JSONStream": {

"browser-resolve": {
"version": "1.3.2",
"version": "1.4.1",
"dependencies": {}

@@ -70,3 +70,3 @@ },

"buffer": {
"version": "2.7.0",
"version": "2.8.1",
"dependencies": {

@@ -127,4 +127,60 @@ "base64-js": {

"crypto-browserify": {
"version": "3.2.8",
"version": "3.4.3",
"dependencies": {
"browserify-aes": {
"version": "0.4.0",
"dependencies": {}
},
"browserify-sign": {
"version": "2.4.0",
"dependencies": {
"asn1.js": {
"version": "0.6.5",
"dependencies": {}
},
"asn1.js-rfc3280": {
"version": "0.5.1",
"dependencies": {}
},
"bn.js": {
"version": "0.15.2",
"dependencies": {}
},
"elliptic": {
"version": "0.15.14",
"dependencies": {
"brorand": {
"version": "1.0.5",
"dependencies": {}
},
"hash.js": {
"version": "0.2.1",
"dependencies": {}
}
}
},
"pemstrip": {
"version": "0.0.1",
"dependencies": {}
}
}
},
"diffie-hellman": {
"version": "2.2.0",
"dependencies": {
"bn.js": {
"version": "0.15.2",
"dependencies": {}
},
"miller-rabin": {
"version": "1.1.1",
"dependencies": {
"brorand": {
"version": "1.0.5",
"dependencies": {}
}
}
}
}
},
"pbkdf2-compat": {

@@ -139,3 +195,3 @@ "version": "2.0.1",

"sha.js": {
"version": "2.2.6",
"version": "2.2.7",
"dependencies": {}

@@ -189,7 +245,12 @@ }

"glob": {
"version": "4.0.6",
"version": "4.2.1",
"dependencies": {
"graceful-fs": {
"version": "3.0.4",
"dependencies": {}
"inflight": {
"version": "1.0.4",
"dependencies": {
"wrappy": {
"version": "1.0.1",
"dependencies": {}
}
}
},

@@ -278,3 +339,3 @@ "minimatch": {

"labeled-stream-splicer": {
"version": "1.0.0",
"version": "1.0.2",
"dependencies": {

@@ -306,3 +367,3 @@ "stream-splicer": {

"module-deps": {
"version": "3.5.6",
"version": "3.5.10",
"dependencies": {

@@ -323,17 +384,17 @@ "JSONStream": {

"detective": {
"version": "3.1.0",
"version": "4.0.0",
"dependencies": {
"acorn": {
"version": "0.9.0",
"dependencies": {}
},
"escodegen": {
"version": "1.1.0",
"version": "1.4.1",
"dependencies": {
"esprima": {
"version": "1.0.4",
"dependencies": {}
},
"estraverse": {
"version": "1.5.1",
"version": "1.8.0",
"dependencies": {}
},
"esutils": {
"version": "1.0.0",
"version": "1.1.6",
"dependencies": {}

@@ -351,6 +412,2 @@ },

}
},
"esprima-fb": {
"version": "3001.1.0-dev-harmony-fb",
"dependencies": {}
}

@@ -488,6 +545,6 @@ }

"syntax-error": {
"version": "1.1.1",
"version": "1.1.2",
"dependencies": {
"esprima-fb": {
"version": "3001.1.0-dev-harmony-fb",
"acorn": {
"version": "0.9.0",
"dependencies": {}

@@ -1482,2 +1539,6 @@ }

},
"jasmine-core": {
"version": "2.1.2",
"dependencies": {}
},
"jscs": {

@@ -2097,3 +2158,3 @@ "version": "1.7.3",

"karma-jasmine": {
"version": "0.2.2",
"version": "0.3.1",
"dependencies": {}

@@ -2315,3 +2376,3 @@ },

"when": {
"version": "3.5.1",
"version": "3.6.3",
"dependencies": {}

@@ -2318,0 +2379,0 @@ }

{
"name": "jsverify",
"description": "Property-based testing for JavaScript.",
"version": "0.4.3",
"version": "0.4.4",
"homepage": "http://jsverify.github.io/",

@@ -32,3 +32,3 @@ "author": {

"devDependencies": {
"browserify": "~6.2.0",
"browserify": "~6.3.2",
"david": "^5.0.0",

@@ -44,3 +44,3 @@ "eslint": "^0.9.1",

"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "~0.2.2",
"karma-jasmine": "~0.3.1",
"karma-mocha": "~0.1.3",

@@ -53,3 +53,3 @@ "ljs": "~0.2.3",

"underscore": "~1.7.0",
"when": "~3.5.0"
"when": "~3.6.3"
},

@@ -56,0 +56,0 @@ "keywords": [

@@ -125,3 +125,30 @@ # JSVerify

You can use `property` to write facts too:
```js
jsc.property("+0 === -0", function () {
return +0 === -0;
});
```
- `sampler(arb: arbitrary a, genSize: nat = 10): (sampleSize: nat?) -> a`
Create a sampler for a given arbitrary with an optional size. Handy when used in
a REPL:
```
> jsc = require('jsverify') // or require('./lib/jsverify') w/in the project
...
> jsonSampler = jsc.sampler(jsc.json, 4)
[Function]
> jsonSampler()
0.08467432763427496
> jsonSampler()
[ [ [] ] ]
> jsonSampler()
''
> sampledJson(2)
[-0.4199344692751765, false]
```
### Types

@@ -188,2 +215,7 @@

- `datetime: generator datetime`
Random datetime
- `elements(args: array a): generator a`

@@ -207,2 +239,7 @@

- `notEmptyString: arbitrary string`
Generates strings which are not empty.
- `asciistring: generator string`

@@ -218,3 +255,3 @@

- `falsy: generator *
- `falsy: arbitrary *`

@@ -224,3 +261,8 @@ Generates falsy values: `false`, `null`, `undefined`, `""`, `0`, and `NaN`.

- `constant(x: a): arbitrary a`
Returns an unshrinkable arbitrary that yields the given object.
### Arbitrary combinators

@@ -237,2 +279,5 @@

- `nearray(arb: arbitrary a): arbitrary (array a)`
- `pair(arbA: arbitrary a, arbB : arbitrary b): arbitrary (pair a b)`

@@ -268,8 +313,17 @@

- `generator.constant(x: a): gen a`
- `generator.array(gen: Gen a, size: nat): gen (array a)`
- `generator.nearray(gen: Gen a, size: nat): gen (array a)`
- `generator.string(size: nat): gen string`
- `generator.nestring(size: nat): gen string`
- `generator.map(gen: gen a, size: nat): gen (map a)`

@@ -334,3 +388,8 @@

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.
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.
- `utils.isEqual(x: json, y: json): bool`

@@ -370,2 +429,7 @@

- 0.4.4 &mdash; *2014-11-22* new generators
- New generators: `nearray`, `nestring`
- `generator.constant`
- zero-ary `jsc.property` (it ∘ assert)
- `jsc.sampler`
- 0.4.3 &mdash; *2014-11-08* jsc.property

@@ -372,0 +436,0 @@ - Now you can write your bdd specs without any boilerplate

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