diff options
Diffstat (limited to 'testes/pm.lua')
-rw-r--r-- | testes/pm.lua | 29 |
1 files changed, 29 insertions, 0 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 | |||
297 | assert(a == 3) | 297 | assert(a == 3) |
298 | 298 | ||
299 | 299 | ||
300 | do -- 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) | ||
326 | end | ||
327 | |||
328 | |||
300 | -- tests for `%f' (`frontiers') | 329 | -- tests for `%f' (`frontiers') |
301 | 330 | ||
302 | assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") | 331 | assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x") |