M balkon.cabal => balkon.cabal +1 -0
@@ 172,6 172,7 @@ test-suite balkon-test
Data.Text.ParagraphLayout.Internal.ZipperSpec,
Data.Text.ParagraphLayout.ParagraphData,
Data.Text.ParagraphLayout.PrettyShow,
+ Data.Text.ParagraphLayout.PrettyShow.Golden,
Data.Text.ParagraphLayout.RectSpec,
Data.Text.ParagraphLayout.SpanData
A test/Data/Text/ParagraphLayout/PrettyShow/Golden.hs => test/Data/Text/ParagraphLayout/PrettyShow/Golden.hs +32 -0
@@ 0,0 1,32 @@
+module Data.Text.ParagraphLayout.PrettyShow.Golden
+ ( goldenTest
+ , goldenPath
+ , actualPath
+ , fontInfoPath
+ )
+where
+
+import Test.Hspec.Golden
+import System.FilePath ((<.>), (</>))
+import Data.Text.ParagraphLayout.PrettyShow
+
+goldenPath :: FilePath -> String -> FilePath
+goldenPath dir name = dir </> name <.> "golden"
+
+actualPath :: FilePath -> String -> FilePath
+actualPath dir name = dir </> name <.> "actual"
+
+fontInfoPath :: FilePath -> String -> FilePath
+fontInfoPath dir name = dir </> name <.> "fontInfo"
+
+goldenTest :: (PrettyShow a, Show inner, Read inner) =>
+ FilePath -> (a -> inner) -> (inner -> a) -> inner -> FilePath -> Golden a
+goldenTest goldenDir unwrap wrap innerOutput name = Golden
+ { output = wrap innerOutput
+ , encodePretty = show . unwrap
+ , writeToFile = \ path -> writeFile path . prettyShow
+ , readFromFile = \ path -> readFile path >>= return . wrap . read
+ , goldenFile = goldenPath goldenDir name
+ , actualFile = Just (actualPath goldenDir name)
+ , failFirstTime = True
+ }
M test/Data/Text/ParagraphLayoutSpec.hs => test/Data/Text/ParagraphLayoutSpec.hs +2 -23
@@ 1,38 1,17 @@
module Data.Text.ParagraphLayoutSpec (spec) where
import Test.Hspec
-import Test.Hspec.Golden
-import System.FilePath ((<.>), (</>))
+import System.FilePath ((</>))
import Data.Text.ParagraphLayout
import Data.Text.ParagraphLayout.FontLoader
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
import Data.Text.ParagraphLayout.ParagraphData
import Data.Text.ParagraphLayout.PrettyShow
+import Data.Text.ParagraphLayout.PrettyShow.Golden
import Data.Text.ParagraphLayout.Rect
type Page = (PageContinuity, ParagraphLayout)
-goldenPath :: FilePath -> String -> FilePath
-goldenPath dir name = dir </> name <.> "golden"
-
-actualPath :: FilePath -> String -> FilePath
-actualPath dir name = dir </> name <.> "actual"
-
-fontInfoPath :: FilePath -> String -> FilePath
-fontInfoPath dir name = dir </> name <.> "fontInfo"
-
-goldenTest :: (PrettyShow a, Show inner, Read inner) =>
- FilePath -> (a -> inner) -> (inner -> a) -> inner -> FilePath -> Golden a
-goldenTest goldenDir unwrap wrap innerOutput name = Golden
- { output = wrap innerOutput
- , encodePretty = show . unwrap
- , writeToFile = \ path -> writeFile path . prettyShow
- , readFromFile = \ path -> readFile path >>= return . wrap . read
- , goldenFile = goldenPath goldenDir name
- , actualFile = Just (actualPath goldenDir name)
- , failFirstTime = True
- }
-
emptyLayout :: ParagraphLayout
emptyLayout = ParagraphLayout (Rect 0 0 0 0) []