Skip to content

Commit

Permalink
Fix flaky arbitrary property generation for the id function test
Browse files Browse the repository at this point in the history
The test for `id` uses fast-check to generate arbitrary properties, and
could potentially generate `NaN` as a property. `NaN` is not strictly
equal to itself (using `===`), which could cause the test to fail. This
applies a filter to the arbitrary property generation to disallow `NaN`.
  • Loading branch information
jmartinezmaes committed Oct 23, 2022
1 parent 21320d9 commit 115ac2a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/fn_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { id, negate } from "../src/fn.js";
describe("Functions", () => {
specify("id", () => {
fc.assert(
fc.property(fc.anything(), (x) => {
assert.strictEqual(id(x), x);
}),
fc.property(
fc.anything().filter((x) => !Number.isNaN(x)),
(x) => assert.strictEqual(id(x), x),
),
);
});

Expand Down

0 comments on commit 115ac2a

Please sign in to comment.