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

ava-fast-check

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava-fast-check - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

150

lib/ava-fast-check.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
exports.testProp = exports.test = exports.fc = void 0;
var ava_1 = require("ava");
exports.test = ava_1["default"];
var fc = require("fast-check");
const ava_1 = require("ava");
exports.test = ava_1.default;
const fc = require("fast-check");
exports.fc = fc;
function wrapProp(arbitraries, prop, params) {
var _this = this;
return function (t) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
return async (t, ...args) => {
var _a;
let failingTry;
try {
await fc.assert(fc.asyncProperty(...arbitraries, async (...args) => {
const tryResult = await t.try((tt) => prop(tt, ...args));
if (tryResult.passed) {
tryResult.commit();
return true;
}
failingTry = tryResult;
return false;
}), params);
}
return __awaiter(_this, void 0, void 0, function () {
var failingTry, error_1;
var _this = this;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4, fc.assert(fc.asyncProperty.apply(fc, __spreadArray(__spreadArray([], __read(arbitraries), false), [function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return __awaiter(_this, void 0, void 0, function () {
var tryResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, t["try"](function (tt) { return prop.apply(void 0, __spreadArray([tt], __read(args), false)); })];
case 1:
tryResult = _a.sent();
if (tryResult.passed) {
tryResult.commit();
return [2, true];
}
failingTry = tryResult;
return [2, false];
}
});
});
}], false)), params)];
case 1:
_b.sent();
return [3, 3];
case 2:
error_1 = _b.sent();
t.log(error_1.message);
((_a = failingTry === null || failingTry === void 0 ? void 0 : failingTry.commit) !== null && _a !== void 0 ? _a : t.fail)();
return [3, 3];
case 3:
t.pass();
return [2];
}
});
});
catch (error) {
t.log(error.message);
((_a = failingTry === null || failingTry === void 0 ? void 0 : failingTry.commit) !== null && _a !== void 0 ? _a : t.fail)();
}
t.pass();
};
}
function internalTestProp(testFn, label, arbitraries, prop, params) {
var customParams = params || {};
const customParams = params || {};
if (customParams.seed === undefined)
customParams.seed = Date.now();
testFn("".concat(label, " (with seed=").concat(customParams.seed, ")"), wrapProp(arbitraries, prop, params));
testFn(`${label} (with seed=${customParams.seed})`, wrapProp(arbitraries, prop, params));
}
function exposeModifier(modifier) {
return function (label, arbitraries, prop, params) {
return internalTestProp(ava_1["default"][modifier], label, arbitraries, prop, params);
};
return (label, arbitraries, prop, params) => internalTestProp(ava_1.default[modifier], label, arbitraries, prop, params);
}
exports.testProp = Object.assign(function testProp(label, arbitraries, prop, params) {
internalTestProp(ava_1["default"], label, arbitraries, prop, params);
internalTestProp(ava_1.default, label, arbitraries, prop, params);
}, {

@@ -140,4 +46,4 @@ only: exposeModifier('only'),

serial: exposeModifier('serial'),
before: ava_1["default"].before,
after: ava_1["default"].after
before: ava_1.default.before,
after: ava_1.default.after,
});

@@ -1,62 +0,1 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import test from 'ava';

@@ -66,66 +5,33 @@ import * as fc from 'fast-check';

function wrapProp(arbitraries, prop, params) {
var _this = this;
return function (t) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
return async (t, ...args) => {
var _a;
let failingTry;
try {
await fc.assert(fc.asyncProperty(...arbitraries, async (...args) => {
const tryResult = await t.try((tt) => prop(tt, ...args));
if (tryResult.passed) {
tryResult.commit();
return true;
}
failingTry = tryResult;
return false;
}), params);
}
return __awaiter(_this, void 0, void 0, function () {
var failingTry, error_1;
var _this = this;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4, fc.assert(fc.asyncProperty.apply(fc, __spreadArray(__spreadArray([], __read(arbitraries), false), [function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return __awaiter(_this, void 0, void 0, function () {
var tryResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, t["try"](function (tt) { return prop.apply(void 0, __spreadArray([tt], __read(args), false)); })];
case 1:
tryResult = _a.sent();
if (tryResult.passed) {
tryResult.commit();
return [2, true];
}
failingTry = tryResult;
return [2, false];
}
});
});
}], false)), params)];
case 1:
_b.sent();
return [3, 3];
case 2:
error_1 = _b.sent();
t.log(error_1.message);
((_a = failingTry === null || failingTry === void 0 ? void 0 : failingTry.commit) !== null && _a !== void 0 ? _a : t.fail)();
return [3, 3];
case 3:
t.pass();
return [2];
}
});
});
catch (error) {
t.log(error.message);
((_a = failingTry === null || failingTry === void 0 ? void 0 : failingTry.commit) !== null && _a !== void 0 ? _a : t.fail)();
}
t.pass();
};
}
function internalTestProp(testFn, label, arbitraries, prop, params) {
var customParams = params || {};
const customParams = params || {};
if (customParams.seed === undefined)
customParams.seed = Date.now();
testFn("".concat(label, " (with seed=").concat(customParams.seed, ")"), wrapProp(arbitraries, prop, params));
testFn(`${label} (with seed=${customParams.seed})`, wrapProp(arbitraries, prop, params));
}
function exposeModifier(modifier) {
return function (label, arbitraries, prop, params) {
return internalTestProp(test[modifier], label, arbitraries, prop, params);
};
return (label, arbitraries, prop, params) => internalTestProp(test[modifier], label, arbitraries, prop, params);
}
export var testProp = Object.assign(function testProp(label, arbitraries, prop, params) {
export const testProp = Object.assign(function testProp(label, arbitraries, prop, params) {
internalTestProp(test, label, arbitraries, prop, params);

@@ -138,3 +44,3 @@ }, {

before: test.before,
after: test.after
after: test.after,
});

7

package.json
{
"name": "ava-fast-check",
"version": "5.0.0",
"version": "6.0.0",
"description": " Property based testing for AVA based on fast-check",

@@ -38,9 +38,10 @@ "type": "commonjs",

"ava": ">=4.0.0",
"fast-check": "^2.0.0"
"fast-check": "^3.0.0"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^17.0.44",
"ava": "^4.0.1",
"esm": "^3.2.25",
"fast-check": "^2.0.0",
"fast-check": "^3.0.0",
"prettier": "^2.2.1",

@@ -47,0 +48,0 @@ "ts-node": "^9.0.0",

@@ -110,9 +110,10 @@ # Property based testing for AVA based on [fast-check](https://github.com/dubzzz/fast-check/)

| ava-fast-check | AVA | fast-check |
|----------------|-----------------------|----------------------|
| ^5.0.0 | >=4.0.0 | ^2.0.0<sup>(2)</sup> |
| ^4.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |
| ^3.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |
| ^2.0.0 | >=3.9.0<sup>(1)</sup> | ^1.0.0 |
| ^1.0.0 | >=0.1.0<sup>(3)</sup> | ^1.0.0 |
| ava-fast-check | AVA | fast-check |
|----------------|-----------------------|-------------------------|
| ^6.0.0 | >=4.0.0 | ^3.0.0 |
| ^5.0.0 | >=4.0.0 | ^2.0.0<sup>(2)(4)</sup> |
| ^4.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |
| ^3.0.0 | >=3.9.0<sup>(1)</sup> | ^2.0.0<sup>(2)</sup> |
| ^2.0.0 | >=3.9.0<sup>(1)</sup> | ^1.0.0 |
| ^1.0.0 | >=0.1.0<sup>(3)</sup> | ^1.0.0 |

@@ -122,1 +123,2 @@ - (1) `ava@>=3.9.0` for [`t.try`](https://github.com/avajs/ava/blob/main/docs/03-assertions.md#trytitle-implementation--macro--macro-args) support

- (3) `ava@>=0.1.0` for its Promise support
- (4) Already compatible with `fast-check@^3.0.0` but bump to `6.0.0` for updated peer version
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