Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
12
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ArrayToMap.js
generated
vendored
Normal file
12
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ArrayToMap.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export function arrayToMapMapper(data) {
|
||||
return new Map(data);
|
||||
}
|
||||
export function arrayToMapUnmapper(value) {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
throw new Error('Incompatible instance received: should be a non-null object');
|
||||
}
|
||||
if (!('constructor' in value) || value.constructor !== Map) {
|
||||
throw new Error('Incompatible instance received: should be of exact type Map');
|
||||
}
|
||||
return Array.from(value);
|
||||
}
|
||||
12
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ArrayToSet.js
generated
vendored
Normal file
12
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ArrayToSet.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export function arrayToSetMapper(data) {
|
||||
return new Set(data);
|
||||
}
|
||||
export function arrayToSetUnmapper(value) {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
throw new Error('Incompatible instance received: should be a non-null object');
|
||||
}
|
||||
if (!('constructor' in value) || value.constructor !== Set) {
|
||||
throw new Error('Incompatible instance received: should be of exact type Set');
|
||||
}
|
||||
return Array.from(value);
|
||||
}
|
||||
10
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/CharsToString.js
generated
vendored
Normal file
10
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/CharsToString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { safeJoin, safeSplit } from '../../../utils/globals.js';
|
||||
export function charsToStringMapper(tab) {
|
||||
return safeJoin(tab, '');
|
||||
}
|
||||
export function charsToStringUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Cannot unmap the passed value');
|
||||
}
|
||||
return safeSplit(value, '');
|
||||
}
|
||||
10
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/CodePointsToString.js
generated
vendored
Normal file
10
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/CodePointsToString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { safeJoin } from '../../../utils/globals.js';
|
||||
export function codePointsToStringMapper(tab) {
|
||||
return safeJoin(tab, '');
|
||||
}
|
||||
export function codePointsToStringUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Cannot unmap the passed value');
|
||||
}
|
||||
return [...value];
|
||||
}
|
||||
71
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/EntitiesToIPv6.js
generated
vendored
Normal file
71
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/EntitiesToIPv6.js
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import { safeEndsWith, safeJoin, safeSlice, safeSplit, safeStartsWith, safeSubstring } from '../../../utils/globals.js';
|
||||
function readBh(value) {
|
||||
if (value.length === 0)
|
||||
return [];
|
||||
else
|
||||
return safeSplit(value, ':');
|
||||
}
|
||||
function extractEhAndL(value) {
|
||||
const valueSplits = safeSplit(value, ':');
|
||||
if (valueSplits.length >= 2 && valueSplits[valueSplits.length - 1].length <= 4) {
|
||||
return [
|
||||
safeSlice(valueSplits, 0, valueSplits.length - 2),
|
||||
`${valueSplits[valueSplits.length - 2]}:${valueSplits[valueSplits.length - 1]}`,
|
||||
];
|
||||
}
|
||||
return [safeSlice(valueSplits, 0, valueSplits.length - 1), valueSplits[valueSplits.length - 1]];
|
||||
}
|
||||
export function fullySpecifiedMapper(data) {
|
||||
return `${safeJoin(data[0], ':')}:${data[1]}`;
|
||||
}
|
||||
export function fullySpecifiedUnmapper(value) {
|
||||
if (typeof value !== 'string')
|
||||
throw new Error('Invalid type');
|
||||
return extractEhAndL(value);
|
||||
}
|
||||
export function onlyTrailingMapper(data) {
|
||||
return `::${safeJoin(data[0], ':')}:${data[1]}`;
|
||||
}
|
||||
export function onlyTrailingUnmapper(value) {
|
||||
if (typeof value !== 'string')
|
||||
throw new Error('Invalid type');
|
||||
if (!safeStartsWith(value, '::'))
|
||||
throw new Error('Invalid value');
|
||||
return extractEhAndL(safeSubstring(value, 2));
|
||||
}
|
||||
export function multiTrailingMapper(data) {
|
||||
return `${safeJoin(data[0], ':')}::${safeJoin(data[1], ':')}:${data[2]}`;
|
||||
}
|
||||
export function multiTrailingUnmapper(value) {
|
||||
if (typeof value !== 'string')
|
||||
throw new Error('Invalid type');
|
||||
const [bhString, trailingString] = safeSplit(value, '::', 2);
|
||||
const [eh, l] = extractEhAndL(trailingString);
|
||||
return [readBh(bhString), eh, l];
|
||||
}
|
||||
export function multiTrailingMapperOne(data) {
|
||||
return multiTrailingMapper([data[0], [data[1]], data[2]]);
|
||||
}
|
||||
export function multiTrailingUnmapperOne(value) {
|
||||
const out = multiTrailingUnmapper(value);
|
||||
return [out[0], safeJoin(out[1], ':'), out[2]];
|
||||
}
|
||||
export function singleTrailingMapper(data) {
|
||||
return `${safeJoin(data[0], ':')}::${data[1]}`;
|
||||
}
|
||||
export function singleTrailingUnmapper(value) {
|
||||
if (typeof value !== 'string')
|
||||
throw new Error('Invalid type');
|
||||
const [bhString, trailing] = safeSplit(value, '::', 2);
|
||||
return [readBh(bhString), trailing];
|
||||
}
|
||||
export function noTrailingMapper(data) {
|
||||
return `${safeJoin(data[0], ':')}::`;
|
||||
}
|
||||
export function noTrailingUnmapper(value) {
|
||||
if (typeof value !== 'string')
|
||||
throw new Error('Invalid type');
|
||||
if (!safeEndsWith(value, '::'))
|
||||
throw new Error('Invalid value');
|
||||
return [readBh(safeSubstring(value, 0, value.length - 2))];
|
||||
}
|
||||
19
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToCharString.js
generated
vendored
Normal file
19
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToCharString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { safeCharCodeAt } from '../../../utils/globals.js';
|
||||
export const indexToCharStringMapper = String.fromCodePoint;
|
||||
export function indexToCharStringUnmapper(c) {
|
||||
if (typeof c !== 'string') {
|
||||
throw new Error('Cannot unmap non-string');
|
||||
}
|
||||
if (c.length === 0 || c.length > 2) {
|
||||
throw new Error('Cannot unmap string with more or less than one character');
|
||||
}
|
||||
const c1 = safeCharCodeAt(c, 0);
|
||||
if (c.length === 1) {
|
||||
return c1;
|
||||
}
|
||||
const c2 = safeCharCodeAt(c, 1);
|
||||
if (c1 < 0xd800 || c1 > 0xdbff || c2 < 0xdc00 || c2 > 0xdfff) {
|
||||
throw new Error('Cannot unmap invalid surrogate pairs');
|
||||
}
|
||||
return c.codePointAt(0);
|
||||
}
|
||||
67
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToMappedConstant.js
generated
vendored
Normal file
67
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToMappedConstant.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Error, Number, Map, safeMapGet, safeMapSet } from '../../../utils/globals.js';
|
||||
const safeObjectIs = Object.is;
|
||||
function buildDichotomyEntries(entries) {
|
||||
let currentFrom = 0;
|
||||
const dichotomyEntries = [];
|
||||
for (const entry of entries) {
|
||||
const from = currentFrom;
|
||||
currentFrom = from + entry.num;
|
||||
const to = currentFrom - 1;
|
||||
dichotomyEntries.push({ from, to, entry });
|
||||
}
|
||||
return dichotomyEntries;
|
||||
}
|
||||
function findDichotomyEntry(dichotomyEntries, choiceIndex) {
|
||||
let min = 0;
|
||||
let max = dichotomyEntries.length;
|
||||
while (max - min > 1) {
|
||||
const mid = ~~((min + max) / 2);
|
||||
if (choiceIndex < dichotomyEntries[mid].from) {
|
||||
max = mid;
|
||||
}
|
||||
else {
|
||||
min = mid;
|
||||
}
|
||||
}
|
||||
return dichotomyEntries[min];
|
||||
}
|
||||
export function indexToMappedConstantMapperFor(entries) {
|
||||
const dichotomyEntries = buildDichotomyEntries(entries);
|
||||
return function indexToMappedConstantMapper(choiceIndex) {
|
||||
const dichotomyEntry = findDichotomyEntry(dichotomyEntries, choiceIndex);
|
||||
return dichotomyEntry.entry.build(choiceIndex - dichotomyEntry.from);
|
||||
};
|
||||
}
|
||||
function buildReverseMapping(entries) {
|
||||
const reverseMapping = { mapping: new Map(), negativeZeroIndex: undefined };
|
||||
let choiceIndex = 0;
|
||||
for (let entryIdx = 0; entryIdx !== entries.length; ++entryIdx) {
|
||||
const entry = entries[entryIdx];
|
||||
for (let idxInEntry = 0; idxInEntry !== entry.num; ++idxInEntry) {
|
||||
const value = entry.build(idxInEntry);
|
||||
if (value === 0 && 1 / value === Number.NEGATIVE_INFINITY) {
|
||||
reverseMapping.negativeZeroIndex = choiceIndex;
|
||||
}
|
||||
else {
|
||||
safeMapSet(reverseMapping.mapping, value, choiceIndex);
|
||||
}
|
||||
++choiceIndex;
|
||||
}
|
||||
}
|
||||
return reverseMapping;
|
||||
}
|
||||
export function indexToMappedConstantUnmapperFor(entries) {
|
||||
let reverseMapping = null;
|
||||
return function indexToMappedConstantUnmapper(value) {
|
||||
if (reverseMapping === null) {
|
||||
reverseMapping = buildReverseMapping(entries);
|
||||
}
|
||||
const choiceIndex = safeObjectIs(value, -0)
|
||||
? reverseMapping.negativeZeroIndex
|
||||
: safeMapGet(reverseMapping.mapping, value);
|
||||
if (choiceIndex === undefined) {
|
||||
throw new Error('Unknown value encountered cannot be built using this mapToConstant');
|
||||
}
|
||||
return choiceIndex;
|
||||
};
|
||||
}
|
||||
14
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToPrintableIndex.js
generated
vendored
Normal file
14
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/IndexToPrintableIndex.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export function indexToPrintableIndexMapper(v) {
|
||||
if (v < 95)
|
||||
return v + 0x20;
|
||||
if (v <= 0x7e)
|
||||
return v - 95;
|
||||
return v;
|
||||
}
|
||||
export function indexToPrintableIndexUnmapper(v) {
|
||||
if (v >= 0x20 && v <= 0x7e)
|
||||
return v - 0x20;
|
||||
if (v >= 0 && v <= 0x1f)
|
||||
return v + 95;
|
||||
return v;
|
||||
}
|
||||
48
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/KeyValuePairsToObject.js
generated
vendored
Normal file
48
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/KeyValuePairsToObject.js
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { Error, safeEvery } from '../../../utils/globals.js';
|
||||
const safeObjectCreate = Object.create;
|
||||
const safeObjectDefineProperty = Object.defineProperty;
|
||||
const safeObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
const safeObjectGetPrototypeOf = Object.getPrototypeOf;
|
||||
const safeObjectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
const safeObjectGetOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
const safeObjectEntries = Object.entries;
|
||||
export function keyValuePairsToObjectMapper(definition) {
|
||||
const obj = definition[1] ? safeObjectCreate(null) : {};
|
||||
for (const keyValue of definition[0]) {
|
||||
safeObjectDefineProperty(obj, keyValue[0], {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: keyValue[1],
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
function buildIsValidPropertyNameFilter(obj) {
|
||||
return function isValidPropertyNameFilter(key) {
|
||||
const descriptor = safeObjectGetOwnPropertyDescriptor(obj, key);
|
||||
return (descriptor !== undefined &&
|
||||
!!descriptor.configurable &&
|
||||
!!descriptor.enumerable &&
|
||||
!!descriptor.writable &&
|
||||
descriptor.get === undefined &&
|
||||
descriptor.set === undefined);
|
||||
};
|
||||
}
|
||||
export function keyValuePairsToObjectUnmapper(value) {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
throw new Error('Incompatible instance received: should be a non-null object');
|
||||
}
|
||||
const hasNullPrototype = safeObjectGetPrototypeOf(value) === null;
|
||||
const hasObjectPrototype = 'constructor' in value && value.constructor === Object;
|
||||
if (!hasNullPrototype && !hasObjectPrototype) {
|
||||
throw new Error('Incompatible instance received: should be of exact type Object');
|
||||
}
|
||||
if (safeObjectGetOwnPropertySymbols(value).length > 0) {
|
||||
throw new Error('Incompatible instance received: should contain symbols');
|
||||
}
|
||||
if (!safeEvery(safeObjectGetOwnPropertyNames(value), buildIsValidPropertyNameFilter(value))) {
|
||||
throw new Error('Incompatible instance received: should contain only c/e/w properties without get/set');
|
||||
}
|
||||
return [safeObjectEntries(value), hasNullPrototype];
|
||||
}
|
||||
33
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/NatToStringifiedNat.js
generated
vendored
Normal file
33
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/NatToStringifiedNat.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { safeNumberToString, safeSubstring } from '../../../utils/globals.js';
|
||||
const safeNumberParseInt = Number.parseInt;
|
||||
export function natToStringifiedNatMapper(options) {
|
||||
const [style, v] = options;
|
||||
switch (style) {
|
||||
case 'oct':
|
||||
return `0${safeNumberToString(v, 8)}`;
|
||||
case 'hex':
|
||||
return `0x${safeNumberToString(v, 16)}`;
|
||||
case 'dec':
|
||||
default:
|
||||
return `${v}`;
|
||||
}
|
||||
}
|
||||
export function tryParseStringifiedNat(stringValue, radix) {
|
||||
const parsedNat = safeNumberParseInt(stringValue, radix);
|
||||
if (safeNumberToString(parsedNat, radix) !== stringValue) {
|
||||
throw new Error('Invalid value');
|
||||
}
|
||||
return parsedNat;
|
||||
}
|
||||
export function natToStringifiedNatUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
if (value.length >= 2 && value[0] === '0') {
|
||||
if (value[1] === 'x') {
|
||||
return ['hex', tryParseStringifiedNat(safeSubstring(value, 2), 16)];
|
||||
}
|
||||
return ['oct', tryParseStringifiedNat(safeSubstring(value, 1), 8)];
|
||||
}
|
||||
return ['dec', tryParseStringifiedNat(value, 10)];
|
||||
}
|
||||
17
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/NumberToPaddedEight.js
generated
vendored
Normal file
17
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/NumberToPaddedEight.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { safeNumberToString, safePadStart } from '../../../utils/globals.js';
|
||||
export function numberToPaddedEightMapper(n) {
|
||||
return safePadStart(safeNumberToString(n, 16), 8, '0');
|
||||
}
|
||||
export function numberToPaddedEightUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
if (value.length !== 8) {
|
||||
throw new Error('Unsupported value: invalid length');
|
||||
}
|
||||
const n = parseInt(value, 16);
|
||||
if (value !== numberToPaddedEightMapper(n)) {
|
||||
throw new Error('Unsupported value: invalid content');
|
||||
}
|
||||
return n;
|
||||
}
|
||||
15
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PaddedEightsToUuid.js
generated
vendored
Normal file
15
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PaddedEightsToUuid.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { safeSubstring } from '../../../utils/globals.js';
|
||||
export function paddedEightsToUuidMapper(t) {
|
||||
return `${t[0]}-${safeSubstring(t[1], 4)}-${safeSubstring(t[1], 0, 4)}-${safeSubstring(t[2], 0, 4)}-${safeSubstring(t[2], 4)}${t[3]}`;
|
||||
}
|
||||
const UuidRegex = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/;
|
||||
export function paddedEightsToUuidUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
const m = UuidRegex.exec(value);
|
||||
if (m === null) {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
return [m[1], m[3] + m[2], m[4] + safeSubstring(m[5], 0, 4), safeSubstring(m[5], 4)];
|
||||
}
|
||||
28
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PartsToUrl.js
generated
vendored
Normal file
28
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PartsToUrl.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
export function partsToUrlMapper(data) {
|
||||
const [scheme, authority, path] = data;
|
||||
const query = data[3] === null ? '' : `?${data[3]}`;
|
||||
const fragments = data[4] === null ? '' : `#${data[4]}`;
|
||||
return `${scheme}://${authority}${path}${query}${fragments}`;
|
||||
}
|
||||
const UrlSplitRegex = /^([[A-Za-z][A-Za-z0-9+.-]*):\/\/([^/?#]*)([^?#]*)(\?[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*)?(#[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*)?$/;
|
||||
export function partsToUrlUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Incompatible value received: type');
|
||||
}
|
||||
const m = UrlSplitRegex.exec(value);
|
||||
if (m === null) {
|
||||
throw new Error('Incompatible value received');
|
||||
}
|
||||
const scheme = m[1];
|
||||
const authority = m[2];
|
||||
const path = m[3];
|
||||
const query = m[4];
|
||||
const fragments = m[5];
|
||||
return [
|
||||
scheme,
|
||||
authority,
|
||||
path,
|
||||
query !== undefined ? query.substring(1) : null,
|
||||
fragments !== undefined ? fragments.substring(1) : null,
|
||||
];
|
||||
}
|
||||
27
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PatternsToString.js
generated
vendored
Normal file
27
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/PatternsToString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { MaxLengthUpperBound } from '../helpers/MaxLengthFromMinLength.js';
|
||||
import { safeJoin, Error } from '../../../utils/globals.js';
|
||||
import { tokenizeString } from '../helpers/TokenizeString.js';
|
||||
export function patternsToStringMapper(tab) {
|
||||
return safeJoin(tab, '');
|
||||
}
|
||||
function minLengthFrom(constraints) {
|
||||
return constraints.minLength !== undefined ? constraints.minLength : 0;
|
||||
}
|
||||
function maxLengthFrom(constraints) {
|
||||
return constraints.maxLength !== undefined ? constraints.maxLength : MaxLengthUpperBound;
|
||||
}
|
||||
export function patternsToStringUnmapperIsValidLength(tokens, constraints) {
|
||||
return minLengthFrom(constraints) <= tokens.length && tokens.length <= maxLengthFrom(constraints);
|
||||
}
|
||||
export function patternsToStringUnmapperFor(patternsArb, constraints) {
|
||||
return function patternsToStringUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported value');
|
||||
}
|
||||
const tokens = tokenizeString(patternsArb, value, minLengthFrom(constraints), maxLengthFrom(constraints));
|
||||
if (tokens === undefined) {
|
||||
throw new Error('Unable to unmap received string');
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
}
|
||||
13
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/SegmentsToPath.js
generated
vendored
Normal file
13
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/SegmentsToPath.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { safeJoin, safeMap, safeSplice, safeSplit } from '../../../utils/globals.js';
|
||||
export function segmentsToPathMapper(segments) {
|
||||
return safeJoin(safeMap(segments, (v) => `/${v}`), '');
|
||||
}
|
||||
export function segmentsToPathUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Incompatible value received: type');
|
||||
}
|
||||
if (value.length !== 0 && value[0] !== '/') {
|
||||
throw new Error('Incompatible value received: start');
|
||||
}
|
||||
return safeSplice(safeSplit(value, '/'), 1);
|
||||
}
|
||||
27
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/StringToBase64.js
generated
vendored
Normal file
27
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/StringToBase64.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { safeSubstring } from '../../../utils/globals.js';
|
||||
export function stringToBase64Mapper(s) {
|
||||
switch (s.length % 4) {
|
||||
case 0:
|
||||
return s;
|
||||
case 3:
|
||||
return `${s}=`;
|
||||
case 2:
|
||||
return `${s}==`;
|
||||
default:
|
||||
return safeSubstring(s, 1);
|
||||
}
|
||||
}
|
||||
export function stringToBase64Unmapper(value) {
|
||||
if (typeof value !== 'string' || value.length % 4 !== 0) {
|
||||
throw new Error('Invalid string received');
|
||||
}
|
||||
const lastTrailingIndex = value.indexOf('=');
|
||||
if (lastTrailingIndex === -1) {
|
||||
return value;
|
||||
}
|
||||
const numTrailings = value.length - lastTrailingIndex;
|
||||
if (numTrailings > 2) {
|
||||
throw new Error('Cannot unmap the passed value');
|
||||
}
|
||||
return safeSubstring(value, 0, lastTrailingIndex);
|
||||
}
|
||||
23
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/TimeToDate.js
generated
vendored
Normal file
23
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/TimeToDate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Date, Error, safeGetTime } from '../../../utils/globals.js';
|
||||
const safeNaN = Number.NaN;
|
||||
const safeNumberIsNaN = Number.isNaN;
|
||||
export function timeToDateMapper(time) {
|
||||
return new Date(time);
|
||||
}
|
||||
export function timeToDateUnmapper(value) {
|
||||
if (!(value instanceof Date) || value.constructor !== Date) {
|
||||
throw new Error('Not a valid value for date unmapper');
|
||||
}
|
||||
return safeGetTime(value);
|
||||
}
|
||||
export function timeToDateMapperWithNaN(valueForNaN) {
|
||||
return (time) => {
|
||||
return time === valueForNaN ? new Date(safeNaN) : timeToDateMapper(time);
|
||||
};
|
||||
}
|
||||
export function timeToDateUnmapperWithNaN(valueForNaN) {
|
||||
return (value) => {
|
||||
const time = timeToDateUnmapper(value);
|
||||
return safeNumberIsNaN(time) ? valueForNaN : time;
|
||||
};
|
||||
}
|
||||
106
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/UintToBase32String.js
generated
vendored
Normal file
106
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/UintToBase32String.js
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import { Error, String } from '../../../utils/globals.js';
|
||||
const encodeSymbolLookupTable = {
|
||||
10: 'A',
|
||||
11: 'B',
|
||||
12: 'C',
|
||||
13: 'D',
|
||||
14: 'E',
|
||||
15: 'F',
|
||||
16: 'G',
|
||||
17: 'H',
|
||||
18: 'J',
|
||||
19: 'K',
|
||||
20: 'M',
|
||||
21: 'N',
|
||||
22: 'P',
|
||||
23: 'Q',
|
||||
24: 'R',
|
||||
25: 'S',
|
||||
26: 'T',
|
||||
27: 'V',
|
||||
28: 'W',
|
||||
29: 'X',
|
||||
30: 'Y',
|
||||
31: 'Z',
|
||||
};
|
||||
const decodeSymbolLookupTable = {
|
||||
'0': 0,
|
||||
'1': 1,
|
||||
'2': 2,
|
||||
'3': 3,
|
||||
'4': 4,
|
||||
'5': 5,
|
||||
'6': 6,
|
||||
'7': 7,
|
||||
'8': 8,
|
||||
'9': 9,
|
||||
A: 10,
|
||||
B: 11,
|
||||
C: 12,
|
||||
D: 13,
|
||||
E: 14,
|
||||
F: 15,
|
||||
G: 16,
|
||||
H: 17,
|
||||
J: 18,
|
||||
K: 19,
|
||||
M: 20,
|
||||
N: 21,
|
||||
P: 22,
|
||||
Q: 23,
|
||||
R: 24,
|
||||
S: 25,
|
||||
T: 26,
|
||||
V: 27,
|
||||
W: 28,
|
||||
X: 29,
|
||||
Y: 30,
|
||||
Z: 31,
|
||||
};
|
||||
function encodeSymbol(symbol) {
|
||||
return symbol < 10 ? String(symbol) : encodeSymbolLookupTable[symbol];
|
||||
}
|
||||
function pad(value, paddingLength) {
|
||||
let extraPadding = '';
|
||||
while (value.length + extraPadding.length < paddingLength) {
|
||||
extraPadding += '0';
|
||||
}
|
||||
return extraPadding + value;
|
||||
}
|
||||
function smallUintToBase32StringMapper(num) {
|
||||
let base32Str = '';
|
||||
for (let remaining = num; remaining !== 0;) {
|
||||
const next = remaining >> 5;
|
||||
const current = remaining - (next << 5);
|
||||
base32Str = encodeSymbol(current) + base32Str;
|
||||
remaining = next;
|
||||
}
|
||||
return base32Str;
|
||||
}
|
||||
export function uintToBase32StringMapper(num, paddingLength) {
|
||||
const head = ~~(num / 0x40000000);
|
||||
const tail = num & 0x3fffffff;
|
||||
return pad(smallUintToBase32StringMapper(head), paddingLength - 6) + pad(smallUintToBase32StringMapper(tail), 6);
|
||||
}
|
||||
export function paddedUintToBase32StringMapper(paddingLength) {
|
||||
return function padded(num) {
|
||||
return uintToBase32StringMapper(num, paddingLength);
|
||||
};
|
||||
}
|
||||
export function uintToBase32StringUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
let accumulated = 0;
|
||||
let power = 1;
|
||||
for (let index = value.length - 1; index >= 0; --index) {
|
||||
const char = value[index];
|
||||
const numericForChar = decodeSymbolLookupTable[char];
|
||||
if (numericForChar === undefined) {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
accumulated += numericForChar * power;
|
||||
power *= 32;
|
||||
}
|
||||
return accumulated;
|
||||
}
|
||||
21
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/UnboxedToBoxed.js
generated
vendored
Normal file
21
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/UnboxedToBoxed.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Boolean, Number, String } from '../../../utils/globals.js';
|
||||
export function unboxedToBoxedMapper(value) {
|
||||
switch (typeof value) {
|
||||
case 'boolean':
|
||||
return new Boolean(value);
|
||||
case 'number':
|
||||
return new Number(value);
|
||||
case 'string':
|
||||
return new String(value);
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
export function unboxedToBoxedUnmapper(value) {
|
||||
if (typeof value !== 'object' || value === null || !('constructor' in value)) {
|
||||
return value;
|
||||
}
|
||||
return value.constructor === Boolean || value.constructor === Number || value.constructor === String
|
||||
? value.valueOf()
|
||||
: value;
|
||||
}
|
||||
59
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ValuesAndSeparateKeysToObject.js
generated
vendored
Normal file
59
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/ValuesAndSeparateKeysToObject.js
generated
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { safePush } from '../../../utils/globals.js';
|
||||
const safeObjectCreate = Object.create;
|
||||
const safeObjectDefineProperty = Object.defineProperty;
|
||||
const safeObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
const safeObjectGetOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
const safeObjectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
export function buildValuesAndSeparateKeysToObjectMapper(keys, noKeyValue) {
|
||||
return function valuesAndSeparateKeysToObjectMapper(definition) {
|
||||
const obj = definition[1] ? safeObjectCreate(null) : {};
|
||||
for (let idx = 0; idx !== keys.length; ++idx) {
|
||||
const valueWrapper = definition[0][idx];
|
||||
if (valueWrapper !== noKeyValue) {
|
||||
safeObjectDefineProperty(obj, keys[idx], {
|
||||
value: valueWrapper,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
export function buildValuesAndSeparateKeysToObjectUnmapper(keys, noKeyValue) {
|
||||
return function valuesAndSeparateKeysToObjectUnmapper(value) {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
throw new Error('Incompatible instance received: should be a non-null object');
|
||||
}
|
||||
const hasNullPrototype = Object.getPrototypeOf(value) === null;
|
||||
const hasObjectPrototype = 'constructor' in value && value.constructor === Object;
|
||||
if (!hasNullPrototype && !hasObjectPrototype) {
|
||||
throw new Error('Incompatible instance received: should be of exact type Object');
|
||||
}
|
||||
let extractedPropertiesCount = 0;
|
||||
const extractedValues = [];
|
||||
for (let idx = 0; idx !== keys.length; ++idx) {
|
||||
const descriptor = safeObjectGetOwnPropertyDescriptor(value, keys[idx]);
|
||||
if (descriptor !== undefined) {
|
||||
if (!descriptor.configurable || !descriptor.enumerable || !descriptor.writable) {
|
||||
throw new Error('Incompatible instance received: should contain only c/e/w properties');
|
||||
}
|
||||
if (descriptor.get !== undefined || descriptor.set !== undefined) {
|
||||
throw new Error('Incompatible instance received: should contain only no get/set properties');
|
||||
}
|
||||
++extractedPropertiesCount;
|
||||
safePush(extractedValues, descriptor.value);
|
||||
}
|
||||
else {
|
||||
safePush(extractedValues, noKeyValue);
|
||||
}
|
||||
}
|
||||
const namePropertiesCount = safeObjectGetOwnPropertyNames(value).length;
|
||||
const symbolPropertiesCount = safeObjectGetOwnPropertySymbols(value).length;
|
||||
if (extractedPropertiesCount !== namePropertiesCount + symbolPropertiesCount) {
|
||||
throw new Error('Incompatible instance received: should not contain extra properties');
|
||||
}
|
||||
return [extractedValues, hasNullPrototype];
|
||||
};
|
||||
}
|
||||
26
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/VersionsApplierForUuid.js
generated
vendored
Normal file
26
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/VersionsApplierForUuid.js
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { Error, safeSubstring } from '../../../utils/globals.js';
|
||||
const quickNumberToHexaString = '0123456789abcdef';
|
||||
export function buildVersionsAppliersForUuid(versions) {
|
||||
const mapping = {};
|
||||
const reversedMapping = {};
|
||||
for (let index = 0; index !== versions.length; ++index) {
|
||||
const from = quickNumberToHexaString[index];
|
||||
const to = quickNumberToHexaString[versions[index]];
|
||||
mapping[from] = to;
|
||||
reversedMapping[to] = from;
|
||||
}
|
||||
function versionsApplierMapper(value) {
|
||||
return mapping[value[0]] + safeSubstring(value, 1);
|
||||
}
|
||||
function versionsApplierUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Cannot produce non-string values');
|
||||
}
|
||||
const rev = reversedMapping[value[0]];
|
||||
if (rev === undefined) {
|
||||
throw new Error('Cannot produce strings not starting by the version in hexa code');
|
||||
}
|
||||
return rev + safeSubstring(value, 1);
|
||||
}
|
||||
return { versionsApplierMapper, versionsApplierUnmapper };
|
||||
}
|
||||
67
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/WordsToLorem.js
generated
vendored
Normal file
67
node_modules/fast-check/lib/esm/arbitrary/_internals/mappers/WordsToLorem.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { safeJoin, safeMap, safePush, safeSplit, safeSubstring, safeToLowerCase, safeToUpperCase, } from '../../../utils/globals.js';
|
||||
export function wordsToJoinedStringMapper(words) {
|
||||
return safeJoin(safeMap(words, (w) => (w[w.length - 1] === ',' ? safeSubstring(w, 0, w.length - 1) : w)), ' ');
|
||||
}
|
||||
export function wordsToJoinedStringUnmapperFor(wordsArbitrary) {
|
||||
return function wordsToJoinedStringUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
const words = [];
|
||||
for (const candidate of safeSplit(value, ' ')) {
|
||||
if (wordsArbitrary.canShrinkWithoutContext(candidate))
|
||||
safePush(words, candidate);
|
||||
else if (wordsArbitrary.canShrinkWithoutContext(candidate + ','))
|
||||
safePush(words, candidate + ',');
|
||||
else
|
||||
throw new Error('Unsupported word');
|
||||
}
|
||||
return words;
|
||||
};
|
||||
}
|
||||
export function wordsToSentenceMapper(words) {
|
||||
let sentence = safeJoin(words, ' ');
|
||||
if (sentence[sentence.length - 1] === ',') {
|
||||
sentence = safeSubstring(sentence, 0, sentence.length - 1);
|
||||
}
|
||||
return safeToUpperCase(sentence[0]) + safeSubstring(sentence, 1) + '.';
|
||||
}
|
||||
export function wordsToSentenceUnmapperFor(wordsArbitrary) {
|
||||
return function wordsToSentenceUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
if (value.length < 2 ||
|
||||
value[value.length - 1] !== '.' ||
|
||||
value[value.length - 2] === ',' ||
|
||||
safeToUpperCase(safeToLowerCase(value[0])) !== value[0]) {
|
||||
throw new Error('Unsupported value');
|
||||
}
|
||||
const adaptedValue = safeToLowerCase(value[0]) + safeSubstring(value, 1, value.length - 1);
|
||||
const words = [];
|
||||
const candidates = safeSplit(adaptedValue, ' ');
|
||||
for (let idx = 0; idx !== candidates.length; ++idx) {
|
||||
const candidate = candidates[idx];
|
||||
if (wordsArbitrary.canShrinkWithoutContext(candidate))
|
||||
safePush(words, candidate);
|
||||
else if (idx === candidates.length - 1 && wordsArbitrary.canShrinkWithoutContext(candidate + ','))
|
||||
safePush(words, candidate + ',');
|
||||
else
|
||||
throw new Error('Unsupported word');
|
||||
}
|
||||
return words;
|
||||
};
|
||||
}
|
||||
export function sentencesToParagraphMapper(sentences) {
|
||||
return safeJoin(sentences, ' ');
|
||||
}
|
||||
export function sentencesToParagraphUnmapper(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error('Unsupported type');
|
||||
}
|
||||
const sentences = safeSplit(value, '. ');
|
||||
for (let idx = 0; idx < sentences.length - 1; ++idx) {
|
||||
sentences[idx] += '.';
|
||||
}
|
||||
return sentences;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue