aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2016-01-24 18:54:14 +0100
committerPhilipp Janda <siffiejoe@gmx.net>2016-01-24 18:54:14 +0100
commitaf8c4896960770c0268ac3281d0622a0c0694dc5 (patch)
treecc84353e67ef11fd2ae0d83a5467b3ee5e9a8604 /tests
parentca85188590e677edcc9290d29e69a3692187c826 (diff)
downloadlua-compat-5.3-af8c4896960770c0268ac3281d0622a0c0694dc5.tar.gz
lua-compat-5.3-af8c4896960770c0268ac3281d0622a0c0694dc5.tar.bz2
lua-compat-5.3-af8c4896960770c0268ac3281d0622a0c0694dc5.zip
Add tests for utf8 backport.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 0c77240..f2094b9 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -248,6 +248,48 @@ print("math.ult", pcall(math.ult, 1, 2.1))
248___'' 248___''
249 249
250 250
251if utf8.len then
252 local unpack = table.unpack or unpack
253 local function utf8rt(s)
254 local t = { utf8.codepoint(s, 1, #s) }
255 local ps, cs = {}, {}
256 for p,c in utf8.codes(s) do
257 ps[#ps+1], cs[#cs+1] = p, c
258 end
259 print("utf8.codes", unpack(ps))
260 print("utf8.codes", unpack(cs))
261 print("utf8.codepoint", unpack(t))
262 print("utf8.len", utf8.len(s), #t, #s)
263 print("utf8.char", utf8.char(unpack(t)))
264 end
265 utf8rt("äöüßÄÖÜ")
266 utf8rt("abcdefg")
267 ___''
268 local s = "äöüßÄÖÜ"
269 print("utf8.offset", utf8.offset(s, 1, 1))
270 print("utf8.offset", utf8.offset(s, 2, 1))
271 print("utf8.offset", utf8.offset(s, 3, 1))
272 print("utf8.offset", pcall(utf8.offset, s, 3, 2))
273 print("utf8.offset", utf8.offset(s, 3, 3))
274 print("utf8.offset", utf8.offset(s, -1, 7))
275 print("utf8.offset", utf8.offset(s, -2, 7))
276 print("utf8.offset", utf8.offset(s, -3, 7))
277 print("utf8.offset", utf8.offset(s, -1))
278 ___''
279else
280 print("XXX: utf8 module not available")
281end
282
283
284if string.pack then
285 -- TODO
286 print("TODO: test string packing/unpacking")
287 ___''
288else
289 print("XXX: string packing not available")
290end
291
292
251print("testing Lua API for Lua 5.1 ...") 293print("testing Lua API for Lua 5.1 ...")
252 294
253___'' 295___''