@@ 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"
+ }
+ ]