-
Notifications
You must be signed in to change notification settings - Fork 12
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
Convert to use hedgehog and hspec #25
Closed
newhoggy
wants to merge
3
commits into
sebastian-philipp:master
from
haskell-works:convert-to-hedgehog
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build", | ||
"type": "shell", | ||
"command": "bash", | ||
"args": ["-lc", "cabal v2-build --enable-tests && echo 'Done'"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": { | ||
"owner": "haskell", | ||
"fileLocation": "relative", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):.*$", | ||
"file": 1, "line": 2, "column": 3, "severity": 4 | ||
}, | ||
{ | ||
"regexp": "\\s*(.*)$", | ||
"message": 1 | ||
} | ||
] | ||
}, | ||
"presentation": { | ||
"echo": false, | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "Test", | ||
"type": "shell", | ||
"command": "bash", | ||
"args": ["-lc", "cabal v2-test --enable-tests --write-ghc-environment-files=ghc8.4.4+ --test-show-details=direct && echo 'Done'"], | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": { | ||
"owner": "haskell", | ||
"fileLocation": "relative", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+?):(\\d+):(\\d+):.*$", | ||
"file": 1, "line": 2, "column": 3, "severity": 4 | ||
}, | ||
{ | ||
"regexp": "\\s*(\\d\\)\\s)?(.*)$", | ||
"message": 2 | ||
} | ||
] | ||
}, | ||
"presentation": { | ||
"echo": false, | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "shared", | ||
"showReuseMessage": false, | ||
"clear": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module Gen | ||
( mbb | ||
, rtreeInt | ||
) where | ||
|
||
import Control.Applicative ((<$>)) | ||
import Data.RTree.Base | ||
import Data.RTree.MBB hiding (mbb) | ||
import Hedgehog | ||
import Prelude hiding (length, lookup, map, null) | ||
import Text.Show.Functions () | ||
|
||
import qualified Hedgehog.Gen as G | ||
import qualified Hedgehog.Range as R | ||
|
||
mbb :: MonadGen m => m MBB | ||
mbb = G.shrink more $ do | ||
cx <- G.double (R.linearFrac (-100000.0) 100000.0) | ||
cy <- G.double (R.linearFrac (-100000.0) 100000.0) | ||
h <- G.double (R.linearFrac 0.0 100000.0) | ||
w <- G.double (R.linearFrac 0.0 100000.0) | ||
return $ MBB (cx - w) (cy - h) (cx + w) (cy + h) | ||
where more :: MBB -> [MBB] | ||
more mbb'@(MBB ulx uly brx bry) | ||
| isPointMBB mbb' = [] | ||
| otherwise = [MBB (mid ulx brx) (mid uly bry) (mid ulx brx) (mid uly bry)] | ||
mid x y = (y - x) / 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One benefit of |
||
|
||
rtreeInt :: MonadGen m => m (RTree Int) | ||
rtreeInt = G.shrink more $ do | ||
ks <- G.list (R.linear 0 100) mbb | ||
return $ fromList (ks `zip` [1..]) | ||
where more :: RTree Int -> [RTree Int] | ||
more Empty = [] | ||
more Leaf{} = [Empty] | ||
more t = | ||
[Empty] ++ | ||
-- shrink to subterms | ||
getChildren t ++ | ||
-- recursively shrink subterms | ||
[createNodeWithChildren newChildred | newChildred <- more <$> getChildren t] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there a tool you're using to format the code?
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'm set up to use
stylish-haskell
with Visual Studio Code.Currently using these rules: