diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-02-15 11:17:39 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-02-15 11:17:39 -0300 |
| commit | 165389b27bc54e7c5214276db177e3ef75226f18 (patch) | |
| tree | f6ce6e7bff04ff6cbe735ee68d64290cc04c04bf /testes | |
| parent | c8121ce34b39c6fd31899f4da91e26063c8af54f (diff) | |
| download | lua-165389b27bc54e7c5214276db177e3ef75226f18.tar.gz lua-165389b27bc54e7c5214276db177e3ef75226f18.tar.bz2 lua-165389b27bc54e7c5214276db177e3ef75226f18.zip | |
New interface to function 'luaL_openselectedlibs'
Instead of preloading all non-loaded libraries, there is another
mask to select which libraries to preload.
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/api.lua | 10 | ||||
| -rw-r--r-- | testes/coroutine.lua | 2 |
2 files changed, 6 insertions, 6 deletions
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 | |||
| 546 | ]], source) | 546 | ]], source) |
| 547 | collectgarbage() | 547 | collectgarbage() |
| 548 | local m2 = collectgarbage"count" * 1024 | 548 | local m2 = collectgarbage"count" * 1024 |
| 549 | -- load used fewer than 350 bytes. Code alone has more than 3*N bytes, | 549 | -- load used fewer than 400 bytes. Code alone has more than 3*N bytes, |
| 550 | -- and string literal has N bytes. Both were not loaded. | 550 | -- and string literal has N bytes. Both were not loaded. |
| 551 | assert(m2 > m1 and m2 - m1 < 350) | 551 | assert(m2 > m1 and m2 - m1 < 400) |
| 552 | X = 0; code(); assert(X == N and Y == string.rep("a", N)) | 552 | X = 0; code(); assert(X == N and Y == string.rep("a", N)) |
| 553 | X = nil; Y = nil | 553 | X = nil; Y = nil |
| 554 | 554 | ||
| @@ -1122,7 +1122,7 @@ assert(a == nil and c == 2) -- 2 == run-time error | |||
| 1122 | a, b, c = T.doremote(L1, "return a+") | 1122 | a, b, c = T.doremote(L1, "return a+") |
| 1123 | assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error | 1123 | assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error |
| 1124 | 1124 | ||
| 1125 | T.loadlib(L1, 2) -- load only 'package' | 1125 | T.loadlib(L1, 2, ~2) -- load only 'package', preload all others |
| 1126 | a, b, c = T.doremote(L1, [[ | 1126 | a, b, c = T.doremote(L1, [[ |
| 1127 | string = require'string' | 1127 | string = require'string' |
| 1128 | local initialG = _G -- not loaded yet | 1128 | local initialG = _G -- not loaded yet |
| @@ -1141,7 +1141,7 @@ T.closestate(L1); | |||
| 1141 | 1141 | ||
| 1142 | 1142 | ||
| 1143 | L1 = T.newstate() | 1143 | L1 = T.newstate() |
| 1144 | T.loadlib(L1, 0) | 1144 | T.loadlib(L1, 0, 0) |
| 1145 | T.doremote(L1, "a = {}") | 1145 | T.doremote(L1, "a = {}") |
| 1146 | T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1; | 1146 | T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1; |
| 1147 | settable -3]]) | 1147 | settable -3]]) |
| @@ -1524,7 +1524,7 @@ end | |||
| 1524 | 1524 | ||
| 1525 | do -- garbage collection with no extra memory | 1525 | do -- garbage collection with no extra memory |
| 1526 | local L = T.newstate() | 1526 | local L = T.newstate() |
| 1527 | T.loadlib(L, 1 | 2) -- load _G and 'package' | 1527 | T.loadlib(L, 1 | 2, 0) -- load _G and 'package' |
| 1528 | local res = (T.doremote(L, [[ | 1528 | local res = (T.doremote(L, [[ |
| 1529 | _ENV = _G | 1529 | _ENV = _G |
| 1530 | assert(string == nil) | 1530 | 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 | |||
| 705 | 705 | ||
| 706 | T.testC(state, "settop 0") | 706 | T.testC(state, "settop 0") |
| 707 | 707 | ||
| 708 | T.loadlib(state, 1 | 2) -- load _G and 'package' | 708 | T.loadlib(state, 1 | 2, 4) -- load _G and 'package', preload 'coroutine' |
| 709 | 709 | ||
| 710 | assert(T.doremote(state, [[ | 710 | assert(T.doremote(state, [[ |
| 711 | coroutine = require'coroutine'; | 711 | coroutine = require'coroutine'; |
