New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not sure worker properly support fc.pre #4473
Labels
✔️ Bug Confirmed
🐛 Bug Report
good first issue
easy issue to start with - contributions welcome
help wanted
contributions welcome
Comments
dubzzz
added
good first issue
easy issue to start with - contributions welcome
help wanted
contributions welcome
labels
Jan 2, 2024
Issue confirmed: import fc from "fast-check";
import { isMainThread } from "node:worker_threads";
import { assert, propertyFor } from "@fast-check/worker";
const property = propertyFor(new URL(import.meta.url));
const p1 = property(fc.nat()), (n) => {
fc.pre(n % 2 === 0);
// Never failing always succeeding...
});
if (isMainThread) {
await assert(p1, { timeout: 1000 });
} Results into: Error: Property failed after 1 tests
{ seed: 1303443886, path: "0:1:1:1:0:0:1:0:1:2:0:0:0:1:2:2:0:0:0", endOnFailure: true }
Counterexample: [358591287]
Shrunk 18 time(s)
Got Error
at Module.pre (file:///D:/Dev/fast-check-playground/node_modules/fast-check/lib/esm/check/precondition/Pre.js:4:15)
at file:///D:/Dev/fast-check-playground/worker.mjs:7:6
at MessagePort.<anonymous> (file:///D:/Dev/fast-check-playground/node_modules/@fast-check/worker/lib/internals/worker-runner/WorkerRunner.js:8:25)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
Hint: Enable verbose mode in order to have the list of all failing values encountered during the run
at buildError (file:///D:/Dev/fast-check-playground/node_modules/fast-check/lib/esm/check/runner/utils/RunDetailsFormatter.js:126:15)
at asyncThrowIfFailed (file:///D:/Dev/fast-check-playground/node_modules/fast-check/lib/esm/check/runner/utils/RunDetailsFormatter.js:143:11) |
8 tasks
dubzzz
added a commit
that referenced
this issue
May 16, 2024
**Description** The package `@fast-check/worker` was not compatible with `fc.pre`. As such users were unable to rely on one of the core built-in primitives provided by fast-check. This PR adds support for it. Fixes #4473 <!-- Please provide a short description and potentially linked issues hustifying the need for this PR --> <!-- * Your PR is fixing a bug or regression? Check for existing issues related to this bug and link them --> <!-- * Your PR is adding a new feature? Make sure there is a related issue or discussion attached to it --> <!-- You can provide any additional context to help into understanding what's this PR is attempting to solve: reproduction of a bug, code snippets... --> **Checklist** — _Don't delete this checklist and make sure you do the following before opening the PR_ - [x] The name of my PR follows [gitmoji](https://gitmoji.dev/) specification - [x] My PR references one of several related issues (if any) - [x] New features or breaking changes must come with an associated Issue or Discussion - [x] My PR does not add any new dependency without an associated Issue or Discussion - [x] My PR includes bumps details, please run `yarn bump` and flag the impacts properly - [x] My PR adds relevant tests and they would have failed without my PR (when applicable) <!-- More about contributing at https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md --> **Advanced** <!-- How to fill the advanced section is detailed below! --> - [x] Category: ✨ Introduce new features - [x] Impacts: properties with `fc.pre` will behave correctly <!-- [Category] Please use one of the categories below, it will help us into better understanding the urgency of the PR --> <!-- * ✨ Introduce new features --> <!-- * 📝 Add or update documentation --> <!-- * ✅ Add or update tests --> <!-- * 🐛 Fix a bug --> <!-- * 🏷️ Add or update types --> <!-- * ⚡️ Improve performance --> <!-- * _Other(s):_ ... --> <!-- [Impacts] Please provide a comma separated list of the potential impacts that might be introduced by this change --> <!-- * Generated values: Can your change impact any of the existing generators in terms of generated values, if so which ones? when? --> <!-- * Shrink values: Can your change impact any of the existing generators in terms of shrink values, if so which ones? when? --> <!-- * Performance: Can it require some typings changes on user side? Please give more details --> <!-- * Typings: Is there a potential performance impact? In which cases? -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
✔️ Bug Confirmed
🐛 Bug Report
good first issue
easy issue to start with - contributions welcome
help wanted
contributions welcome
To be checked and tested
The text was updated successfully, but these errors were encountered: