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 a subset of laws / exclude some laws #127

Open
dschrempf opened this issue Jul 23, 2021 · 3 comments
Open

Test a subset of laws / exclude some laws #127

dschrempf opened this issue Jul 23, 2021 · 3 comments

Comments

@dschrempf
Copy link

Hello,

I have a zip-like applicative instance of a tree (similar to a ZipList), and I would like to test the applicative laws. I know that

Homomorphism
pure f <*> pure x ≡ pure (f x)

holds, but the test suite hangs (because pure x is an infinite tree).

Is there a way to test the the applicative laws but exclude this one test. In general, is there a way to perform a test on a subset of laws?

Thank you!

@andrewthad
Copy link
Owner

There is not currently a way to do this. In the interest of pragmatism, I'd think I'd be fine with a PR adding applicativeWithoutHomomorphismLaws, which would just not do that one test. Alternatively, if you're using tasty, you might be able to use a flag to exclude tests matching a certain pattern, or you may be able to modify the options (adding the exclusion) after tasty has parsed the options.

@andrewthad
Copy link
Owner

Sorry, didn't mean to close.

@dschrempf
Copy link
Author

dschrempf commented Jul 23, 2021

OK. In this case, I propose using the following function (works very well here):

filterLaws :: [String] -> Laws -> Laws
filterLaws xs (Laws tn ps) = Laws tn [ (n, p) | (n, p) <- ps, n `notElem` xs ]

Then, one can use, e.g.,

      lawsCheck (filterLaws ["Homomorphism"] $ applicativeLaws (Proxy :: Proxy (ZipTree String)))

Or maybe excludeLaws would be more appropriate.

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