aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/api.lua21
-rw-r--r--testes/strings.lua1
2 files changed, 15 insertions, 7 deletions
diff --git a/testes/api.lua b/testes/api.lua
index 9904dadf..d034ea80 100644
--- a/testes/api.lua
+++ b/testes/api.lua
@@ -332,6 +332,7 @@ function to (s, x, n)
332 return T.testC(string.format("%s %d; return 1", s, n), x) 332 return T.testC(string.format("%s %d; return 1", s, n), x)
333end 333end
334 334
335local null = T.pushuserdata(0)
335local hfunc = string.gmatch("", "") -- a "heavy C function" (with upvalues) 336local hfunc = string.gmatch("", "") -- a "heavy C function" (with upvalues)
336assert(debug.getupvalue(hfunc, 1)) 337assert(debug.getupvalue(hfunc, 1))
337assert(to("tostring", {}) == nil) 338assert(to("tostring", {}) == nil)
@@ -349,13 +350,19 @@ assert(to("tonumber", {}) == 0)
349assert(to("tonumber", "12") == 12) 350assert(to("tonumber", "12") == 12)
350assert(to("tonumber", "s2") == 0) 351assert(to("tonumber", "s2") == 0)
351assert(to("tonumber", 1, 20) == 0) 352assert(to("tonumber", 1, 20) == 0)
352assert(to("topointer", 10) == 0) 353assert(to("topointer", 10) == null)
353assert(to("topointer", true) == 0) 354assert(to("topointer", true) == null)
354assert(to("topointer", T.pushuserdata(20)) == 20) 355assert(to("topointer", nil) == null)
355assert(to("topointer", io.read) ~= 0) -- light C function 356assert(to("topointer", "abc") ~= null)
356assert(to("topointer", hfunc) ~= 0) -- "heavy" C function 357assert(to("topointer", string.rep("x", 10)) ==
357assert(to("topointer", function () end) ~= 0) -- Lua function 358 to("topointer", string.rep("x", 10))) -- short strings
358assert(to("topointer", io.stdin) ~= 0) -- full userdata 359assert(to("topointer", string.rep("x", 300)) ~=
360 to("topointer", string.rep("x", 300))) -- long strings
361assert(to("topointer", T.pushuserdata(20)) ~= null)
362assert(to("topointer", io.read) ~= null) -- light C function
363assert(to("topointer", hfunc) ~= null) -- "heavy" C function
364assert(to("topointer", function () end) ~= null) -- Lua function
365assert(to("topointer", io.stdin) ~= null) -- full userdata
359assert(to("func2num", 20) == 0) 366assert(to("func2num", 20) == 0)
360assert(to("func2num", T.pushuserdata(10)) == 0) 367assert(to("func2num", T.pushuserdata(10)) == 0)
361assert(to("func2num", io.read) ~= 0) -- light C function 368assert(to("func2num", io.read) ~= 0) -- light C function
diff --git a/testes/strings.lua b/testes/strings.lua
index 88480924..da53a87e 100644
--- a/testes/strings.lua
+++ b/testes/strings.lua
@@ -199,6 +199,7 @@ end
199 199
200assert(string.format("\0%s\0", "\0\0\1") == "\0\0\0\1\0") 200assert(string.format("\0%s\0", "\0\0\1") == "\0\0\0\1\0")
201checkerror("contains zeros", string.format, "%10s", "\0") 201checkerror("contains zeros", string.format, "%10s", "\0")
202checkerror("cannot have modifiers", string.format, "%10q", "1")
202 203
203-- format x tostring 204-- format x tostring
204assert(string.format("%s %s", nil, true) == "nil true") 205assert(string.format("%s %s", nil, true) == "nil true")