fast-check
Advanced tools
Comparing version
@@ -5,2 +5,3 @@ import { escapeForTemplateString } from '../helpers/TextEscaper.js'; | ||
const defaultSchedulerAct = (f) => f(); | ||
export const numTicksBeforeScheduling = 50; | ||
export class SchedulerImplem { | ||
@@ -125,7 +126,15 @@ constructor(act, taskSelector) { | ||
let taskResolved = false; | ||
let awaiterTicks = 0; | ||
let awaiterPromise = null; | ||
let awaiterScheduledTaskPromise = null; | ||
const awaiter = async () => { | ||
while (!taskResolved && this.scheduledTasks.length > 0) { | ||
await this.waitOne(customAct); | ||
awaiterTicks = numTicksBeforeScheduling; | ||
for (awaiterTicks = numTicksBeforeScheduling; !taskResolved && awaiterTicks > 0; --awaiterTicks) { | ||
await Promise.resolve(); | ||
} | ||
if (!taskResolved && this.scheduledTasks.length > 0) { | ||
awaiterScheduledTaskPromise = this.waitOne(customAct); | ||
awaiterScheduledTaskPromise.then(() => (awaiterScheduledTaskPromise = null), () => (awaiterScheduledTaskPromise = null)); | ||
return awaiterScheduledTaskPromise.then(awaiter); | ||
} | ||
awaiterPromise = null; | ||
@@ -135,5 +144,6 @@ }; | ||
if (awaiterPromise !== null) { | ||
awaiterTicks = numTicksBeforeScheduling + 1; | ||
return; | ||
} | ||
awaiterPromise = Promise.resolve().then(awaiter); | ||
awaiterPromise = awaiter(); | ||
}; | ||
@@ -151,7 +161,7 @@ const clearAndReplaceWatcher = () => { | ||
taskResolved = true; | ||
if (awaiterPromise === null) { | ||
if (awaiterScheduledTaskPromise === null) { | ||
clearAndReplaceWatcher(); | ||
return ret; | ||
} | ||
return awaiterPromise.then(() => { | ||
return awaiterScheduledTaskPromise.then(() => { | ||
clearAndReplaceWatcher(); | ||
@@ -162,7 +172,7 @@ return ret; | ||
taskResolved = true; | ||
if (awaiterPromise === null) { | ||
if (awaiterScheduledTaskPromise === null) { | ||
clearAndReplaceWatcher(); | ||
throw err; | ||
} | ||
return awaiterPromise.then(() => { | ||
return awaiterScheduledTaskPromise.then(() => { | ||
clearAndReplaceWatcher(); | ||
@@ -169,0 +179,0 @@ throw err; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SchedulerImplem = void 0; | ||
exports.SchedulerImplem = exports.numTicksBeforeScheduling = void 0; | ||
const TextEscaper_1 = require("../helpers/TextEscaper"); | ||
@@ -8,2 +8,3 @@ const symbols_1 = require("../../../check/symbols"); | ||
const defaultSchedulerAct = (f) => f(); | ||
exports.numTicksBeforeScheduling = 50; | ||
class SchedulerImplem { | ||
@@ -128,7 +129,15 @@ constructor(act, taskSelector) { | ||
let taskResolved = false; | ||
let awaiterTicks = 0; | ||
let awaiterPromise = null; | ||
let awaiterScheduledTaskPromise = null; | ||
const awaiter = async () => { | ||
while (!taskResolved && this.scheduledTasks.length > 0) { | ||
await this.waitOne(customAct); | ||
awaiterTicks = exports.numTicksBeforeScheduling; | ||
for (awaiterTicks = exports.numTicksBeforeScheduling; !taskResolved && awaiterTicks > 0; --awaiterTicks) { | ||
await Promise.resolve(); | ||
} | ||
if (!taskResolved && this.scheduledTasks.length > 0) { | ||
awaiterScheduledTaskPromise = this.waitOne(customAct); | ||
awaiterScheduledTaskPromise.then(() => (awaiterScheduledTaskPromise = null), () => (awaiterScheduledTaskPromise = null)); | ||
return awaiterScheduledTaskPromise.then(awaiter); | ||
} | ||
awaiterPromise = null; | ||
@@ -138,5 +147,6 @@ }; | ||
if (awaiterPromise !== null) { | ||
awaiterTicks = exports.numTicksBeforeScheduling + 1; | ||
return; | ||
} | ||
awaiterPromise = Promise.resolve().then(awaiter); | ||
awaiterPromise = awaiter(); | ||
}; | ||
@@ -154,7 +164,7 @@ const clearAndReplaceWatcher = () => { | ||
taskResolved = true; | ||
if (awaiterPromise === null) { | ||
if (awaiterScheduledTaskPromise === null) { | ||
clearAndReplaceWatcher(); | ||
return ret; | ||
} | ||
return awaiterPromise.then(() => { | ||
return awaiterScheduledTaskPromise.then(() => { | ||
clearAndReplaceWatcher(); | ||
@@ -165,7 +175,7 @@ return ret; | ||
taskResolved = true; | ||
if (awaiterPromise === null) { | ||
if (awaiterScheduledTaskPromise === null) { | ||
clearAndReplaceWatcher(); | ||
throw err; | ||
} | ||
return awaiterPromise.then(() => { | ||
return awaiterScheduledTaskPromise.then(() => { | ||
clearAndReplaceWatcher(); | ||
@@ -172,0 +182,0 @@ throw err; |
@@ -203,5 +203,5 @@ "use strict"; | ||
exports.__type = __type; | ||
const __version = '4.0.1'; | ||
const __version = '4.1.0'; | ||
exports.__version = __version; | ||
const __commitHash = 'fab3176335c6fd362f204be710ad482f8462efca'; | ||
const __commitHash = '9375f31f81ca6a8efd2bc87a513378bf0b2680fb'; | ||
exports.__commitHash = __commitHash; |
@@ -157,3 +157,3 @@ import { pre } from './check/precondition/Pre.js'; | ||
/** | ||
* Version of fast-check used by your project (eg.: 4.0.1) | ||
* Version of fast-check used by your project (eg.: 4.1.0) | ||
* @remarks Since 1.22.0 | ||
@@ -164,3 +164,3 @@ * @public | ||
/** | ||
* Commit hash of the current code (eg.: fab3176335c6fd362f204be710ad482f8462efca) | ||
* Commit hash of the current code (eg.: 9375f31f81ca6a8efd2bc87a513378bf0b2680fb) | ||
* @remarks Since 2.7.0 | ||
@@ -167,0 +167,0 @@ * @public |
@@ -157,3 +157,3 @@ import { pre } from './check/precondition/Pre.js'; | ||
/** | ||
* Version of fast-check used by your project (eg.: 4.0.1) | ||
* Version of fast-check used by your project (eg.: 4.1.0) | ||
* @remarks Since 1.22.0 | ||
@@ -164,3 +164,3 @@ * @public | ||
/** | ||
* Commit hash of the current code (eg.: fab3176335c6fd362f204be710ad482f8462efca) | ||
* Commit hash of the current code (eg.: 9375f31f81ca6a8efd2bc87a513378bf0b2680fb) | ||
* @remarks Since 2.7.0 | ||
@@ -167,0 +167,0 @@ * @public |
@@ -91,4 +91,4 @@ import { pre } from './check/precondition/Pre.js'; | ||
const __type = 'module'; | ||
const __version = '4.0.1'; | ||
const __commitHash = 'fab3176335c6fd362f204be710ad482f8462efca'; | ||
const __version = '4.1.0'; | ||
const __commitHash = '9375f31f81ca6a8efd2bc87a513378bf0b2680fb'; | ||
export { __type, __version, __commitHash, sample, statistics, check, assert, pre, PreconditionFailure, property, asyncProperty, boolean, falsy, float, double, integer, nat, maxSafeInteger, maxSafeNat, bigInt, mixedCase, string, base64String, stringMatching, limitShrink, lorem, constant, constantFrom, mapToConstant, option, oneof, clone, noBias, noShrink, shuffledSubarray, subarray, array, sparseArray, infiniteStream, uniqueArray, tuple, record, dictionary, anything, object, json, jsonValue, letrec, memo, compareBooleanFunc, compareFunc, func, context, gen, date, ipV4, ipV4Extended, ipV6, domain, webAuthority, webSegment, webFragments, webPath, webQueryParameters, webUrl, emailAddress, ulid, uuid, 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, }; |
@@ -157,3 +157,3 @@ import { pre } from './check/precondition/Pre.js'; | ||
/** | ||
* Version of fast-check used by your project (eg.: 4.0.1) | ||
* Version of fast-check used by your project (eg.: 4.1.0) | ||
* @remarks Since 1.22.0 | ||
@@ -164,3 +164,3 @@ * @public | ||
/** | ||
* Commit hash of the current code (eg.: fab3176335c6fd362f204be710ad482f8462efca) | ||
* Commit hash of the current code (eg.: 9375f31f81ca6a8efd2bc87a513378bf0b2680fb) | ||
* @remarks Since 2.7.0 | ||
@@ -167,0 +167,0 @@ * @public |
@@ -157,3 +157,3 @@ import { pre } from './check/precondition/Pre.js'; | ||
/** | ||
* Version of fast-check used by your project (eg.: 4.0.1) | ||
* Version of fast-check used by your project (eg.: 4.1.0) | ||
* @remarks Since 1.22.0 | ||
@@ -164,3 +164,3 @@ * @public | ||
/** | ||
* Commit hash of the current code (eg.: fab3176335c6fd362f204be710ad482f8462efca) | ||
* Commit hash of the current code (eg.: 9375f31f81ca6a8efd2bc87a513378bf0b2680fb) | ||
* @remarks Since 2.7.0 | ||
@@ -167,0 +167,0 @@ * @public |
{ | ||
"name": "fast-check", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Property based testing framework for JavaScript (like QuickCheck)", | ||
@@ -55,4 +55,4 @@ "type": "module", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.52.2", | ||
"@types/node": "^22.13.14", | ||
"@microsoft/api-extractor": "^7.52.3", | ||
"@types/node": "^22.13.17", | ||
"cross-env": "^7.0.3", | ||
@@ -68,3 +68,3 @@ "glob": "^11.0.1", | ||
"@fast-check/poisoning": "0.2.3", | ||
"fast-check": "4.0.1" | ||
"fast-check": "4.1.0" | ||
}, | ||
@@ -71,0 +71,0 @@ "keywords": [ |
1528235
0.09%38952
0.05%