diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-07 15:12:52 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-07 15:12:52 -0300 |
| commit | d738c8d18bcc5651109b3a46103d6aa983772e68 (patch) | |
| tree | e66f2f38d7cc1600da3ea19b134c7c21636a3870 /testes | |
| parent | 0270c204c235a495ce4702ac3891eb30752d0c8d (diff) | |
| download | lua-d738c8d18bcc5651109b3a46103d6aa983772e68.tar.gz lua-d738c8d18bcc5651109b3a46103d6aa983772e68.tar.bz2 lua-d738c8d18bcc5651109b3a46103d6aa983772e68.zip | |
New function 'luaL_openselectedlibs'
Makes it easier to start Lua with only some standard libraries.
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/api.lua | 14 | ||||
| -rw-r--r-- | testes/coroutine.lua | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/testes/api.lua b/testes/api.lua index bd85a923..f8e36ae3 100644 --- a/testes/api.lua +++ b/testes/api.lua | |||
| @@ -1039,10 +1039,12 @@ assert(a == nil and b == 2) -- 2 == run-time error | |||
| 1039 | a, b, c = T.doremote(L1, "return a+") | 1039 | a, b, c = T.doremote(L1, "return a+") |
| 1040 | assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error | 1040 | assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error |
| 1041 | 1041 | ||
| 1042 | T.loadlib(L1) | 1042 | T.loadlib(L1, 2) -- load only 'package' |
| 1043 | a, b, c = T.doremote(L1, [[ | 1043 | a, b, c = T.doremote(L1, [[ |
| 1044 | string = require'string' | 1044 | string = require'string' |
| 1045 | a = require'_G'; assert(a == _G and require("_G") == a) | 1045 | local initialG = _G -- not loaded yet |
| 1046 | local a = require'_G'; assert(a == _G and require("_G") == a) | ||
| 1047 | assert(initialG == nil and io == nil) -- now we have 'assert' | ||
| 1046 | io = require'io'; assert(type(io.read) == "function") | 1048 | io = require'io'; assert(type(io.read) == "function") |
| 1047 | assert(require("io") == io) | 1049 | assert(require("io") == io) |
| 1048 | a = require'table'; assert(type(a.insert) == "function") | 1050 | a = require'table'; assert(type(a.insert) == "function") |
| @@ -1056,7 +1058,7 @@ T.closestate(L1); | |||
| 1056 | 1058 | ||
| 1057 | 1059 | ||
| 1058 | L1 = T.newstate() | 1060 | L1 = T.newstate() |
| 1059 | T.loadlib(L1) | 1061 | T.loadlib(L1, 0) |
| 1060 | T.doremote(L1, "a = {}") | 1062 | T.doremote(L1, "a = {}") |
| 1061 | T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1; | 1063 | T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1; |
| 1062 | settable -3]]) | 1064 | settable -3]]) |
| @@ -1436,10 +1438,10 @@ end | |||
| 1436 | 1438 | ||
| 1437 | do -- garbage collection with no extra memory | 1439 | do -- garbage collection with no extra memory |
| 1438 | local L = T.newstate() | 1440 | local L = T.newstate() |
| 1439 | T.loadlib(L) | 1441 | T.loadlib(L, 1 | 2) -- load _G and 'package' |
| 1440 | local res = (T.doremote(L, [[ | 1442 | local res = (T.doremote(L, [[ |
| 1441 | _ENV = require"_G" | 1443 | _ENV = _G |
| 1442 | local T = require"T" | 1444 | assert(string == nil) |
| 1443 | local a = {} | 1445 | local a = {} |
| 1444 | for i = 1, 1000 do a[i] = 'i' .. i end -- grow string table | 1446 | for i = 1, 1000 do a[i] = 'i' .. i end -- grow string table |
| 1445 | local stsize, stuse = T.querystr() | 1447 | local stsize, stuse = T.querystr() |
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 15fccc30..f05672a5 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
| @@ -694,7 +694,7 @@ else | |||
| 694 | 694 | ||
| 695 | T.testC(state, "settop 0") | 695 | T.testC(state, "settop 0") |
| 696 | 696 | ||
| 697 | T.loadlib(state) | 697 | T.loadlib(state, 1 | 2) -- load _G and 'package' |
| 698 | 698 | ||
| 699 | assert(T.doremote(state, [[ | 699 | assert(T.doremote(state, [[ |
| 700 | coroutine = require'coroutine'; | 700 | coroutine = require'coroutine'; |
