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

test: Ensure access to reduced counterexamples from fast-check #4631

Merged
merged 3 commits into from
Feb 24, 2022

Conversation

gibson042
Copy link
Member

Description

Updates use of fast-check assert to conform with its documentation: https://dubzzz.github.io/fast-check/index.html#assert

WARNING: Has to be awaited

Returns Promise<void>

Security Considerations

n/a

Documentation Considerations

n/a

Testing Considerations

Noted above.

Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing this, Richard.

FYI, @dckc, who introduced these tests.

@dckc
Copy link
Member

dckc commented Feb 22, 2022

Weird. Their tutorial example treats fc.assert as sync.

@gibson042
Copy link
Member Author

It took some digging, but I think I got to the bottom of it—fc.assert has multiple signatures, and is asynchronous if and only if the property being tested is asynchronous. So landing this PR is safe (and possibly future-proof) but unnecessary.

@gibson042
Copy link
Member Author

I also opened an issue in fast-check: dubzzz/fast-check#2749

test('isEqual is a (total) equivalence relation', t => {
fc.assert(
test('isEqual is a (total) equivalence relation', async t => {
await fc.assert(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed given the fact that you are using a sync property.

const empty = m.makeEmpty(mockBrand, AssetKind.COPY_BAG);
fc.assert(
await fc.assert(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

const empty = m.makeEmpty(mockBrand, AssetKind.COPY_BAG);
fc.assert(
await fc.assert(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

test('subtract: (x + y) - y = x; (y - x) + x = y if y >= x', t => {
fc.assert(
test('subtract: (x + y) - y = x; (y - x) + x = y if y >= x', async t => {
await fc.assert(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

test('balancesToReachRatio calculations are to spec', t => {
fc.assert(
test('balancesToReachRatio calculations are to spec', async t => {
await fc.assert(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@dubzzz
Copy link

dubzzz commented Feb 22, 2022

Only asyncProperty has to be awaited. Normal property can be but it is not needed. Anyway, always awaiting can avoid forgetting about it and will work for both (while not awaiting the async one will miss bugs).

@gibson042 gibson042 force-pushed the 2022-02-fast-check branch 2 times, most recently from 6206135 to 8302358 Compare February 24, 2022 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants