Skip to content

Commit

Permalink
✅ Add extra set of tests for constant*
Browse files Browse the repository at this point in the history
These new tests will make sure that we never break things around `-0` and `0` unwantingly if we want to make `canShrinkWithoutContext` more performant.
  • Loading branch information
dubzzz authored Oct 25, 2024
1 parent 00c0490 commit 914ad82
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ describe('ConstantArbitrary', () => {
// Assert
expect(out).toBe(false); // Object.is([], []) is falsy
});

it.each([{ source: -0 }, { source: 0 }, { source: 48 }])(
'should not accept to shrink -$source if built with $source',
({ source }) => {
// Arrange
const arb = new ConstantArbitrary([source]);

// Act
const out = arb.canShrinkWithoutContext(-source);

// Assert
expect(out).toBe(false);
},
);

it.each([{ source: -0 }, { source: 0 }, { source: 48 }])(
'should accept to shrink $source if built with $source',
({ source }) => {
// Arrange
const arb = new ConstantArbitrary([source]);

// Act
const out = arb.canShrinkWithoutContext(source);

// Assert
expect(out).toBe(true);
},
);
});

describe('shrink', () => {
Expand Down

0 comments on commit 914ad82

Please sign in to comment.