~jaro/balkon

ref: a1a78d251a8e2f67c0e26815b73dfc774ed3a848 balkon/test/Data/Text/ParagraphLayout/Internal/RunSpec.hs -rw-r--r-- 1.6 KiB
a1a78d25Jaro Allow custom font options outside FontLoader. 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Data.Text.ParagraphLayout.Internal.RunSpec (spec) where

import Data.Text (pack)
import Data.Text.Glyphize (Direction(..), emptyFont)

import Test.Hspec
import Data.Text.ParagraphLayout.Internal.ResolvedSpan
import Data.Text.ParagraphLayout.Internal.Run
import Data.Text.ParagraphLayout.SpanData

spec :: Spec
spec = do
    describe "spanToRuns" $ do
        it "handles span with no text" $ do
            spanToRuns (emptySpan emptyFont) `shouldBe` []
        it "handles Czech hello" $ do
            let inputSpan = czechHello emptyFont
            let runs = spanToRuns inputSpan
            runs `shouldBe`
                [ Run
                    { runOffsetInSpan = 0
                    , runText = spanText inputSpan
                    , runDirection = Just DirLTR
                    , runScript = Just "Latn"
                    }
                ]
        it "handles Serbian with mixed script" $ do
            let inputSpan = serbianMixedScript emptyFont
            let runs = spanToRuns inputSpan
            runs `shouldBe`
                [ Run
                    -- TODO: We might want both parentheses in the same run.
                    { runOffsetInSpan = 0
                    , runText = pack "Vikipedija ("
                    , runDirection = Just DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 12
                    , runText = pack "Википедија)"
                    , runDirection = Just DirLTR
                    , runScript = Just "Cyrl"
                    }
                ]