-
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.
[ mcov ] Support the colouring of the resulting printed model coverage
- Loading branch information
Showing
5 changed files
with
123 additions
and
11 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,50 @@ | ||
module PrintCoverage | ||
|
||
import Test.DepTyCheck.Gen | ||
import Test.DepTyCheck.Gen.Coverage | ||
|
||
import Deriving.DepTyCheck.Gen | ||
|
||
import System.Random.Pure.StdGen | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
export | ||
smallStrs : Fuel -> Gen NonEmpty String | ||
smallStrs _ = elements ["", "a", "bc"] | ||
|
||
data X = X1 | X2 Nat | X3 String | ||
|
||
genX : Fuel -> Gen NonEmpty X | ||
genX fl = withCoverage $ oneOf | ||
[ pure X1 | ||
, X3 <$> smallStrs fl | ||
] | ||
|
||
data Y : Nat -> Type where | ||
Y1 : Y 0 | ||
Y2 : X -> Y 1 | ||
Y3 : X -> X -> Y n | ||
|
||
genY : Fuel -> (n : _) -> Gen NonEmpty $ Y n | ||
genY fl Z = withCoverage $ oneOf | ||
[ [| Y1 |] | ||
, [| Y3 (genX fl) (genX fl) |] | ||
] | ||
genY fl 1 = withCoverage [| Y2 (genX fl) |] | ||
genY fl n = withCoverage [| Y3 (genX fl) (genX fl) |] | ||
|
||
main : IO () | ||
main = do | ||
let ci = initCoverageInfo genY | ||
do let vs = unGenTryND 100 someStdGen $ genY (limit 10) 0 | ||
let mc = concatMap fst vs | ||
let ci = registerCoverage mc ci | ||
putStrLn $ show @{Colourful} ci | ||
putStrLn "\n--------\n" | ||
do let vs = unGenTryND 100 someStdGen $ genY (limit 10) 3 | ||
let mc = concatMap fst vs | ||
let ci = registerCoverage mc ci | ||
putStrLn $ show @{Colourful} ci |
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,31 @@ | ||
1/1: Building PrintCoverage (PrintCoverage.idr) | ||
|
||
Prelude.Types.[1mNat[0m [38;5;9mnot covered[0m | ||
- S: [38;5;9mnot covered[0m | ||
- Z: [38;5;9mnot covered[0m | ||
|
||
PrintCoverage.[1mX[0m [38;5;11mcovered partially[0m | ||
- X1: [38;5;10mcovered[0m | ||
- X2: [38;5;9mnot covered[0m | ||
- X3: [38;5;10mcovered[0m | ||
|
||
PrintCoverage.[1mY[0m [38;5;11mcovered partially[0m | ||
- Y1: [38;5;10mcovered[0m | ||
- Y2: [38;5;9mnot covered[0m | ||
- Y3: [38;5;10mcovered[0m | ||
|
||
-------- | ||
|
||
Prelude.Types.[1mNat[0m [38;5;9mnot covered[0m | ||
- S: [38;5;9mnot covered[0m | ||
- Z: [38;5;9mnot covered[0m | ||
|
||
PrintCoverage.[1mX[0m [38;5;11mcovered partially[0m | ||
- X1: [38;5;10mcovered[0m | ||
- X2: [38;5;9mnot covered[0m | ||
- X3: [38;5;10mcovered[0m | ||
|
||
PrintCoverage.[1mY[0m [38;5;11mcovered partially[0m | ||
- Y1: [38;5;9mnot covered[0m | ||
- Y2: [38;5;9mnot covered[0m | ||
- Y3: [38;5;10mcovered[0m |
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,8 @@ | ||
rm -rf build | ||
|
||
flock "$1" pack -q install-deps test.ipkg && \ | ||
idris2 --no-color --console-width 0 --no-banner --find-ipkg --check PrintCoverage.idr && \ | ||
echo && \ | ||
pack exec PrintCoverage.idr | ||
|
||
rm -rf build |
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,6 @@ | ||
package a-test | ||
executable = a-test | ||
|
||
depends = deptycheck | ||
|
||
main = PrintCoverage |