From 165389b27bc54e7c5214276db177e3ef75226f18 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 15 Feb 2024 11:17:39 -0300 Subject: New interface to function 'luaL_openselectedlibs' Instead of preloading all non-loaded libraries, there is another mask to select which libraries to preload. --- testes/api.lua | 10 +++++----- testes/coroutine.lua | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'testes') diff --git a/testes/api.lua b/testes/api.lua index ca4b3fb4..eec9c0ab 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -546,9 +546,9 @@ do ]], source) collectgarbage() local m2 = collectgarbage"count" * 1024 - -- load used fewer than 350 bytes. Code alone has more than 3*N bytes, + -- load used fewer than 400 bytes. Code alone has more than 3*N bytes, -- and string literal has N bytes. Both were not loaded. - assert(m2 > m1 and m2 - m1 < 350) + assert(m2 > m1 and m2 - m1 < 400) X = 0; code(); assert(X == N and Y == string.rep("a", N)) X = nil; Y = nil @@ -1122,7 +1122,7 @@ assert(a == nil and c == 2) -- 2 == run-time error a, b, c = T.doremote(L1, "return a+") assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error -T.loadlib(L1, 2) -- load only 'package' +T.loadlib(L1, 2, ~2) -- load only 'package', preload all others a, b, c = T.doremote(L1, [[ string = require'string' local initialG = _G -- not loaded yet @@ -1141,7 +1141,7 @@ T.closestate(L1); L1 = T.newstate() -T.loadlib(L1, 0) +T.loadlib(L1, 0, 0) T.doremote(L1, "a = {}") T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1; settable -3]]) @@ -1524,7 +1524,7 @@ end do -- garbage collection with no extra memory local L = T.newstate() - T.loadlib(L, 1 | 2) -- load _G and 'package' + T.loadlib(L, 1 | 2, 0) -- load _G and 'package' local res = (T.doremote(L, [[ _ENV = _G assert(string == nil) diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 664ef5fa..c1252ab8 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua @@ -705,7 +705,7 @@ else T.testC(state, "settop 0") - T.loadlib(state, 1 | 2) -- load _G and 'package' + T.loadlib(state, 1 | 2, 4) -- load _G and 'package', preload 'coroutine' assert(T.doremote(state, [[ coroutine = require'coroutine'; -- cgit v1.2.3-55-g6feb