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.6.0-beta.2 to 0.6.0

2

CHANGELOG.md
## Release History
- **0.6.0** — *2015-06-19* — Minor but major release!
- added `jsc.utils.isApproxEqual`
- **0.6.0-beta.2** — *2015-05-31* — Beta!

@@ -4,0 +6,0 @@ - Fix issue [#113](https://github.com/jsverify/jsverify/issues/113) - Shrink of tuple with arrays failed.

2

lib/either.js

@@ -43,3 +43,3 @@ "use strict";

/**
- `either.isEqual(other: either a b): bool
- `either.isEqual(other: either a b): bool`

@@ -46,0 +46,0 @@ TODO: add `eq` optional parameter

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

/**
- `generator.unit: generator ()
- `generator.unit: generator ()`

@@ -177,0 +177,0 @@ `unit` is an empty tuple, i.e. empty array in JavaScript representation. This is useful as a building block.

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

- `opts.tests` - test count to run, default 100
- `opts.size` - maximum size of generated values, default 5
- `opts.size` - maximum size of generated values, default 50
- `opts.quiet` - do not `console.log`

@@ -256,0 +256,0 @@ - `opts.rngState` - state string for the rng

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

- **Note** `oneof` cannot be shrinked, because the union is untagged, we don't know which shrink to use.
- *anonymous records*: `"{ b: bool, n: nat}"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`.
- *anonymous records*: `"{ b: bool; n: nat}"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`.
*/

@@ -23,0 +23,0 @@

@@ -55,2 +55,76 @@ /* @flow weak */

/**
- `utils.isApproxEqual(x: a, y: b, opts: obj): bool`
Tests whether two objects are approximately and optimistically equal.
Returns `false` only if they are distinguisable not equal.
This function works with cyclic data.
Takes optional 'opts' parameter with properties:
- `fnEqual` - whether all functions are considered equal (default: yes)
- `depth` - how deep to recurse until treating as equal (default: 5)
*/
function isApproxEqual(x, y, opts) {
opts = opts || {};
var fnEqual = opts.fnEqual === false ? false : true;
var depth = opts.depth || 5; // totally arbitrary
// state contains pairs we checked (or are still checking, but assume equal!)
var state = [];
function loop(a, b, n) {
// trivial check
if (a === b) {
return true;
}
// depth check
if (n >= depth) {
return true;
}
var i;
// check if pair already occured
for (i = 0; i < state.length; i++) {
if (state[i][0] === a && state[i][1] === b) {
return true;
}
}
// add to state
state.push([a, b]);
if (typeof a === "function" && typeof b === "function") {
return fnEqual;
}
if (isArray(a) && isArray(b) && a.length === b.length) {
for (i = 0; i < a.length; i++) {
if (!loop(a[i], b[i], n + 1)) {
return false;
}
}
return true;
} else if (isObject(a) && isObject(b) && !isArray(a) && !isArray(b)) {
var akeys = Object.keys(a);
var bkeys = Object.keys(b);
if (!loop(akeys, bkeys, n + 1)) {
return false;
}
for (i = 0; i < akeys.length; i++) {
if (!loop(a[akeys[i]], b[akeys[i]], n + 1)) {
return false;
}
}
return true;
}
return false;
}
return loop(x, y, 0);
}
function identity(x) {

@@ -149,2 +223,3 @@ return x;

isEqual: isEqual,
isApproxEqual: isApproxEqual,
identity: identity,

@@ -151,0 +226,0 @@ pluck: pluck,

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

@@ -29,5 +29,5 @@ "author": {

"browserify": "^10.0.0",
"chai": "^2.0.0",
"chai": "^3.0.0",
"david": "^6.0.1",
"eslint": "^0.22.1",
"eslint": ">=0.23.0 <1.0.0",
"esprima": "^2.2.0",

@@ -38,7 +38,7 @@ "istanbul": "~0.3.0",

"karma": "~0.12.1",
"karma-chrome-launcher": "~0.1.2",
"karma-cli": "0.0.4",
"karma-chrome-launcher": "^0.2.0",
"karma-cli": "^0.1.0",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "~0.3.1",
"karma-mocha": "~0.1.3",
"karma-mocha": "^0.2.0",
"ljs": "~0.3.0",

@@ -45,0 +45,0 @@ "lodash": "^3.9.3",

@@ -112,3 +112,3 @@ # JSVerify

- `opts.tests` - test count to run, default 100
- `opts.size` - maximum size of generated values, default 5
- `opts.size` - maximum size of generated values, default 50
- `opts.quiet` - do not `console.log`

@@ -202,3 +202,3 @@ - `opts.rngState` - state string for the rng

- **Note** `oneof` cannot be shrinked, because the union is untagged, we don't know which shrink to use.
- *anonymous records*: `"{ b: bool, n: nat}"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`.
- *anonymous records*: `"{ b: bool; n: nat}"` is evaluated to `jsc.record({ n: jsc.bool, n: jsc.nat })`.

@@ -425,3 +425,3 @@ ### Arbitrary data

- `generator.unit: generator ()
- `generator.unit: generator ()`

@@ -511,3 +511,3 @@ `unit` is an empty tuple, i.e. empty array in JavaScript representation. This is useful as a building block.

- `either.isEqual(other: either a b): bool
- `either.isEqual(other: either a b): bool`

@@ -545,2 +545,13 @@ TODO: add `eq` optional parameter

- `utils.isApproxEqual(x: a, y: b, opts: obj): bool`
Tests whether two objects are approximately and optimistically equal.
Returns `false` only if they are distinguisable not equal.
This function works with cyclic data.
Takes optional 'opts' parameter with properties:
- `fnEqual` - whether all functions are considered equal (default: yes)
- `depth` - how deep to recurse until treating as equal (default: 5)
- `utils.force(x: a | () -> a) : a`

@@ -576,2 +587,4 @@

- **0.6.0** &mdash; *2015-06-19* &mdash; Minor but major release!
- added `jsc.utils.isApproxEqual`
- **0.6.0-beta.2** &mdash; *2015-05-31* &mdash; Beta!

@@ -743,3 +756,3 @@ - Fix issue [#113](https://github.com/jsverify/jsverify/issues/113) - Shrink of tuple with arrays failed.

Copyright (c) 2013, 2014 Oleg Grenrus
Copyright (c) 2013-2015 Oleg Grenrus

@@ -746,0 +759,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

Sorry, the diff of this file is not supported yet

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

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