aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/pm.lua29
-rw-r--r--testes/strings.lua5
-rw-r--r--testes/tpack.lua2
3 files changed, 34 insertions, 2 deletions
diff --git a/testes/pm.lua b/testes/pm.lua
index 1afaccf6..8cc8772e 100644
--- a/testes/pm.lua
+++ b/testes/pm.lua
@@ -297,6 +297,35 @@ for k,v in pairs(t) do assert(k+1 == v+0); a=a+1 end
297assert(a == 3) 297assert(a == 3)
298 298
299 299
300do -- init parameter in gmatch
301 local s = 0
302 for k in string.gmatch("10 20 30", "%d+", 3) do
303 s = s + tonumber(k)
304 end
305 assert(s == 50)
306
307 s = 0
308 for k in string.gmatch("11 21 31", "%d+", -4) do
309 s = s + tonumber(k)
310 end
311 assert(s == 32)
312
313 -- there is an empty string at the end of the subject
314 s = 0
315 for k in string.gmatch("11 21 31", "%w*", 9) do
316 s = s + 1
317 end
318 assert(s == 1)
319
320 -- there are no empty strings after the end of the subject
321 s = 0
322 for k in string.gmatch("11 21 31", "%w*", 10) do
323 s = s + 1
324 end
325 assert(s == 0)
326end
327
328
300-- tests for `%f' (`frontiers') 329-- tests for `%f' (`frontiers')
301 330
302assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") 331assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x")
diff --git a/testes/strings.lua b/testes/strings.lua
index 587a0e06..88480924 100644
--- a/testes/strings.lua
+++ b/testes/strings.lua
@@ -94,6 +94,11 @@ assert(string.char(string.byte("\xe4l\0ķu", 1, -1)) == "\xe4l\0ķu")
94assert(string.char(string.byte("\xe4l\0ķu", 1, 0)) == "") 94assert(string.char(string.byte("\xe4l\0ķu", 1, 0)) == "")
95assert(string.char(string.byte("\xe4l\0ķu", -10, 100)) == "\xe4l\0ķu") 95assert(string.char(string.byte("\xe4l\0ķu", -10, 100)) == "\xe4l\0ķu")
96 96
97checkerror("out of range", string.char, 256)
98checkerror("out of range", string.char, -1)
99checkerror("out of range", string.char, math.maxinteger)
100checkerror("out of range", string.char, math.mininteger)
101
97assert(string.upper("ab\0c") == "AB\0C") 102assert(string.upper("ab\0c") == "AB\0C")
98assert(string.lower("\0ABCc%$") == "\0abcc%$") 103assert(string.lower("\0ABCc%$") == "\0abcc%$")
99assert(string.rep('teste', 0) == '') 104assert(string.rep('teste', 0) == '')
diff --git a/testes/tpack.lua b/testes/tpack.lua
index 4c5fc7f7..2b9953f8 100644
--- a/testes/tpack.lua
+++ b/testes/tpack.lua
@@ -314,9 +314,7 @@ do -- testing initial position
314 for i = 1, #x + 1 do 314 for i = 1, #x + 1 do
315 assert(unpack("c0", x, i) == "") 315 assert(unpack("c0", x, i) == "")
316 end 316 end
317 checkerror("out of string", unpack, "c0", x, 0)
318 checkerror("out of string", unpack, "c0", x, #x + 2) 317 checkerror("out of string", unpack, "c0", x, #x + 2)
319 checkerror("out of string", unpack, "c0", x, -(#x + 1))
320 318
321end 319end
322 320