aboutsummaryrefslogtreecommitdiff
path: root/testes (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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...)
* 'math.rand()' uses higher bits to produce float valueRoberto Ierusalimschy2018-12-111-6/+8
| | | | | | | The call 'math.rand()' converts the higher bits of the internal unsigned integer random to a float, instead of its lower bits. That ensures that Lua compiled with different float precisions always generates equal (up to the available precision) random numbers when given the same seed.
* Calls cannot be tail in the scope of a to-be-closed variableRoberto Ierusalimschy2018-12-041-5/+8
| | | | | | A to-be-closed variable must be closed when a block ends, so even a 'return foo()' cannot directly returns the results of 'foo'; the function must close the scope before returning.
* A to-be-closed variable must have a closable value (or be nil)Roberto Ierusalimschy2018-11-293-17/+45
| | | | | | | It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
* Auxiliary buffer cannot close box with 'lua_remove'Roberto Ierusalimschy2018-11-261-16/+40
| | | | | | | To remove a to-be-closed variable from the stack in the C API a function must use 'lua_settop' or 'lua_pop'. Previous implementation of 'luaL_pushresult' was not closing the box. (This commit also added tests to check that box is being closed "as soon as possible".)
* Added opcodes for arithmetic with K operandsRoberto Ierusalimschy2018-11-233-31/+55
| | | | | | | | Added opcodes for all seven arithmetic operators with K operands (that is, operands that are numbers in the array of constants of the function). They cover the cases of constant float operands (e.g., 'x + .0.0', 'x^0.5') and large integer operands (e.g., 'x % 10000').
* String buffer using to-be-closed variableRoberto Ierusalimschy2018-11-131-0/+32
| | | | | The string buffers in the C API now mark their boxes as to-be-closed variables, to release their buffers in case of errors.
* 'lua_toclose' gets the index to be closed as an argumentRoberto Ierusalimschy2018-11-121-8/+10
| | | | | | Sometimes it is useful to mark to-be-closed an index that is not at the top of the stack (e.g., if the value to be closed came from a function call returning multiple values).
* To-be-closed variable in 'for' loop separated from the stateRoberto Ierusalimschy2018-11-072-2/+43
| | | | | | | | | The variable to be closed in a generic 'for' loop now is the 4th value produced in the loop initialization, instead of being the loop state (the 2nd value produced). That allows a loop to use a state with a '__toclose' metamethod but do not close it. (As an example, 'f:lines()' might use the file 'f' as a state for the loop, but it should not close the file when the loop ends.)
* New syntax for to-be-closed variablesRoberto Ierusalimschy2018-11-074-31/+31
| | | | | | | The new syntax is <local *toclose x = f()>. The mark '*' allows other attributes to be added later without the need of new keywords; it also allows better error messages. The API function was also renamed ('lua_tobeclosed' -> 'lua_toclose').
* Removed internal cache for closuresRoberto Ierusalimschy2018-11-011-7/+6
| | | | | | | | | | | | | | | | | | | The mechanism of "caching the last closure created for a prototype to try to reuse it the next time a closure for that prototype is created" was removed. There are several reasons: - It is hard to find a natural example where this cache has a measurable impact on performance. - Programmers already perceive closure creation as something slow, so they tend to avoid it inside hot paths. (Any case where the cache could reuse a closure can be rewritten predefining the closure in some variable and using that variable.) - The implementation was somewhat complex, due to a bad interaction with the generational collector. (Typically, new closures are new, while prototypes are old. So, the cache breaks the invariant that old objects should not point to new ones.)
* State in generic 'for' acts as a to-be-closed variableRoberto Ierusalimschy2018-10-312-5/+53
| | | | | | | | | | | The implicit variable 'state' in a generic 'for' is marked as a to-be-closed variable, so that the state will be closed as soon as the loop ends, no matter how. Taking advantage of this new facility, the call 'io.lines(filename)' now returns the open file as a second result. Therefore, an iteraction like 'for l in io.lines(name)...' will close the file even when the loop ends with a break or an error.
* Better error messages for invalid operands in numeric 'for'Roberto Ierusalimschy2018-10-301-0/+10
| | | | | | "Better" and similar to error messages for invalid function arguments. *old message: 'for' limit must be a number *new message: bad 'for' limit (number expected, got table)
* Back with optimization for 'if cond then goto'Roberto Ierusalimschy2018-10-302-1/+35
| | | | | | | | | | | | Statements like 'if cond then goto label' generate code so that the jump in the 'if' goes directly to the given label. This optimization cannot be done when the jump is backwards leaving the scope of some variable, as it cannot add the needed 'close' instruction. (The jumps were already generated by the 'if'.) This commit also added 'likely'/'unlikely' for tests for errors in the parser, and it changed the way breaks outside loops are detected. (Now they are detected like other goto's with undefined labels.)
* Big revamp in the implmentation of labels/gotosRoberto Ierusalimschy2018-10-292-14/+8
| | | | | | | | Added restriction that, when a label is created, there cannot be another label with the same name visible. That allows backward goto's to be resolved when they are read. Backward goto's get a close if they jump out of the scope of some variable; labels get a close only if previous goto to it jumps out of the scope of some upvalue.
* To-be-closed variables in the C APIRoberto Ierusalimschy2018-10-251-0/+71
|
* Closing methods should not interfere with returning valuesRoberto Ierusalimschy2018-10-251-1/+54
| | | | | | | | | | | | A closing method cannot be called in its own stack slot, as there may be returning values in the stack after that slot, and the call would corrupt those values. Instead, the closing method must be copied to the top of the stack to be called. Moreover, even when a function returns no value, its return istruction still has to have its position (which will set the stack top) after the local variables, otherwise a closing method might corrupt another not-yet-called closing method.
* Added a '__close' metamethod to file handlesRoberto Ierusalimschy2018-10-231-22/+35
|
* Removed extra information from RCS keyword strings in testsRoberto Ierusalimschy2018-10-226-4/+4
| | | | | Version numbers and dates (mostly wrong) from RCS keyword strings removed from all test files; only the file name are kept.
* Complete implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-222-9/+33
|
* Handling of memory errors when creating to-be-closed upvaluesRoberto Ierusalimschy2018-10-181-6/+52
|
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-172-6/+72
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-082-1/+14
| | | | | | | | | | | | Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
* Corrections in the implementation of '%' for floats.Roberto Ierusalimschy2018-08-281-1/+65
| | | | | | | | | The multiplication (m*b) used to test whether 'm' is non-zero and 'm' and 'b' have different signs can underflow for very small numbers, giving a wrong result. The use of explicit comparisons solves this problem. This commit also adds several new tests for '%' (both for floats and for integers) to exercise more corner cases, such as very large and very small values.
* Deprecated the emulation of '__le' using '__lt'Roberto Ierusalimschy2018-08-242-24/+18
| | | | | | | | | | | As hinted in the manual for Lua 5.3, the emulation of the metamethod for '__le' using '__le' has been deprecated. It is slow, complicates the logic, and it is easy to avoid this emulation by defining a proper '__le' function. Moreover, often this emulation was used wrongly, with a programmer assuming that an order is total when it is not (e.g., NaN in floating-point numbers).
* Added directory to test file names in '$Id:'Roberto Ierusalimschy2018-07-2529-29/+29
| | | | | | | From the point of view of 'git', all names are relative to the root directory of the project. So, file names in '$Id:' also should be relative to that directory: the proper name for test file 'all.lua' is 'testes/all.lua'.
* Fixed bug in generational collection of userdataRoberto Ierusalimschy2018-07-133-4/+87
| | | | | | | | | During generational collection, a userdatum must become gray and go to a gray list after being traversed (like tables), so that 'correctgraylist' can handle it to its next stage. This commit also added minimum tests for the generational collector, including one that would detect this bug.
* Fixed bug in line info. when using 'not' operatorRoberto Ierusalimschy2018-07-111-2/+19
| | | | | | | | | When creating code for a jump on a 'not' condition, the code generator was removing an instruction (the OP_NOT) without adjusting its corresponding line information. This fix also added tests for this case and extra functionality in the test library to debug line info. structures.
* In tests of opcodes, avoid coercion in bitwise operationRoberto Ierusalimschy2018-07-101-1/+1
|
* Fixed bug in OP_IDIVIRoberto Ierusalimschy2018-07-091-1/+12
| | | | | Opocode was using 'luai_numdiv' (float division) instead of 'luai_numidiv' (integer division).
* Added manual and tests for version 5.4-w2Roberto Ierusalimschy2018-07-0934-0/+13031