~jaro/balkon

0b2a78cbf854bd0ef02be2ee5cd1aa65315eab1a — Jaro 1 year, 5 months ago 42d205e
Test spanToRuns independently for scripts/directions.
1 files changed, 55 insertions(+), 0 deletions(-)

M test/Data/Text/ParagraphLayout/Internal/RunSpec.hs
M test/Data/Text/ParagraphLayout/Internal/RunSpec.hs => test/Data/Text/ParagraphLayout/Internal/RunSpec.hs +55 -0
@@ 162,3 162,58 @@ spec = do
                    , runScript = Just "Latn"
                    }
                ]
        -- Unrealistic example where text changes direction
        -- without changing script.
        it "handles script and direction changes" $ do
            let levels = levelsRLE [(4, 1), (4, 2), (8, 1), (4, 2), (3, 1)]
            let inputSpan = sampleSpan serbianMixedScript levels
            let runs = spanToRuns inputSpan
            runs `shouldBe`
                [ Run
                    { runOffsetInSpan = 0
                    , runText = pack "Viki"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runScript = Just "Latn"
                    }
                -- direction change
                , Run
                    { runOffsetInSpan = 4
                    , runText = pack "pedi"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runScript = Just "Latn"
                    }
                -- direction change
                , Run
                    { runOffsetInSpan = 8
                    , runText = pack "ja ("
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runScript = Just "Latn"
                    }
                -- script change
                , Run
                    { runOffsetInSpan = 12
                    , runText = pack "Вики"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runScript = Just "Cyrl"
                    }
                -- direction change
                , Run
                    { runOffsetInSpan = 20
                    , runText = pack "педи"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runScript = Just "Cyrl"
                    }
                -- direction change
                , Run
                    { runOffsetInSpan = 28
                    , runText = pack "ја)"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runScript = Just "Cyrl"
                    }
                ]