-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add Gen module and propery tests #31
Conversation
src/Data/Path/Pathy/Gen.purs
Outdated
import Data.Path.Pathy (AbsPath, AbsFile, AbsDir, RelDir, RelFile, RelPath, Sandboxed, (</>)) | ||
import Data.Path.Pathy as P | ||
|
||
genAbsDirPath :: forall m. MonadGen m => MonadRec m => m String -> m (AbsDir Sandboxed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This staff is moved from ps-quasar
@@ -39,8 +40,37 @@ instance arbitraryArbPath ∷ QC.Arbitrary ArbPath where | |||
pathPart ∷ Gen.Gen String | |||
pathPart = Gen.suchThat QC.arbitrary (not <<< Str.null) | |||
|
|||
parsePrintCheck :: forall a b. Path a b Sandboxed -> Maybe (Path a b Unsandboxed) -> QC.Result | |||
parsePrintCheck input parsed = | |||
if parsed == Just (unsandbox input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this check is not the best, as I got this error at some point:
checking `parse <<< print` for `RelFile``
97/100 test(s) passed.
/Users/safareli/dev/slamdata/purescript-pathy/output/Control.Monad.Eff.Exception/foreign.js:29
throw e;
^
Error: Test 40 (seed 846546249) failed:
`parse (print path) != Just path` for path: `(((((((((currentDir </> dir "냫笼嬋ఱ护") </> dir "ꘓၷ两뱖쌜") </> dir "沌뢑朿ガ茧") </> dir "ﹱ捴ኧ嵹") </> dir "횽") </> dir "⤋") </> dir "큛रꃙ") </> dir "/솛鼒") </> file "냫笼嬋ఱ护")` which was re-parsed into `(Just (((((((((currentDir </> dir "냫笼嬋ఱ护") </> dir "ꘓၷ两뱖쌜") </> dir "沌뢑朿ガ茧") </> dir "ﹱ捴ኧ嵹") </> dir "횽") </> dir "⤋") </> dir "큛रꃙ") </> dir "솛鼒") </> file "냫笼嬋ఱ护"))`
Printed path: "./냫笼嬋ఱ护/ꘓၷ两뱖쌜/沌뢑朿ガ茧/ﹱ捴ኧ嵹/횽/⤋/큛रꃙ/솛鼒/냫笼嬋ఱ护"
Printed path': `(Just "./냫笼嬋ఱ护/ꘓၷ两뱖쌜/沌뢑朿ガ茧/ﹱ捴ኧ嵹/횽/⤋/큛रꃙ/솛鼒/냫笼嬋ఱ护")`
if we move show-ed values side by side difference becomes more clear (scroll to right end)
(((((((((currentDir </> dir "냫笼嬋ఱ护") </> dir "ꘓၷ两뱖쌜") </> dir "沌뢑朿ガ茧") </> dir "ﹱ捴ኧ嵹") </> dir "횽") </> dir "⤋") </> dir "큛रꃙ") </> dir "/솛鼒") </> file "냫笼嬋ఱ护")
(((((((((currentDir </> dir "냫笼嬋ఱ护") </> dir "ꘓၷ两뱖쌜") </> dir "沌뢑朿ガ茧") </> dir "ﹱ捴ኧ嵹") </> dir "횽") </> dir "⤋") </> dir "큛रꃙ") </> dir "솛鼒") </> file "냫笼嬋ఱ护")
The different part:
... </> dir "/솛鼒") </> file "냫笼嬋ఱ护")
... </> dir "솛鼒") </> file "냫笼嬋ఱ护")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used alpha numeric generator in resent amend so this issue is not going to occur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a module that produces alphaNumString
import Data.String.Gen as SG | ||
|
||
genName ∷ ∀ m. MonadGen m ⇒ MonadRec m ⇒ m String | ||
genName = SG.genString $ Gen.oneOf $ CG.genDigitChar :| [CG.genAlpha] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we have no dependency on that.
@cryogenian is this fine to merge? |
Oh, we don't have strongcheck here, weird... |
made 4.1.0 release |
No description provided.