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

fast-check

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-check - npm Package Compare versions

Comparing version 3.17.2 to 3.18.0

lib/arbitrary/_internals/helpers/DoubleOnlyHelpers.js

22

CHANGELOG.md

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

# 3.18.0
_New options for floating point arbitraries_
[[Code](https://github.com/dubzzz/fast-check/tree/v3.18.0)][[Diff](https://github.com/dubzzz/fast-check/compare/v3.17.2...v3.18.0)]
## Features
- ([PR#4917](https://github.com/dubzzz/fast-check/pull/4917)) Add option to produce non-integer on `double`
- ([PR#4923](https://github.com/dubzzz/fast-check/pull/4923)) Add option to produce non-integer on `float`
- ([PR#4935](https://github.com/dubzzz/fast-check/pull/4935)) Produce "//" in web paths
## Fixes
- ([PR#4924](https://github.com/dubzzz/fast-check/pull/4924)) CI: Enable more advanced TS flags
- ([PR#4925](https://github.com/dubzzz/fast-check/pull/4925)) CI: Explicitly test against Node 22
- ([PR#4926](https://github.com/dubzzz/fast-check/pull/4926)) CI: Stabilize tests of `double` on small ranges
- ([PR#4921](https://github.com/dubzzz/fast-check/pull/4921)) Performance: More optimal `noInteger` on `double`
- ([PR#4933](https://github.com/dubzzz/fast-check/pull/4933)) Script: Switch on more eslint rules
- ([PR#4922](https://github.com/dubzzz/fast-check/pull/4922)) Test: Cover `noInteger` on `double` via integration layers
---
# 3.17.2

@@ -2,0 +24,0 @@

9

lib/arbitrary/_internals/builders/UriPathArbitraryBuilder.js

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

const SegmentsToPath_1 = require("../mappers/SegmentsToPath");
const oneof_1 = require("../../oneof");
function sqrtSize(size) {

@@ -22,6 +23,12 @@ switch (size) {

}
function buildUriPathArbitraryInternal(segmentSize, numSegmentSize) {
return (0, array_1.array)((0, webSegment_1.webSegment)({ size: segmentSize }), { size: numSegmentSize }).map(SegmentsToPath_1.segmentsToPathMapper, SegmentsToPath_1.segmentsToPathUnmapper);
}
function buildUriPathArbitrary(resolvedSize) {
const [segmentSize, numSegmentSize] = sqrtSize(resolvedSize);
return (0, array_1.array)((0, webSegment_1.webSegment)({ size: segmentSize }), { size: numSegmentSize }).map(SegmentsToPath_1.segmentsToPathMapper, SegmentsToPath_1.segmentsToPathUnmapper);
if (segmentSize === numSegmentSize) {
return buildUriPathArbitraryInternal(segmentSize, numSegmentSize);
}
return (0, oneof_1.oneof)(buildUriPathArbitraryInternal(segmentSize, numSegmentSize), buildUriPathArbitraryInternal(numSegmentSize, segmentSize));
}
exports.buildUriPathArbitrary = buildUriPathArbitrary;

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

const DoubleHelpers_1 = require("./_internals/helpers/DoubleHelpers");
const DoubleOnlyHelpers_1 = require("./_internals/helpers/DoubleOnlyHelpers");
const safeNumberIsInteger = Number.isInteger;
const safeNumberIsNaN = Number.isNaN;

@@ -24,3 +26,6 @@ const safeNegativeInfinity = Number.NEGATIVE_INFINITY;

}
function double(constraints = {}) {
function numberIsNotInteger(value) {
return !safeNumberIsInteger(value);
}
function anyDouble(constraints) {
const { noDefaultInfinity = false, noNaN = false, minExcluded = false, maxExcluded = false, min = noDefaultInfinity ? -safeMaxValue : safeNegativeInfinity, max = noDefaultInfinity ? safeMaxValue : safePositiveInfinity, } = constraints;

@@ -53,2 +58,10 @@ const minIndexRaw = safeDoubleToIndex(min, 'min');

}
function double(constraints = {}) {
if (!constraints.noInteger) {
return anyDouble(constraints);
}
return anyDouble((0, DoubleOnlyHelpers_1.refineConstraintsForDoubleOnly)(constraints))
.map(DoubleOnlyHelpers_1.doubleOnlyMapper, DoubleOnlyHelpers_1.doubleOnlyUnmapper)
.filter(numberIsNotInteger);
}
exports.double = double;

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

const FloatHelpers_1 = require("./_internals/helpers/FloatHelpers");
const FloatOnlyHelpers_1 = require("./_internals/helpers/FloatOnlyHelpers");
const safeNumberIsInteger = Number.isInteger;
const safeNumberIsNaN = Number.isNaN;

@@ -25,3 +27,6 @@ const safeMathFround = Math.fround;

}
function float(constraints = {}) {
function numberIsNotInteger(value) {
return !safeNumberIsInteger(value);
}
function anyFloat(constraints) {
const { noDefaultInfinity = false, noNaN = false, minExcluded = false, maxExcluded = false, min = noDefaultInfinity ? -FloatHelpers_1.MAX_VALUE_32 : safeNegativeInfinity, max = noDefaultInfinity ? FloatHelpers_1.MAX_VALUE_32 : safePositiveInfinity, } = constraints;

@@ -53,2 +58,10 @@ const minIndexRaw = safeFloatToIndex(min, 'min');

}
function float(constraints = {}) {
if (!constraints.noInteger) {
return anyFloat(constraints);
}
return anyFloat((0, FloatOnlyHelpers_1.refineConstraintsForFloatOnly)(constraints))
.map(FloatOnlyHelpers_1.floatOnlyMapper, FloatOnlyHelpers_1.floatOnlyUnmapper)
.filter(numberIsNotInteger);
}
exports.float = float;
import { webSegment } from '../../webSegment.js';
import { array } from '../../array.js';
import { segmentsToPathMapper, segmentsToPathUnmapper } from '../mappers/SegmentsToPath.js';
import { oneof } from '../../oneof.js';
function sqrtSize(size) {

@@ -18,5 +19,11 @@ switch (size) {

}
function buildUriPathArbitraryInternal(segmentSize, numSegmentSize) {
return array(webSegment({ size: segmentSize }), { size: numSegmentSize }).map(segmentsToPathMapper, segmentsToPathUnmapper);
}
export function buildUriPathArbitrary(resolvedSize) {
const [segmentSize, numSegmentSize] = sqrtSize(resolvedSize);
return array(webSegment({ size: segmentSize }), { size: numSegmentSize }).map(segmentsToPathMapper, segmentsToPathUnmapper);
if (segmentSize === numSegmentSize) {
return buildUriPathArbitraryInternal(segmentSize, numSegmentSize);
}
return oneof(buildUriPathArbitraryInternal(segmentSize, numSegmentSize), buildUriPathArbitraryInternal(numSegmentSize, segmentSize));
}
import { add64, isEqual64, isStrictlyPositive64, isStrictlySmaller64, substract64, Unit64, } from './_internals/helpers/ArrayInt64.js';
import { arrayInt64 } from './_internals/ArrayInt64Arbitrary.js';
import { doubleToIndex, indexToDouble } from './_internals/helpers/DoubleHelpers.js';
import { doubleOnlyMapper, doubleOnlyUnmapper, refineConstraintsForDoubleOnly, } from './_internals/helpers/DoubleOnlyHelpers.js';
const safeNumberIsInteger = Number.isInteger;
const safeNumberIsNaN = Number.isNaN;

@@ -20,3 +22,6 @@ const safeNegativeInfinity = Number.NEGATIVE_INFINITY;

}
export function double(constraints = {}) {
function numberIsNotInteger(value) {
return !safeNumberIsInteger(value);
}
function anyDouble(constraints) {
const { noDefaultInfinity = false, noNaN = false, minExcluded = false, maxExcluded = false, min = noDefaultInfinity ? -safeMaxValue : safeNegativeInfinity, max = noDefaultInfinity ? safeMaxValue : safePositiveInfinity, } = constraints;

@@ -49,1 +54,9 @@ const minIndexRaw = safeDoubleToIndex(min, 'min');

}
export function double(constraints = {}) {
if (!constraints.noInteger) {
return anyDouble(constraints);
}
return anyDouble(refineConstraintsForDoubleOnly(constraints))
.map(doubleOnlyMapper, doubleOnlyUnmapper)
.filter(numberIsNotInteger);
}
import { integer } from './integer.js';
import { floatToIndex, indexToFloat, MAX_VALUE_32 } from './_internals/helpers/FloatHelpers.js';
import { floatOnlyMapper, floatOnlyUnmapper, refineConstraintsForFloatOnly, } from './_internals/helpers/FloatOnlyHelpers.js';
const safeNumberIsInteger = Number.isInteger;
const safeNumberIsNaN = Number.isNaN;

@@ -21,3 +23,6 @@ const safeMathFround = Math.fround;

}
export function float(constraints = {}) {
function numberIsNotInteger(value) {
return !safeNumberIsInteger(value);
}
function anyFloat(constraints) {
const { noDefaultInfinity = false, noNaN = false, minExcluded = false, maxExcluded = false, min = noDefaultInfinity ? -MAX_VALUE_32 : safeNegativeInfinity, max = noDefaultInfinity ? MAX_VALUE_32 : safePositiveInfinity, } = constraints;

@@ -49,1 +54,9 @@ const minIndexRaw = safeFloatToIndex(min, 'min');

}
export function float(constraints = {}) {
if (!constraints.noInteger) {
return anyFloat(constraints);
}
return anyFloat(refineConstraintsForFloatOnly(constraints))
.map(floatOnlyMapper, floatOnlyUnmapper)
.filter(numberIsNotInteger);
}

4

lib/esm/fast-check-default.js

@@ -107,4 +107,4 @@ import { pre } from './check/precondition/Pre.js';

const __type = 'module';
const __version = '3.17.2';
const __commitHash = 'a377b81e6e8362ad7324cf65b75bc5e93d12af64';
const __version = '3.18.0';
const __commitHash = '3500faa4c0063da88e3f1facd8137b1db34d3f5f';
export { __type, __version, __commitHash, sample, statistics, check, assert, pre, PreconditionFailure, property, asyncProperty, boolean, falsy, float, double, integer, nat, maxSafeInteger, maxSafeNat, bigIntN, bigUintN, bigInt, bigUint, char, ascii, char16bits, unicode, fullUnicode, hexa, base64, mixedCase, string, asciiString, string16bits, stringOf, unicodeString, fullUnicodeString, hexaString, base64String, stringMatching, lorem, constant, constantFrom, mapToConstant, option, oneof, clone, shuffledSubarray, subarray, array, sparseArray, infiniteStream, uniqueArray, tuple, record, dictionary, anything, object, json, jsonValue, unicodeJson, unicodeJsonValue, letrec, memo, compareBooleanFunc, compareFunc, func, context, gen, date, ipV4, ipV4Extended, ipV6, domain, webAuthority, webSegment, webFragments, webPath, webQueryParameters, webUrl, emailAddress, ulid, uuid, uuidV, int8Array, uint8Array, uint8ClampedArray, int16Array, uint16Array, int32Array, uint32Array, float32Array, float64Array, bigInt64Array, bigUint64Array, asyncModelRun, modelRun, scheduledModelRun, commands, scheduler, schedulerFor, Arbitrary, Value, cloneMethod, cloneIfNeeded, hasCloneMethod, toStringMethod, hasToStringMethod, asyncToStringMethod, hasAsyncToStringMethod, getDepthContextFor, stringify, asyncStringify, defaultReportMessage, asyncDefaultReportMessage, hash, VerbosityLevel, configureGlobal, readConfigureGlobal, resetConfigureGlobal, ExecutionStatus, Random, Stream, stream, createDepthIdentifier, };

@@ -47,2 +47,9 @@ import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';

noNaN?: boolean;
/**
* When set to true, Number.isInteger(value) will be false for any generated value.
* Note: -infinity and +infinity, or NaN can stil be generated except if you rejected them via another constraint.
* @defaultValue false
* @remarks Since 3.18.0
*/
noInteger?: boolean;
}

@@ -49,0 +56,0 @@ /**

@@ -47,2 +47,9 @@ import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';

noNaN?: boolean;
/**
* When set to true, Number.isInteger(value) will be false for any generated value.
* Note: -infinity and +infinity, or NaN can stil be generated except if you rejected them via another constraint.
* @defaultValue false
* @remarks Since 3.18.0
*/
noInteger?: boolean;
}

@@ -49,0 +56,0 @@ /**

@@ -173,3 +173,3 @@ import { pre } from './check/precondition/Pre.js';

/**
* Version of fast-check used by your project (eg.: 3.17.2)
* Version of fast-check used by your project (eg.: 3.18.0)
* @remarks Since 1.22.0

@@ -180,3 +180,3 @@ * @public

/**
* Commit hash of the current code (eg.: a377b81e6e8362ad7324cf65b75bc5e93d12af64)
* Commit hash of the current code (eg.: 3500faa4c0063da88e3f1facd8137b1db34d3f5f)
* @remarks Since 2.7.0

@@ -183,0 +183,0 @@ * @public

@@ -235,5 +235,5 @@ "use strict";

exports.__type = __type;
const __version = '3.17.2';
const __version = '3.18.0';
exports.__version = __version;
const __commitHash = 'a377b81e6e8362ad7324cf65b75bc5e93d12af64';
const __commitHash = '3500faa4c0063da88e3f1facd8137b1db34d3f5f';
exports.__commitHash = __commitHash;

@@ -47,2 +47,9 @@ import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';

noNaN?: boolean;
/**
* When set to true, Number.isInteger(value) will be false for any generated value.
* Note: -infinity and +infinity, or NaN can stil be generated except if you rejected them via another constraint.
* @defaultValue false
* @remarks Since 3.18.0
*/
noInteger?: boolean;
}

@@ -49,0 +56,0 @@ /**

@@ -47,2 +47,9 @@ import type { Arbitrary } from '../check/arbitrary/definition/Arbitrary.js';

noNaN?: boolean;
/**
* When set to true, Number.isInteger(value) will be false for any generated value.
* Note: -infinity and +infinity, or NaN can stil be generated except if you rejected them via another constraint.
* @defaultValue false
* @remarks Since 3.18.0
*/
noInteger?: boolean;
}

@@ -49,0 +56,0 @@ /**

@@ -173,3 +173,3 @@ import { pre } from './check/precondition/Pre.js';

/**
* Version of fast-check used by your project (eg.: 3.17.2)
* Version of fast-check used by your project (eg.: 3.18.0)
* @remarks Since 1.22.0

@@ -180,3 +180,3 @@ * @public

/**
* Commit hash of the current code (eg.: a377b81e6e8362ad7324cf65b75bc5e93d12af64)
* Commit hash of the current code (eg.: 3500faa4c0063da88e3f1facd8137b1db34d3f5f)
* @remarks Since 2.7.0

@@ -183,0 +183,0 @@ * @public

{
"name": "fast-check",
"version": "3.17.2",
"version": "3.18.0",
"description": "Property based testing framework for JavaScript (like QuickCheck)",

@@ -66,3 +66,3 @@ "type": "commonjs",

"@types/node": "^20.12.7",
"@vitest/coverage-v8": "^1.5.0",
"@vitest/coverage-v8": "^1.5.2",
"cross-env": "^7.0.3",

@@ -75,3 +75,3 @@ "glob": "^10.3.12",

"typescript": "~5.4.5",
"vitest": "^1.5.0"
"vitest": "^1.5.2"
},

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

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