Lines effect

This commit is contained in:
Nathan McCarty 2025-02-23 21:34:10 -05:00
parent db0f3a0427
commit bd94410c01
13 changed files with 146 additions and 27 deletions

View file

@ -4,5 +4,5 @@ import Test.Golden.RunnerHelper
main : IO ()
main = goldenRunner
[ "Djot -> HTML Golden Values" `atDir` "djot-to-html"
[ "Hedgehog Tests" `atDir` "hedgehog"
]

View file

@ -1,16 +0,0 @@
module Main
import SSG.Djot
import SSG.HTML
import System
import System.File
main : IO ()
main = do
Right contents <- readFile "test.dj"
| Left err => do
printLn err
exitFailure
let parsed = djot contents
putStr . render . renderHtml $ parsed

View file

@ -1,6 +0,0 @@
<!DOCTYPE HTML>
<html lang=en>
<body>
<p>Hello World!</p>
</body>
</html>

View file

@ -1 +0,0 @@
Hello World!

View file

@ -0,0 +1,28 @@
module Main
import SSG.Djot.Lines
import Control.Eff
import Data.String
import Hedgehog
lines' : Eff [Lines] (List String)
lines' = do
Just next <- take
| _ => pure []
map (next ::) lines'
propLinesEquiv : Property
propLinesEquiv = property $ do
str <- forAll $ string (linear 0 256) ascii
let std_lines = lines str
let (our_lines, rest) = extract $ runLines str lines'
our_lines === std_lines
main : IO ()
main = test $
[ MkGroup
"Lines effect"
[ ("Lines effect equivalent to lines", propLinesEquiv)
]
]

View file

@ -0,0 +1,3 @@
━━━ Lines effect ━━━
✓ Lines effect equivalent to lines passed 1000 tests.
✓ 1 succeeded.

View file

@ -0,0 +1,5 @@
[custom.all.SSG]
type = "local"
path = "../../.."
ipkg = "SSG.ipkg"
test = "test/test.ipkg"

View file

@ -1,6 +1,6 @@
rm -rf build/
flock "$1" pack -q install-deps test.ipkg
pack -q run test.ipkg
HEDGEHOG_COLOR=0 pack -q run test.ipkg -n 1000
rm -rf build/

View file

@ -1,6 +1,8 @@
package a-test
depends = SSG
, hedgehog
, eff
main = Main