-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
320 additions
and
328 deletions.
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
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 | ||
|
||
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.