summaryrefslogtreecommitdiff
path: root/lib/std/test
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2017-11-07 00:16:11 -0500
committerOri Bernstein <ori@eigenstate.org>2017-11-06 22:12:20 -0800
commit76fc43acecea75b362d7e56557a0466cbda94572 (patch)
tree37c4bf0579feaa1d44f5fd86a1c3490b8215d84c /lib/std/test
parent4e018273cd06542a0605cebd840dbcb8b14ad906 (diff)
downloadmc-76fc43acecea75b362d7e56557a0466cbda94572.tar.gz
Fix use of width uninitialized in graphemestep
This would result in infinite loops in pretty much any caller. Also fix handling of \r, \n, \t, which need to form their own graphemes, but which aren't nicely marked as positive width by cellwidth.
Diffstat (limited to 'lib/std/test')
-rw-r--r--lib/std/test/utf.myr15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/std/test/utf.myr b/lib/std/test/utf.myr
index 8778b05..e4d0f47 100644
--- a/lib/std/test/utf.myr
+++ b/lib/std/test/utf.myr
@@ -30,10 +30,13 @@ const main = {
"wrong width of Cuneiform")
/* graphemestep() */
- var s = "a史cЯx̀̀̀̀̀yz̉"
+ var s = "̀a史c\tЯx̀̀̀̀̀\nz̉"
var sub, rest
(sub, rest) = std.graphemestep(s)
+ std.assert(std.streq(sub, "̀"), "didn't get U+0300 as next grapheme")
+
+ (sub, rest) = std.graphemestep(rest)
std.assert(std.streq(sub, "a"), "didn't get \"a\" as next grapheme")
(sub, rest) = std.graphemestep(rest)
@@ -43,13 +46,16 @@ const main = {
std.assert(std.streq(sub, "c"), "didn't get \"c\" as next grapheme")
(sub, rest) = std.graphemestep(rest)
+ std.assert(std.streq(sub, "\t"), "didn't get \"\\t\" as next grapheme")
+
+ (sub, rest) = std.graphemestep(rest)
std.assert(std.streq(sub, "Я"), "didn't get \"Я\" as next grapheme")
(sub, rest) = std.graphemestep(rest)
std.assert(std.streq(sub, "x̀̀̀̀̀"), "didn't get \"x̀̀̀̀̀\" as next grapheme")
(sub, rest) = std.graphemestep(rest)
- std.assert(std.streq(sub, "y"), "didn't get \"y\" as next grapheme")
+ std.assert(std.streq(sub, "\n"), "didn't get \"\\n\" as next grapheme")
(sub, rest) = std.graphemestep(rest)
std.assert(std.streq(sub, "z̉"), "didn't get \"z̉\" as next grapheme")
@@ -59,9 +65,12 @@ const main = {
/* with excessive combiners */
- s = "c̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝ḧ̵̸̛̥͚̭̣͈͖̼͈͓͓̫͍́̓ͪͫ̋͘͡a̢̩̱̠̘̹̤̯͚̦̰̼̯̲̞͆͂̿ͬ̂͋͒̈ͅͅo̷̷̶̥͖̼̮̳̗͚ͦ̉̆̅̃̍ͤ̆͑ͣ̽́̚s̓̍̍̄͏̖̞̟̱́͡͡͝"
+ s = "\tc̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝ḧ̵̸̛̥͚̭̣͈͖̼͈͓͓̫͍́̓ͪͫ̋͘͡a̢̩̱̠̘̹̤̯͚̦̰̼̯̲̞͆͂̿ͬ̂͋͒̈ͅͅo̷̷̶̥͖̼̮̳̗͚ͦ̉̆̅̃̍ͤ̆͑ͣ̽́̚s̓̍̍̄͏̖̞̟̱́͡͡͝"
(sub, rest) = std.graphemestep(s)
+ std.assert(std.streq(sub, "\t"), "didn't get \"\\t\" as next grapheme")
+
+ (sub, rest) = std.graphemestep(rest)
std.assert(std.streq(sub, "c̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝"), "didn't get \"c̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝\" as next grapheme")
(sub, rest) = std.graphemestep(rest)