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
The first step towards validity-based testing. #36
Conversation
Just saw your continuous builds. |
I'm having hard time seeing any value in this PR. Depending on your |
Why would you want to do (6)? All the useful functions take |
This PR is not done, I would go at least through the first 5 steps (6 was optional anyway) before merging anything. I use validity because then I can do testing with genvalidity-hspec. |
See https://github.com/NorfairKing/safepath/blob/master/safepath-testing/test/Data/PathSpec.hs for the kind of tests I mean. |
As I said elsewhere, depending on E.g. -- | Convert a relative 'FilePath' to a normalized relative dir 'Path'.
--
-- Throws: 'PathParseException' when the supplied path:
--
-- * is not a relative path
-- * is any of @""@, @.@ or @..@
-- * contains @..@ anywhere in the path
-- * is not a valid path (See 'System.FilePath.isValid')
--
parseRelDir :: MonadThrow m
=> FilePath -> m (Path Rel Dir) IMHO it makes sense to encode Throws clauses as properties checked with I'm 👍 to the goals of this PR. |
The validity library looks pretty neat now that I see your PR with it. Presumably that instance lets you mess around with generated values while ensuring that the values are correct. I'm a little concerned that you might be underwhelmed with how many tests are needed for the I'm not too concerned about making the test-suite require > ghc-7.0, if needs be. |
The |
You are mixing up
Great! |
I added the first few validity tests. |
I may have screwed up the commit message there: I found a false positive because the validity instance is not strict enough yet. Stil WIP, but would like to hear your thoughts. You may want to view the three commits together instead of seperately. |
The commit looks pretty simple and uninvasive. I like it so far. One question, how does this differ to implementing QuickCheck property-based tests? |
I'm not sure I understand the question. |
Oh, of course. I'm merging into master and I'll try to contribute some more properties too. For example the "parent" function is in need of a breaking change to its type (tracked in another issue) which someone pointed out contradicted a properties purported by the docs, it would be cool to make that triggered in these property tests, and then fix the bug. I'll get to that tomorrow. |
Tomorrow I'd like to make sure that the build matrix is all green, when I'm back at my desk. Seems like it's not at the moment. Thanks Tom! |
@chrisdone Thank you very much for the chance to contribute. |
This
path
library is very scarsely tested. I would like to improve that.There are invariants for the
Path
type.We should:
Path
, can only produce validPath
s.(6.) Optimise the internals to use something better than
String
.This commit just takes the first step by adding a
Validity
instance forPath
s.I would like to hear your thoughts on the matter.
See https://github.com/NorfairKing/safepath for the level of testing I would like to achieve here.