aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-05-27 11:46:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-05-27 11:46:47 -0300
commitaa8d4a782d88738b3ea921cde5a450656da8fa63 (patch)
treeecdc874d2476a40ad3857d2c03aaced9d0e04598 /testes
parentefcf24be0c22cba57b298161bf4ab0561fd3c08e (diff)
downloadlua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.gz
lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.bz2
lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.zip
Details (more uniformity in error messages)
Diffstat (limited to 'testes')
-rw-r--r--testes/utf8.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/testes/utf8.lua b/testes/utf8.lua
index 5954f6e8..6010d1ad 100644
--- a/testes/utf8.lua
+++ b/testes/utf8.lua
@@ -115,17 +115,17 @@ do
115end 115end
116 116
117-- error in initial position for offset 117-- error in initial position for offset
118checkerror("position out of range", utf8.offset, "abc", 1, 5) 118checkerror("position out of bounds", utf8.offset, "abc", 1, 5)
119checkerror("position out of range", utf8.offset, "abc", 1, -4) 119checkerror("position out of bounds", utf8.offset, "abc", 1, -4)
120checkerror("position out of range", utf8.offset, "", 1, 2) 120checkerror("position out of bounds", utf8.offset, "", 1, 2)
121checkerror("position out of range", utf8.offset, "", 1, -1) 121checkerror("position out of bounds", utf8.offset, "", 1, -1)
122checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) 122checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
123checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) 123checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
124checkerror("continuation byte", utf8.offset, "\x80", 1) 124checkerror("continuation byte", utf8.offset, "\x80", 1)
125 125
126-- error in indices for len 126-- error in indices for len
127checkerror("out of string", utf8.len, "abc", 0, 2) 127checkerror("out of bounds", utf8.len, "abc", 0, 2)
128checkerror("out of string", utf8.len, "abc", 1, 4) 128checkerror("out of bounds", utf8.len, "abc", 1, 4)
129 129
130 130
131local s = "hello World" 131local s = "hello World"
@@ -140,11 +140,11 @@ do
140 local t = {utf8.codepoint(s,1,#s - 1)} 140 local t = {utf8.codepoint(s,1,#s - 1)}
141 assert(#t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237) 141 assert(#t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237)
142 checkerror("invalid UTF%-8 code", utf8.codepoint, s, 1, #s) 142 checkerror("invalid UTF%-8 code", utf8.codepoint, s, 1, #s)
143 checkerror("out of range", utf8.codepoint, s, #s + 1) 143 checkerror("out of bounds", utf8.codepoint, s, #s + 1)
144 t = {utf8.codepoint(s, 4, 3)} 144 t = {utf8.codepoint(s, 4, 3)}
145 assert(#t == 0) 145 assert(#t == 0)
146 checkerror("out of range", utf8.codepoint, s, -(#s + 1), 1) 146 checkerror("out of bounds", utf8.codepoint, s, -(#s + 1), 1)
147 checkerror("out of range", utf8.codepoint, s, 1, #s + 1) 147 checkerror("out of bounds", utf8.codepoint, s, 1, #s + 1)
148 -- surrogates 148 -- surrogates
149 assert(utf8.codepoint("\u{D7FF}") == 0xD800 - 1) 149 assert(utf8.codepoint("\u{D7FF}") == 0xD800 - 1)
150 assert(utf8.codepoint("\u{E000}") == 0xDFFF + 1) 150 assert(utf8.codepoint("\u{E000}") == 0xDFFF + 1)