diff options
Diffstat (limited to 'testes/api.lua')
-rw-r--r-- | testes/api.lua | 21 |
1 files changed, 14 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) |
333 | end | 333 | end |
334 | 334 | ||
335 | local null = T.pushuserdata(0) | ||
335 | local hfunc = string.gmatch("", "") -- a "heavy C function" (with upvalues) | 336 | local hfunc = string.gmatch("", "") -- a "heavy C function" (with upvalues) |
336 | assert(debug.getupvalue(hfunc, 1)) | 337 | assert(debug.getupvalue(hfunc, 1)) |
337 | assert(to("tostring", {}) == nil) | 338 | assert(to("tostring", {}) == nil) |
@@ -349,13 +350,19 @@ assert(to("tonumber", {}) == 0) | |||
349 | assert(to("tonumber", "12") == 12) | 350 | assert(to("tonumber", "12") == 12) |
350 | assert(to("tonumber", "s2") == 0) | 351 | assert(to("tonumber", "s2") == 0) |
351 | assert(to("tonumber", 1, 20) == 0) | 352 | assert(to("tonumber", 1, 20) == 0) |
352 | assert(to("topointer", 10) == 0) | 353 | assert(to("topointer", 10) == null) |
353 | assert(to("topointer", true) == 0) | 354 | assert(to("topointer", true) == null) |
354 | assert(to("topointer", T.pushuserdata(20)) == 20) | 355 | assert(to("topointer", nil) == null) |
355 | assert(to("topointer", io.read) ~= 0) -- light C function | 356 | assert(to("topointer", "abc") ~= null) |
356 | assert(to("topointer", hfunc) ~= 0) -- "heavy" C function | 357 | assert(to("topointer", string.rep("x", 10)) == |
357 | assert(to("topointer", function () end) ~= 0) -- Lua function | 358 | to("topointer", string.rep("x", 10))) -- short strings |
358 | assert(to("topointer", io.stdin) ~= 0) -- full userdata | 359 | assert(to("topointer", string.rep("x", 300)) ~= |
360 | to("topointer", string.rep("x", 300))) -- long strings | ||
361 | assert(to("topointer", T.pushuserdata(20)) ~= null) | ||
362 | assert(to("topointer", io.read) ~= null) -- light C function | ||
363 | assert(to("topointer", hfunc) ~= null) -- "heavy" C function | ||
364 | assert(to("topointer", function () end) ~= null) -- Lua function | ||
365 | assert(to("topointer", io.stdin) ~= null) -- full userdata | ||
359 | assert(to("func2num", 20) == 0) | 366 | assert(to("func2num", 20) == 0) |
360 | assert(to("func2num", T.pushuserdata(10)) == 0) | 367 | assert(to("func2num", T.pushuserdata(10)) == 0) |
361 | assert(to("func2num", io.read) ~= 0) -- light C function | 368 | assert(to("func2num", io.read) ~= 0) -- light C function |