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

Add Gen module and propery tests #31

Merged
merged 1 commit into from
Dec 21, 2017
Merged

Conversation

safareli
Copy link
Contributor

No description provided.

@safareli safareli requested a review from garyb December 20, 2017 15:07
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)
Copy link
Contributor Author

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)
Copy link
Contributor Author

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 "냫笼嬋ఱ护⿼")

Copy link
Contributor Author

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

Copy link
Member

@cryogenian cryogenian left a 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]
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

@safareli
Copy link
Contributor Author

@cryogenian is this fine to merge?

@cryogenian
Copy link
Member

Oh, we don't have strongcheck here, weird...
Yeah, it's good to go 👍

@safareli safareli merged commit e8f5581 into purescript-contrib:master Dec 21, 2017
@safareli safareli deleted the gen branch December 21, 2017 13:02
@safareli
Copy link
Contributor Author

made 4.1.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants