-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ test, distr ] Add a relative weight distribution test
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/CheckDistribution.idr
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,34 @@ | ||
module CheckDistribution | ||
|
||
import Data.DPair | ||
import Data.SortedBinTree.Gen | ||
|
||
import Deriving.DepTyCheck.Gen | ||
|
||
import DistrCheckCommon | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
-- Check how weights of subtrees are related between left and right subtree of a root | ||
|
||
getLR : (mi ** ma ** SortedBinTree1 mi ma) -> Maybe $ let t = Exists $ Exists . SortedBinTree1 in (t, t) | ||
getLR (_ ** _ ** Leaf {}) = Nothing | ||
getLR (_ ** _ ** Node l r) = Just (Evidence _ $ Evidence _ l, Evidence _ $ Evidence _ r) | ||
|
||
mainFor : (depth : Nat) -> IO () | ||
mainFor depth = printVerdict' getLR (genSortedBinTree1 $ limit depth) $ fromList | ||
$ [ coverWith 1 (\(l, r) => weight l.snd.snd `f` weight r.snd.snd) | ||
| (r, f) <- | ||
[ (ratio 1 2, (>)) | ||
, (ratio 1 10, (==)) | ||
, (ratio 1 2, (<)) | ||
] | ||
] | ||
|
||
main : IO () | ||
main = do | ||
mainFor 2 | ||
mainFor 4 | ||
mainFor 6 |
1 change: 1 addition & 0 deletions
1
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/DistrCheckCommon.idr
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 @@ | ||
../_common/DistrCheckCommon.idr |
3 changes: 3 additions & 0 deletions
3
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/expected
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,3 @@ | ||
Just [ok, ok, ok] | ||
Just [ok, ok, ok] | ||
Just [ok, ok, ok] |
1 change: 1 addition & 0 deletions
1
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/run
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 @@ | ||
../_common/run |
5 changes: 5 additions & 0 deletions
5
examples/sorted-tree-indexed/tests/gens/distribution-relative-weight/test.ipkg
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,5 @@ | ||
package test | ||
|
||
main = CheckDistribution | ||
|
||
depends = deptycheck, sorted-tree-indexed, summary-stat |