aboutsummaryrefslogtreecommitdiff
path: root/testes (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Small changes around C-stack limitRoberto Ierusalimschy2019-06-261-7/+21
| | | | | | | | | - Better documentation in 'testes/cstack.lua' about using 'debug.setCstacklimit' to find a good limit. - Constant LUAI_MAXCSTACK gets added CSTACKERR (extra stack for error handling), so that it is compatible with the argument to 'debug.setCstacklimit'.
* '__call' metamethod can be any callable objectRoberto Ierusalimschy2019-06-251-0/+17
| | | | | Removed the restriction that a '__call' metamethod must be an actual function.
* A few more tests for table access in the APIRoberto Ierusalimschy2019-06-251-1/+47
| | | | | Added tests where the table being accessed is also the index or value in the operation.
* Added script 'packtests' to the projectRoberto Ierusalimschy2019-06-211-0/+52
| | | | | The script 'packtests' creates the 'tar.gz' to deploy the test suite for Lua.
* Details in testsRoberto Ierusalimschy2019-06-212-18/+10
| | | | | | | | | | - Added a test for calling 'debug.traceback' after yields inside hooks. (Lua 5.3 seems to have a bug there.) - Removed test "repeat test with '__open' metamethod instead of a function", as the previous test already uses the '__open' metamethod. (It changed when functions were removed as possible to-be-closed variables).
* New function 'setCstacklimit'Roberto Ierusalimschy2019-06-182-6/+58
| | | | | Added new functions to dynamically set the C-stack limit ('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
* Revamp around 'L->nCcalls' countRoberto Ierusalimschy2019-06-121-0/+14
| | | | | The field 'L->nCcalls' now counts downwards, so that the C-stack limits do not depend on the stack size.
* Multiple errors in '__toclose' report the first oneRoberto Ierusalimschy2019-06-052-14/+33
| | | | | | | | When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback.
* Function 'warn' is varargRoberto Ierusalimschy2019-06-042-13/+27
| | | | | | | Instead of a 'tocont' flag, the function 'warn' in Lua now receives all message pieces as multiple arguments in a single call. Besides being simpler to use, this implementation ensures that Lua code cannot create unfinished warnings.
* 'coroutine.kill' renamed 'coroutine.close'Roberto Ierusalimschy2019-06-031-11/+11
|
* bug in 5.4 alpha rc1: to-be-closed x vararg functionsRoberto Ierusalimschy2019-06-031-0/+9
| | | | | | Closing methods must be run before correcting 'ci->func' when exiting a vararg function, to get correct debug information (e.g., in case of errors).
* Improvements in 'testes/cstack.lua'Roberto Ierusalimschy2019-06-031-12/+32
| | | | | | - tests show progress in real time, so that we can see maximum stack levels even if test crashes. - new test for recursion continuing into message handler.
* DetailsRoberto Ierusalimschy2019-05-283-5/+5
| | | | | | | - new error message for "attempt to assign to const variable" - note in the manual about compatibility options - comments - small changes in 'read_line' and 'pushstr'
* First implementation for 'const' variablesRoberto Ierusalimschy2019-05-173-9/+66
| | | | | A variable can be declared const, which means it cannot be assigned to, with the syntax 'local <const> name = exp'.
* Flag for to-be-closed variables changed to '<toclose>'Roberto Ierusalimschy2019-05-096-35/+36
| | | | | | | The flag for to-be-closed variables was changed from '*toclose' to '<toclose>'. Several people found confusing the old syntax and the new one has a clear terminator, making it more flexible for future changes.
* Coroutines do not unwind the stack in case of errorsRoberto Ierusalimschy2019-05-093-14/+43
| | | | | | | | | | | Back to how it was, a coroutine does not unwind its stack in case of errors (and therefore do not close its to-be-closed variables). This allows the stack to be examined after the error. The program can use 'coroutine.kill' to close the variables. The function created by 'coroutine.wrap', however, closes the coroutine's variables in case of errors, as it is impossible to examine the stack any way.
* File 'lib2-v2.so' generated from its own sourceRoberto Ierusalimschy2019-05-033-3/+28
| | | | | Instead of being a copy of 'lib2.so', 'lib2-v2.so' has its own source file ('lib22.c'), so that the test can distinguish both libraries.
* A few more improvements in 'luaO_pushvfstring'Roberto Ierusalimschy2019-05-031-2/+1
| | | | | | | | - 'L' added to the 'BuffFS' structure - '%c' does not handle control characters (it is not its business. This now is done by the lexer, who is the one in charge of that kind of errors.) - avoid the direct use of 'l_sprintf' in the Lua kernel
* Avoid the creation of too many strings in 'package'Roberto Ierusalimschy2019-05-031-8/+19
| | | | | | | | | Both when setting a path and searching for a file ('searchpath'), this commit reduces the number of intermediate strings created in Lua. (For setting a path the change is not relevant, because this is done only twice when loading the module. Anyway, it is a nice example of how to use auxlib buffers to manipulate strings in the C API.)
* Some more small improvements to 'luaO_pushvfstring'Roberto Ierusalimschy2019-04-261-0/+3
| | | | | | | Details: - counter 'pushed' moved to the struct 'BuffFS' - new auxiliar function 'getbuff' to build strings directly on the buffer.
* Revamp of 'lua_pushfstring' / 'luaO_pushvfstring'Roberto Ierusalimschy2019-04-241-0/+61
| | | | | | | | | The function 'luaO_pushvfstring' now uses an internal buffer to concatenate small strings, instead of pushing all pieces on the stack. This avoids the creation of several small Lua strings for each piece of the result. (For instance, a format like "n: '%d'" used to create three intermediate strings: "n: '", the numeral, and "'". Now it creates none.)
* Small correction in test about 'isdst'Roberto Ierusalimschy2019-04-221-1/+1
| | | | | The field 'isdst' can be false, so we cannot test its absence with 'if not D.isdst'; we must compare with nil for a correct test.
* 'require' returns where module was foundRoberto Ierusalimschy2019-04-171-15/+20
| | | | | The function 'require' returns the *loader data* as a second result. For file searchers, this data is the path where they found the module.
* Small optimizations in 'string.gsub'Roberto Ierusalimschy2019-04-112-1/+31
| | | | | | | | | | | Avoid creating extra strings when possible: - avoid creating new resulting string when subject was not modified (instead, return the subject itself); - avoid creating strings representing the captured substrings when handling replacements like '%1' (instead, add the substring directly to the buffer).
* Added an optional parameter to 'coroutine.isyieldable'Roberto Ierusalimschy2019-04-101-2/+5
|
* 'print' does not call 'tostring' to format its argumentsRoberto Ierusalimschy2019-04-101-15/+0
|
* Corrected tests around non-portable 'isdst' in datesRoberto Ierusalimschy2019-04-091-3/+7
| | | | | The field 'isdst' in date tables may not be present; portable tests should not assume it is.
* Syntax should not allow numbers touching identifiersRoberto Ierusalimschy2019-04-091-0/+9
| | | | Code like 'a = 1print()' should not be accepted.
* Fixed wrong error message in 'return math.seed(0)'Roberto Ierusalimschy2019-04-042-1/+5
| | | | | | Bug introduced in commit 28d829c8: OP_TAILCALL might raise an error without saving 'pc'. (This commit also fixes a detail in 'testes/uf8.lua'.)
* Small optimizations in range checksRoberto Ierusalimschy2019-03-271-0/+3
| | | | | | | | Checks of the form '1 <= x && x <= M' were rewritten in the form '(unsigned)x - 1 < (unsigned)M', which is usually more efficient. (Other similar checks have similar translations.) Although some compilers do these optimizations, that does not happen for all compilers or all cases.
* Keep correct type for immediate operands in comparisonsRoberto Ierusalimschy2019-03-222-55/+46
| | | | | | | | | | | | When calling metamethods for things like 'a < 3.0', which generates the opcode OP_LTI, the C register tells that the operand was converted to an integer, so that it can be corrected to float when calling a metamethod. This commit also includes some other stuff: - file 'onelua.c' added to the project - opcode OP_PREPVARARG renamed to OP_VARARGPREP - comparison opcodes rewritten through macros
* Details in the implementation of the integer 'for' loopRoberto Ierusalimschy2019-03-211-0/+6
| | | | | | | | Changed some implementation details; in particular, it is back using an internal variable to keep the index, with the control variable being only a copy of that internal variable. (The direct use of the control variable demands a check of its type for each access, which offsets the gains from the use of a single variable.)
* Small changes in the header of binary filesRoberto Ierusalimschy2019-03-191-11/+9
| | | | | | | | | - LUAC_VERSION is equal to LUA_VERSION_NUM, and it is stored as an int. - 'sizeof(int)' and 'sizeof(size_t)' removed from the header, as the binary format does not depend on these sizes. (It uses its own serialization for unsigned integer values.)
* New semantics for the integer 'for' loopRoberto Ierusalimschy2019-03-193-8/+71
| | | | | | | | | | | The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
* Changes in the validation of UTF-8Roberto Ierusalimschy2019-03-152-37/+72
| | | | | | | | | | | All UTF-8 encoding functionality (including the escape sequence '\u') accepts all values from the original UTF-8 specification (with sequences of up to six bytes). By default, the decoding functions in the UTF-8 library do not accept invalid Unicode code points, such as surrogates. A new parameter 'nonstrict' makes them accept all code points up to (2^31)-1, as in the original UTF-8 specification.
* Changes in the warning systemRoberto Ierusalimschy2019-03-143-16/+17
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* 'math.randomseed()' sets a somewhat random seedRoberto Ierusalimschy2019-03-131-1/+1
| | | | | | When called with no arguments, 'math.randomseed' uses time and ASLR to generate a somewhat random seed. the initial seed when Lua starts is generated this way.
* New conversion specifier '%p' for 'string.format'Roberto Ierusalimschy2019-03-131-0/+16
| | | | | The call 'string.format("%p", val)' gives a Lua equivalent to the C API function 'lua_topointer'.
* DetailsRoberto Ierusalimschy2019-03-132-7/+15
| | | | | | | | | | Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard)
* After a "bad collections", avoid switching back back to generationalRoberto Ierusalimschy2019-01-301-0/+6
| | | | | | | After a major bad collection (one that collects too few objects), next collection will be major again. In that case, avoid switching back to generational mode (as it will have to switch again to incremental to do next major collection).
* Optional 'init' argument to 'string.gmatch'Roberto Ierusalimschy2019-01-083-2/+34
| | | | | | | | | The function 'string.gmatch' now has an optional 'init' argument, similar to 'string.find' and 'string.match'. Moreover, there was some reorganization in the manipulation of indices in the string library. This commit also includes small janitorial work in the manual and in comments in the interpreter loop.
* No more to-be-closed functionsRoberto Ierusalimschy2019-01-044-27/+61
| | | | | | | | | | | | | | | | | | | To-be-closed variables must contain objects with '__toclose' metamethods (or nil). Functions were removed for several reasons: * Functions interact badly with sandboxes. If a sandbox raises an error to interrupt a script, a to-be-closed function still can hijack control and continue running arbitrary sandboxed code. * Functions interact badly with coroutines. If a coroutine yields and is never resumed again, its to-be-closed functions will never run. To-be-closed objects, on the other hand, will still be closed, provided they have appropriate finalizers. * If you really need a function, it is easy to create a dummy object to run that function in its '__toclose' metamethod. This comit also adds closing of variables in case of panic.
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-013-61/+65
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-282-5/+22
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* Changes in the control of C-stack overflowRoberto Ierusalimschy2018-12-274-14/+65
| | | | | | | | | | * unification of the 'nny' and 'nCcalls' counters; * external C functions ('lua_CFunction') count more "slots" in the C stack (to allow for their possible use of buffers) * added a new test script specific for C-stack overflows. (Most of those tests were already present, but concentrating them in a single script easies the task of checking whether 'LUAI_MAXCCALLS' is adequate in a system.)
* DetailRoberto Ierusalimschy2018-12-271-1/+1
| | | | Slightly better error message for invalid conversions in 'string.format'.
* 'all' script automatically 'make's everythingRoberto Ierusalimschy2018-12-191-5/+6
| | | | | | The script 'all', to run all tests, automatically ensures that the Lua interpreter and the test C libraries (in 'testes/libs/') are updated with any changes in 'luaconf.h'.
* Added directory 'testes/libs/P1' to the repositoryRoberto Ierusalimschy2018-12-171-0/+2
| | | | | This directory is used for some tests. As standard Lua has no command to create directories, it must be present before running tests.
* Added file 'testes/heavy.lua'Roberto Ierusalimschy2018-12-141-0/+173
| | | | | | | | | | | | | | | | | | This file is not part of the regular tests. It tests error conditions that demand too much memory or too much time to create: * string with too many characters * control structure with body too large * chunk with too many lines * identifier with too many characters * chunks with too many instructions * function with too many constants * too many strings internalized * table with too many entries In machines with limited memory (less than 150 GB), many tests run up to a "not enough memory" error. We need some memory (~256 GB) to run all tests up to their intrinsic limits.
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-132-5/+64
| | | | | | New functions to reset/kill a thread/coroutine, mainly (only?) to close any pending to-be-closed variable. ('lua_resetthread' also allows a thread to be reused...)