From b9e2a941c9ef51725eac029e46453373db7b980a Mon Sep 17 00:00:00 2001 From: Jaro Date: Mon, 22 May 2023 05:07:11 +0200 Subject: [PATCH] Add more sample texts. --- .../Text/ParagraphLayout/Internal/RunSpec.hs | 29 ++++++++++++++ test/Data/Text/ParagraphLayout/TextData.hs | 40 +++++++++++++++---- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/test/Data/Text/ParagraphLayout/Internal/RunSpec.hs b/test/Data/Text/ParagraphLayout/Internal/RunSpec.hs index dbb0ba0..6305767 100644 --- a/test/Data/Text/ParagraphLayout/Internal/RunSpec.hs +++ b/test/Data/Text/ParagraphLayout/Internal/RunSpec.hs @@ -78,6 +78,35 @@ spec = do , runScript = Just "Cyrl" } ] + it "handles Arabic text with English inside" $ do + let inputSpan = sampleSpan arabicAroundEnglish + let runs = spanToRuns inputSpan + runs `shouldBe` + [ Run + { runOffsetInSpan = 0 + , runText = pack "في " + , runDirection = Just DirRTL + , runScript = Just "Arab" + } + , Run + { runOffsetInSpan = 5 + , runText = pack "XHTML 1.0 " + , runDirection = Just DirLTR + , runScript = Just "Latn" + } + , Run + { runOffsetInSpan = 15 + , runText = pack "يتم تحقيق ذلك بإضافة العنصر المضمن " + , runDirection = Just DirRTL + , runScript = Just "Arab" + } + , Run + { runOffsetInSpan = 79 + , runText = pack "bdo." + , runDirection = Just DirLTR + , runScript = Just "Latn" + } + ] it "handles English text with Arabic inside" $ do let inputSpan = sampleSpan englishAroundArabic let runs = spanToRuns inputSpan diff --git a/test/Data/Text/ParagraphLayout/TextData.hs b/test/Data/Text/ParagraphLayout/TextData.hs index 5f96921..6bff6cc 100644 --- a/test/Data/Text/ParagraphLayout/TextData.hs +++ b/test/Data/Text/ParagraphLayout/TextData.hs @@ -1,8 +1,11 @@ module Data.Text.ParagraphLayout.TextData - ( englishEmpty - , czechHello + ( arabicEmpty + , englishEmpty + , englishWord , arabicHello + , czechHello , serbianMixedScript + , arabicAroundEnglish , englishAroundArabic ) where @@ -13,6 +16,13 @@ import Data.Text.Glyphize (Direction (DirLTR, DirRTL)) type Language = String type Sample = (Direction, Language, Text) +arabicEmpty :: Sample +arabicEmpty = + ( DirRTL + , "ar" + , empty + ) + englishEmpty :: Sample englishEmpty = ( DirLTR @@ -20,11 +30,11 @@ englishEmpty = , empty ) -czechHello :: Sample -czechHello = - ( DirLTR - , "cs" - , pack "Ahoj, světe!" +englishWord :: Sample +englishWord = + ( DirRTL + , "en" + , pack "word" ) arabicHello :: Sample @@ -34,6 +44,13 @@ arabicHello = , pack "سلام" ) +czechHello :: Sample +czechHello = + ( DirLTR + , "cs" + , pack "Ahoj, světe!" + ) + serbianMixedScript :: Sample serbianMixedScript = ( DirLTR @@ -41,6 +58,15 @@ serbianMixedScript = , pack "Vikipedija (Википедија)" ) +-- | Source: +-- +arabicAroundEnglish :: Sample +arabicAroundEnglish = + ( DirRTL + , "ar" + , pack "في XHTML 1.0 يتم تحقيق ذلك بإضافة العنصر المضمن bdo." + ) + -- | Source: -- englishAroundArabic :: Sample -- 2.30.2