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

"(exhausted)" is printed late? #19

Closed
jwaldmann opened this issue Jun 14, 2022 · 1 comment
Closed

"(exhausted)" is printed late? #19

jwaldmann opened this issue Jun 14, 2022 · 1 comment

Comments

@jwaldmann
Copy link

this is nit-picking, but ..

ghci> checkFor 2 $ \ x -> x == not (not x)
+++ OK, passed 2 tests.

ghci> checkFor 3 $ \ x -> x == not (not x)
+++ OK, passed 2 tests (exhausted).

I was expecting the (exhausted) message to appear already in the first example.

rudymatela added a commit that referenced this issue Aug 13, 2022
Thanks to Johannes Waldmann for noticing and reporting this caveat:
#19
@rudymatela
Copy link
Owner

rudymatela commented Aug 13, 2022

The meaning of exhausted in LeanCheck is slightly confusing indeed...

I have added (e9f1a89, 5529de1) the following note in the haddock of checkFor clarifying the caveat:

-- Test exhaustion is reported when the configured number of tests
-- is larger than the number of available test values:
--
-- > > checkFor 3 $ \p -> p == not (not p)
-- > +++ OK, passed 2 tests (exhausted).

Test exhaustion is reported when the configured number of tests is larger than the number of available test values:

> checkFor 3 $ \p -> p == not (not p)
+++ OK, passed 2 tests (exhausted).

The straightorward meaning of exhausted would be to say that all possible values are tested. Unfortunately, that is not the case in LeanCheck: here "exhaustion" means: no more tests could be enumerated.

The problem is that there is no way for LeanCheck to know that tests are exhausted unless it tries to enumerate one more element. In your example here:

> checkFor 2 $ \ x -> x == not (not x)
+++ OK, passed 2 tests.

LeanCheck has no way of knowing that there are only two possible booleans unless it tries (and fails) to enumerate a third.

We are left with two options:

  1. when configured to test n elements, always try to enumerate n+1, so we know that we are actually exhausted on n;
  2. document the caveat to note that exhausted only appears when LeanCheck tries to enumerate but it cannot. That is, when the maximum number of tests is larger than the number of enumerated values.

With option 1, we would be inconsistent with the number of tests and enumerated values. With option 2, we have a slightly confusing meaning of "exhausted".

I went with option 2: e9f1a89, 5529de1.

rudymatela added a commit that referenced this issue Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants