Skip to content
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

πŸ’š Stabilize tests of double on small ranges #4926

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yarn/versions/fe923812.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declined:
- fast-check
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,25 @@ function constraintsInternal(
const maxIndex = floatToIndex(resolvedCt.max);
const distance = maxIndex - minIndex;
// Dangerous range, not enough value in range to safely run
// Worst cases:
// > [int, float, int] -> distance is 2,
// > ]int, float, int[ -> distance is 2,
// -> for >= 2 it's safe, we will alays have a non-integer value within the range
if (distance < 2) return false;
// Worst broken cases:
// > {float, int, float} with distance 2 such as from 8388606.5 (excl.) to 8388607.5 (excl.)
// > {float, -0, 0} with distance 2 such as from -MIN_VALUE (excl.) to 0
// > {-0, 0, float} with distance 2 such as from 0 to MIN_VALUE (excl.)
// -> for >= 3 it's safe, we will always have a non-integer value within the range
if (distance < 3) return false;
} else {
const resolvedCt = refineConstraintsForDoubleOnly(ct);
if (resolvedCt.min > resolvedCt.max) return false;
const minIndex = doubleToIndex(resolvedCt.min);
const maxIndex = doubleToIndex(resolvedCt.max);
const distance = substract64(maxIndex, minIndex);
// Dangerous range, not enough value in range to safely run
// Worst cases:
// > [int, float, int] -> distance is 2,
// > ]int, float, int[ -> distance is 2,
// -> for >= 2 it's safe, we will alays have a non-integer value within the range
if (distance.data[0] === 0 && distance.data[1] < 2) return false;
// Worst broken cases:
// > {float, int, float} with distance 2 such as from 4503599627370494.5 (excl.) to 4503599627370495.5 (excl.)
// > {float, -0, 0} with distance 2 such as from -MIN_VALUE (excl.) to 0
// > {-0, 0, float} with distance 2 such as from 0 to MIN_VALUE (excl.)
// -> for >= 3 it's safe, we will always have a non-integer value within the range
if (distance.data[0] === 0 && distance.data[1] < 3) return false;
}
return true;
});
Expand Down
Loading