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 ed857fd0..6f35e132 100644 --- a/testes/api.lua +++ b/testes/api.lua | |||
@@ -366,7 +366,7 @@ do | |||
366 | -- "argerror" without frames | 366 | -- "argerror" without frames |
367 | assert(T.checkpanic("loadstring 4") == | 367 | assert(T.checkpanic("loadstring 4") == |
368 | "bad argument #4 (string expected, got no value)") | 368 | "bad argument #4 (string expected, got no value)") |
369 | 369 | ||
370 | 370 | ||
371 | -- memory error | 371 | -- memory error |
372 | T.totalmem(T.totalmem()+10000) -- set low memory limit (+10k) | 372 | T.totalmem(T.totalmem()+10000) -- set low memory limit (+10k) |
@@ -987,12 +987,12 @@ do | |||
987 | 987 | ||
988 | local a, b = T.testC([[ | 988 | local a, b = T.testC([[ |
989 | call 0 1 # create resource | 989 | call 0 1 # create resource |
990 | pushint 34 | 990 | pushnil |
991 | toclose -2 # mark call result to be closed | 991 | toclose -2 # mark call result to be closed |
992 | toclose -1 # mark number to be closed (will be ignored) | 992 | toclose -1 # mark nil to be closed (will be ignored) |
993 | return 2 | 993 | return 2 |
994 | ]], newresource) | 994 | ]], newresource) |
995 | assert(a[1] == 11 and b == 34) | 995 | assert(a[1] == 11 and b == nil) |
996 | assert(#openresource == 0) -- was closed | 996 | assert(#openresource == 0) -- was closed |
997 | 997 | ||
998 | -- repeat the test, but calling function in a 'multret' context | 998 | -- repeat the test, but calling function in a 'multret' context |
@@ -1005,7 +1005,7 @@ do | |||
1005 | assert(#openresource == 0) -- was closed | 1005 | assert(#openresource == 0) -- was closed |
1006 | 1006 | ||
1007 | -- error | 1007 | -- error |
1008 | local a, b = pcall(T.testC, [[ | 1008 | local a, b = pcall(T.makeCfunc[[ |
1009 | call 0 1 # create resource | 1009 | call 0 1 # create resource |
1010 | toclose -1 # mark it to be closed | 1010 | toclose -1 # mark it to be closed |
1011 | error # resource is the error object | 1011 | error # resource is the error object |
@@ -1038,6 +1038,13 @@ do | |||
1038 | ]], newresource, check) | 1038 | ]], newresource, check) |
1039 | assert(a == 3) -- no extra items left in the stack | 1039 | assert(a == 3) -- no extra items left in the stack |
1040 | 1040 | ||
1041 | -- non-closable value | ||
1042 | local a, b = pcall(T.makeCfunc[[ | ||
1043 | pushint 32 | ||
1044 | toclose -1 | ||
1045 | ]]) | ||
1046 | assert(not a and string.find(b, "(C temporary)")) | ||
1047 | |||
1041 | end | 1048 | end |
1042 | 1049 | ||
1043 | 1050 | ||
@@ -1249,9 +1256,9 @@ do -- closing state with no extra memory | |||
1249 | T.closestate(L) | 1256 | T.closestate(L) |
1250 | T.alloccount() | 1257 | T.alloccount() |
1251 | end | 1258 | end |
1252 | 1259 | ||
1253 | do -- garbage collection with no extra memory | 1260 | do -- garbage collection with no extra memory |
1254 | local L = T.newstate() | 1261 | local L = T.newstate() |
1255 | T.loadlib(L) | 1262 | T.loadlib(L) |
1256 | local res = (T.doremote(L, [[ | 1263 | local res = (T.doremote(L, [[ |
1257 | _ENV = require"_G" | 1264 | _ENV = require"_G" |