unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/case_mapping_context_test.mbt
1///|2test "lowercase: final sigma uses the original string context" {3  inspect(@ucd.lowercase("Σ"), content="σ")4  inspect(@ucd.lowercase("ΟΣ"), content="ος")5  inspect(@ucd.lowercase("ΟΣΑ"), content="οσα")6  inspect(@ucd.lowercase("ΣΣ"), content="σς")7  inspect(@ucd.lowercase("ΣΣΣ"), content="σσς")8  inspect(@ucd.lowercase("ΟΔΥΣΣΕΥΣ"), content="οδυσσευς")9  inspect(@ucd.lowercase("İΣ"), content="i\u{0307}ς")10  // Existing lowercase sigma forms are preserved, not reselected.11  inspect(@ucd.lowercase("ΟΣ σς"), content="ος σς")12  inspect(@ucd.to_lowercase('Σ'), content="σ")13  inspect(@ucd.to_simple_lowercase('Σ'), content="σ")14}1516///|17test "lowercase: uncased characters stop the final sigma context" {18  inspect(@ucd.lowercase("AΣ"), content="aς")19  inspect(@ucd.lowercase("中Σ"), content="中σ")20  inspect(@ucd.lowercase("1Σ"), content="1σ")21  inspect(@ucd.lowercase("A Σ"), content="a σ")22  inspect(@ucd.lowercase("AΣ中A"), content="aς中a")23  inspect(@ucd.lowercase("AΣ1A"), content="aς1a")24  inspect(@ucd.lowercase("AΣ A"), content="aς a")25  // Cased includes Other_Lowercase and Other_Uppercase, not just Lu/Ll/Lt.26  inspect(@ucd.lowercase("ªΣ"), content="ªς")27  inspect(@ucd.lowercase("ⅠΣ"), content="ⅰς")28}2930///|31test "lowercase: final sigma skips case-ignorable characters" {32  inspect(@ucd.lowercase("A\u{0301}Σ"), content="a\u{0301}ς")33  inspect(@ucd.lowercase("AΣ\u{0301}"), content="aς\u{0301}")34  inspect(@ucd.lowercase("AΣ\u{0301}A"), content="aσ\u{0301}a")35  inspect(@ucd.lowercase("A\u{200D}Σ"), content="a\u{200D}ς")36  inspect(@ucd.lowercase("AΣ\u{200D}"), content="aς\u{200D}")37  inspect(@ucd.lowercase("AΣ\u{200D}A"), content="aσ\u{200D}a")38  inspect(@ucd.lowercase("A'Σ"), content="a'ς")39  inspect(@ucd.lowercase("AΣ'A"), content="aσ'a")40  inspect(@ucd.lowercase("'Σ"), content="'σ")41}4243///|44test "lowercase: case-ignorable takes precedence over cased" {45  // U+0345 is both Cased and Case_Ignorable. Unicode's context patterns46  // consume Case_Ignorable possessively, so it cannot supply the cased letter.47  inspect(@ucd.lowercase("\u{0345}Σ"), content="\u{0345}σ")48  inspect(@ucd.lowercase("A\u{0345}Σ"), content="a\u{0345}ς")49  inspect(@ucd.lowercase("AΣ\u{0345}"), content="aς\u{0345}")50  inspect(@ucd.lowercase("AΣ\u{0345}A"), content="aσ\u{0345}a")51  inspect(@ucd.lowercase("\u{0345}Σ\u{0345}"), content="\u{0345}σ\u{0345}")52  inspect(@ucd.lowercase("Σ\u{0345}Σ"), content="σ\u{0345}ς")53}5455///|56test "lowercase: supplementary characters participate in sigma context" {57  // Deseret letters are cased; the musical combining doit is case-ignorable.58  inspect(@ucd.lowercase("\u{10400}Σ"), content="\u{10428}ς")59  inspect(@ucd.lowercase("AΣ\u{10400}"), content="aσ\u{10428}")60  inspect(@ucd.lowercase("A\u{1D185}Σ"), content="a\u{1D185}ς")61  inspect(@ucd.lowercase("AΣ\u{1D185}A"), content="aσ\u{1D185}a")62  // Variation selector 17 exercises case-ignorable data in plane 14.63  inspect(@ucd.lowercase("A\u{E0100}Σ"), content="a\u{E0100}ς")64  inspect(@ucd.lowercase("AΣ\u{E0100}"), content="aς\u{E0100}")65  inspect(@ucd.lowercase("AΣ\u{E0100}A"), content="aσ\u{E0100}a")66  inspect(@ucd.lowercase("\u{E0100}Σ"), content="\u{E0100}σ")67}6869///|70test "lowercase: sigma context stops at StringView boundaries" {71  inspect(@ucd.lowercase("ΑΣΑ"[1:2]), content="σ")72  inspect(@ucd.lowercase("ΑΣΑ"[:2]), content="ας")73  inspect(@ucd.lowercase("ΑΣΑ"[1:]), content="σα")74  inspect(@ucd.lowercase("😀ΟΣ😀"[2:4]), content="ος")75  inspect(@ucd.lowercase("A\u{0345}Σ"[1:]), content="\u{0345}σ")76  inspect(@ucd.lowercase("AΣ\u{0345}A"[:3]), content="aς\u{0345}")77}7879///|80test "lowercase: unpaired surrogates are preserved and stop sigma context" {81  let leading = (0xD800).unsafe_to_char()82  let trailing = (0xDC00).unsafe_to_char()83  let first = String::from_array(['A', leading, 'Σ', 'A', 'Σ', trailing, 'A'])84  debug_inspect(85    @ucd.lowercase(first).code_units().iter().map(c => c.to_int()).collect(),86    content="[97, 55296, 963, 97, 962, 56320, 97]",87  )88  let second = String::from_array(['A', trailing, 'Σ', 'A', 'Σ', leading, 'A'])89  debug_inspect(90    @ucd.lowercase(second).code_units().iter().map(c => c.to_int()).collect(),91    content="[97, 56320, 963, 97, 962, 55296, 97]",92  )93}9495///|96test "lowercase: split surrogate pairs do not extend the view's context" {97  // The trailing surrogate in the view must not combine with the leading98  // surrogate outside it to become a cased Deseret letter.99  let prefix = "\u{10400}Σ".unsafe_view(start=1, end=3)100  debug_inspect(101    @ucd.lowercase(prefix).code_units().iter().map(c => c.to_int()).collect(),102    content="[56320, 963]",103  )104  let suffix = "AΣ\u{10400}".unsafe_view(start=0, end=3)105  debug_inspect(106    @ucd.lowercase(suffix).code_units().iter().map(c => c.to_int()).collect(),107    content="[97, 962, 55297]",108  )109}110