Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

checkers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

checkers - npm Package Compare versions

Comparing version 0.10.0 to 0.13.1

2

package.json
{
"name": "checkers",
"version": "0.10.0",
"version": "0.13.1",
"description": "Property-based testing for JavaScript via ClojureScript's test.check",

@@ -5,0 +5,0 @@ "main": "checkers.js",

# checkers
[![Build Status](https://travis-ci.org/glenjamin/checkers.svg?branch=master)](https://travis-ci.org/glenjamin/checkers)
[![npm version](https://img.shields.io/npm/v/checkers.svg)](https://www.npmjs.com/package/checkers) [![Build Status](https://img.shields.io/travis/glenjamin/checkers/master.svg)](https://travis-ci.org/glenjamin/checkers)

@@ -69,2 +69,4 @@ <img src="https://drive.google.com/uc?id=0BxqNu2E4b85zeWtxZGtOR1doaXM" align="right" />

For now you'll have to rely on the examples in the `test` folder.
## TODO

@@ -71,0 +73,0 @@

@@ -28,2 +28,11 @@ /*eslint-env mocha */

});
it("returns summary of run", function() {
var summary = checkers.forAll(
[gen.int],
function(n) {
return (n * n) >= n;
}
).check(100);
assert.equal(summary["num-tests"], 100);
});
it("errors if property is not satisfied", function() {

@@ -39,2 +48,22 @@ try {

});
it("treats null as a failure", function() {
try {
checkers.forAll([gen.int], function() {
return null;
}).check(1);
throw new Error("Shouldn't throw");
} catch(ex) {
assert.notEqual(ex.message, "Shouldn't throw");
}
});
it("treats undefined as a failure", function() {
try {
checkers.forAll([gen.int], function() {
return undefined;
}).check(1);
throw new Error("Shouldn't throw");
} catch(ex) {
assert.notEqual(ex.message, "Shouldn't throw");
}
});
it("errors if property checker throws", function() {

@@ -47,5 +76,8 @@ try {

} catch(ex) {
assert.equal(ex.message, "whoops");
assert.ok(
/whoops/.test(ex.message),
"expected /whoops/ to match " + ex.message
);
}
});
});

@@ -42,3 +42,3 @@ /*eslint-env mocha */

return _.isString(c);
}, 1000);
}, 100);
checking(".stringAscii", [gen.stringAscii], function(s) {

@@ -48,3 +48,3 @@ return _.isString(s) && _.every(s, function(c) {

});
}, 1000);
}, 100);
checking(".stringAlphanum", [gen.stringAlphanum], function(s) {

@@ -54,3 +54,3 @@ return _.isString(s) && _.every(s, function(c) {

});
}, 1000);
}, 100);
describe(".tuple", function() {

@@ -77,2 +77,52 @@ checking("pairs of ints", [gen.tuple(gen.int, gen.int)], function(t) {

});
describe(".array", function() {
checking("array of ints", [gen.array(gen.int)], function(arr) {
return _.isArray(arr) && _.every(arr, _.isNumber);
});
checking("array of strings", [gen.array(gen.string)], function(arr) {
return _.isArray(arr) && _.every(arr, _.isString);
}, 100);
checking("fixed length array", [gen.array(gen.int, 7)], function(arr) {
return _.isArray(arr) && _.every(arr, _.isNumber) &&
arr.length === 7;
});
checking("bounded length array",
[gen.array(gen.int, 3, 17)],
function(arr) {
return _.isArray(arr) && _.every(arr, _.isNumber) &&
arr.length >= 3 && arr.length <= 17;
}
);
});
describe(".obj", function() {
checking("int -> int", [gen.obj(gen.int, gen.int)], function(o) {
return _.isObject(o) && _.every(o, function(v, k) {
return _.isNumber(v) && _.isString(k) && /^-?\d+$/.test(k);
});
}, 100);
checking("charAlpha -> int",
[gen.obj(gen.charAlpha, gen.int)],
function(o) {
return _.isObject(o) && _.every(o, function(v, k) {
return _.isString(k) && _.isNumber(v);
});
},
100
);
});
checking(".object",
[gen.object({a: gen.int, b: gen.charAlpha, c: gen.nat})],
function(o) {
return _.isEqual(['a', 'b', 'c'], _.keys(o)) &&
_.isNumber(o.a) && /[a-z]/i.test(o.b) &&
_.isNumber(o.c) && o.c >= 0;
}
);
checking(".pick",
[gen.pick([1, 'a', false])],
function(x) {
return x == 1 || x == 'a' || x === false;
},
10
);
});

@@ -79,0 +129,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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