-
-
Save samcv/c39b3c916525e390e74c6ad050f887a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test; | |
sub test-it (:$text, :@chars-to-test, :@graphs, :@cps) { | |
#my $text = "join+comb"; | |
#my @chars-to-test = ("a", "π¦", "π§", "π¨", "π©", "b").join.comb; | |
#my @graphs = "a", "π¦π§", "π¨π©", "b"; | |
#my @cps = (("a",), ("π¦", "π§"), ("π¨","π©"), ("b",)).deepmap(*.ord); | |
is-deeply @chars-to-test, @graphs, "Graphemes compare correct in initial test of $text"; | |
for ^@graphs -> $i { | |
is-deeply @graphs[$i].ords, @cps[$i], "Codepoints in isolated grapheme $i are correct"; | |
} | |
for ^@chars-to-test -> $i { | |
is-deeply @chars-to-test[$i].ords, @cps[$i], "Codepoints in grapheme $i created from $text is correct"; | |
is-deeply @chars-to-test[$i].chars, 1, "Number of graphemes in grapheme $i created from $text is correct"; | |
} | |
} | |
test-it( | |
:text("join+comb"), | |
:chars-to-test(("a", "π¦", "π§", "π¨", "π©", "b").join.comb), | |
:graphs:("a", "π¦π§", "π¨π©", "b"), | |
:cps((("a",), ("π¦", "π§"), ("π¨","π©"), ("b",)).deepmap(*.ord)) | |
); | |
{ | |
my $text = "join+comb"; | |
my @chars-to-test = ("a", "π¦", "π§", "π¨", "π©", "b").join.comb; | |
my @graphs = "a", "π¦π§", "π¨π©", "b"; | |
my @cps = (("a",), ("π¦", "π§"), ("π¨","π©"), ("b",)).deepmap(*.ord); | |
is-deeply @chars-to-test, @graphs, "Graphemes seem correct"; | |
for ^@graphs -> $i { | |
is-deeply @graphs[$i].ords, @cps[$i], "Codepoints in isolated grapheme $i are correct"; | |
} | |
for ^@chars-to-test -> $i { | |
is-deeply @chars-to-test[$i].ords, @cps[$i], "Codepoints in grapheme $i created from $text is correct"; | |
is-deeply @chars-to-test[$i].chars, 1, "Number of graphemes in grapheme $i created from $text is correct"; | |
} | |
} | |
{ | |
my Str:D $concat = "π¦π§" ~ "π¨π©"; | |
my $text = "concat+comb"; | |
my @chars-to-test = $concat.comb; | |
my @graphs = "π¦π§", "π¨π©"; | |
my @cps = ( ("π¦","π§"), ("π¨", "π©") ).deepmap(*.ord); | |
is-deeply $concat.chars, 2, "Correct number of chars from concat of two Regional Indicators"; | |
for ^@graphs -> $i { | |
is-deeply @graphs[$i].ords, @cps[$i], "Codepoints in isolated grapheme $i are correct"; | |
} | |
for ^@chars-to-test -> $i { | |
is-deeply @chars-to-test[$i].ords, @cps[$i], "Codepoints in grapheme $i created from $text is correct"; | |
is-deeply @chars-to-test[$i].chars, 1, "Number of graphemes in grapheme $i created from $text is correct"; | |
} | |
} | |
is-deeply ("π¦π§" ~ "π¨").comb, ("π¦π§", "π¨").Seq; | |
is-deeply ("π¦π§π¨" ~ "π©").comb, ("π¦π§", "π¨π©").Seq; | |
done-testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment