aboutsummaryrefslogtreecommitdiff
path: root/testes (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Added macro 'luaL_pushfail'Roberto Ierusalimschy2019-08-169-91/+91
| | | | | | | | The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'.
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-163-28/+133
|
* Added control messages to warningsRoberto Ierusalimschy2019-08-154-1/+42
| | | | | | | Added the concept of control messages to the warning system, plus the implementation of the controls "@on"/"@off" to turn warnings on/off. Moreover, the warning system in the test library adds some other controls to ease the test of warnings.
* Tracebacks recognize metamethods '__close'Roberto Ierusalimschy2019-07-311-4/+17
|
* To-be-closed variables must be closed on initializationRoberto Ierusalimschy2019-07-312-12/+22
| | | | | | | | | When initializing a to-be-closed variable, check whether it has a '__close' metamethod (or is a false value) and raise an error if if it hasn't. This produces more accurate error messages. (The check before closing still need to be done: in the C API, the value is not constant; and the object may lose its '__close' metamethod during the block.)
* Fixed test in 'main.lua'Roberto Ierusalimschy2019-07-301-7/+10
| | | | | | | The test "to-be-closed variables in main chunk" was broken, as it used the removed feature of functions as to-be-closed values. The error was not detected because its expected result had no lines to be checked (due to missing new lines).
* Change in the syntax of attributesRoberto Ierusalimschy2019-07-3010-90/+90
| | | | | | | Attributes changed to posfixed ('x <const>', instead of '<const> x'), and "toclose" renamed to "close". Posfixed attributes seem to make it clearer that it applies to only one variable when there are multiple variables.
* Change in the handling of 'L->top' when calling metamethodsRoberto Ierusalimschy2019-07-264-5/+36
| | | | | | | Instead of updating 'L->top' in every place that may call a metamethod, the metamethod functions themselves (luaT_trybinTM and luaT_callorderTM) correct the top. (When calling metamethods from the C API, however, the callers must preserve 'L->top'.)
* Small corrections when setting 'L->top'Roberto Ierusalimschy2019-07-251-1/+2
| | | | | | | | | - OP_NEWTABLE can use 'ra + 1' to set top (instead of ci->top); - OP_CLOSE doesn't need to set top ('Protect' already does that); - OP_TFORCALL must use 'ProtectNT', to preserve the top already set. (That was a small bug, because iterators could be called with extra parameters besides the state and the control variable.) - Comments and an extra test for the bug in previous item.
* Some improvements in date/time functionsRoberto Ierusalimschy2019-07-241-13/+52
| | | | | | - Range in date table extended to full 32 bits. - Easier support for times represented as floats. - Added more tests.
* Fixed bug in 'string.format' with option '%f'Roberto Ierusalimschy2019-07-231-0/+6
| | | | | | | | | | | As an example, 'print(string.format("%.99f", 1e70))' may have a lot of garbage after the number. The old test to ensure that 'string.format("%.99f", n)' was not too large, 'fabs(n) < 1e100', assumes that the number will fit in the 99 bytes; but the 99 is not the space for the number, it is the added extra zeros. The option worked for smaller numbers because of the extra space added to MAX_ITEM.
* 'math.randomseed' always returns the two seed componentsRoberto Ierusalimschy2019-07-191-2/+4
|
* Avoid using addresses of static variables as unique keysRoberto Ierusalimschy2019-07-191-0/+4
| | | | | | The addresses of static variables may be different for different instances of Lua, making these instances incompatible if they use these addresses as unique keys in the registry (or other tables).
* DetailsRoberto Ierusalimschy2019-07-182-20/+12
| | | | | | | - Macro 'checkliveness' (for debug) always uses 'L', to avoid warnings. - Some old 'while' changed to 'for' in 'testes/gc.lua'. - In 'testes/libs/makefile', do not make files depend on 'ltests.h', which may not even exist.
* Reviving HARDMEMTESTSRoberto Ierusalimschy2019-07-182-5/+13
| | | | | | | | | | | This commit brings a new implementation for HARDMEMTESTS, which forces an emergency GC whenever possible. It also fixes some issues detected with this option: - A small bug in lvm.c: a closure could be collected by an emergency GC while being initialized. - Some tests: a memory address can be immediatly reused after a GC; for instance, two consecutive '{}' expressions can return exactly the same address, if the first one is not anchored.
* 'math.randomseed()' returns the seeds it usedRoberto Ierusalimschy2019-07-172-5/+17
| | | | | A call to 'math.randomseed()' returns the two components of the seed it set, so that they can be used to set that same seed again.
* Fixed small issue with constant propagationRoberto Ierusalimschy2019-07-171-4/+6
| | | | | | | | Constants directly assigned to other constants were not propagating: For instance, in local <const> k1 = 10 local <const> k2 = k1 'k2' were not treated as a compile-time constant.
* New kind of expression VKSTRRoberto Ierusalimschy2019-07-171-0/+17
| | | | | | | String literal expressions have their own kind VKSTR, instead of the generic VK. This allows strings to "cross" functions without entering their constant tables (e.g., if they are used only by some nested function).
* '__close' method may be called again in case of errorRoberto Ierusalimschy2019-07-161-7/+14
| | | | | | | | | An error in a closing method may be caused by a lack of resources, such as memory or stack space, and the error may free enough resources (by unwinding the stack) to allow the method to work if called again. If the closing method is already running after some error (including its own), it is not called again.
* Unification of size representation in OP_NEWTABLE and OP_SETLISTRoberto Ierusalimschy2019-07-151-10/+18
| | | | | | Opcodes OP_NEWTABLE and OP_SETLIST use the same representation to store the size of the array part of a table. This new representation can go up to 2^33 (8 + 25 bits).
* OP_NEWTABLE keeps exact size of arraysRoberto Ierusalimschy2019-07-122-35/+23
| | | | | | OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep the exact size of the array part of the table to be created. (Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
* First implementation of constant propagationRoberto Ierusalimschy2019-07-124-42/+89
| | | | | Local constant variables initialized with compile-time constants are optimized away from the code.
* DetailsRoberto Ierusalimschy2019-07-101-3/+5
| | | | | | | | In the generic for loop, it is simpler for OP_TFORLOOP to use the same 'ra' as OP_TFORCALL. Moreover, the internal names of the loop temporaries "(for ...)" don't need to leak internal details (even because the numerical for loop doesn't have a fixed role for each of its temporaries).
* New implementation for constantsRoberto Ierusalimschy2019-07-091-4/+14
| | | | | | | | | VLOCAL expressions keep a reference to their corresponding 'Vardesc', and 'Upvaldesc' (for upvalues) has a field 'ro' (read-only). So, it is easier to check whether a variable is read-only. The decoupling in VLOCAL between 'vidx' ('Vardesc' index) and 'sidx' (stack index) should also help the forthcoming implementation of compile-time constant propagation.
* Local attributes can be used in list of local variablesRoberto Ierusalimschy2019-07-031-6/+28
| | | | | | | | | | | | The syntax for local attributes ('const'/'toclose') was unified with the regular syntax for local variables, so that we can have variables with attributes in local definitions with multiple names; for instance: local <toclose> f, <const> err = io.open(fname) This new syntax does not implement constant propagation, yet. This commit also has some small improvements to the manual.
* 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
|