Files
gyehoek-hs/test/Gyehoek/Test/Sexp/Print.hs
T
msyds 61c4e428bd
build / build (push) Successful in 1m24s
print begin
2026-08-21 16:13:22 -06:00

47 lines
1.3 KiB
Haskell

module Gyehoek.Test.Sexp.Print where
import Test.Tasty (TestTree, testGroup, TestName)
import Test.Tasty.HUnit
import Gyehoek.Prelude
import Gyehoek.Sexp.Syntax qualified as S
import Gyehoek.Sexp.Print qualified as Sut
import System.FilePath ((</>))
import Test.Tasty.Silver
tcase = tcaseW 80
tcaseW :: Int -> TestName -> S.Datum -> TestTree
tcaseW width name ast =
goldenVsAction
name
("golden/print" </> name)
(pure $ Sut.printDatumW width ast)
id
thinWide name x = testGroup name
[ tcase (name <> "-wide") x
, tcaseW 4 (name <> "-thin") x
]
test_print = testGroup "sexp pretty printer" $
[ tcase "null" $ S.List []
, thinWide "simple-list" $
S.List [ S.Symbol s | s <- ["가","나","다","라"] ]
, thinWide "begin-nonempty" $
S.indentWith (S.NSpecial 0) $
S.List [ S.adorn S.SynBuiltin $ S.Symbol "begin"
, S.Symbol "책을"
, S.Symbol "더"
, S.Symbol "먹으세요~!"
]
, thinWide "lambda-nonempty" $
S.indentWith (S.NSpecial 1) $
S.List [ S.adorn S.SynBuiltin $ S.Symbol "lambda"
, S.List [S.Symbol "어간", S.Symbol "어미"]
, S.List [S.Symbol "display", S.Symbol "꾸깃"]
]
, tcase "rainbow" $
S.List [S.List [S.List [S.List [S.List []]]]]
]