* Space Lua: `<close>` attribute, `__close` metamethod and extensive tests
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Space Lua: Align arithmetical error messages with Lua 5.4
**Fixes:**
- Tighten `tonumber` semantics to accept hex floats like `0x1.2` while
keeping plain hex as integers.
- Improve Lua compatibility by fixing relational `>`/`>=` operand
ordering to preserve correct error type direction.
**Changes:**
- Update concatenation errors to include the operand type.
- Add `LuaStringCoercionError` from numeric coercion and handle it
in `luaOp()` to emit correct messages (or fallback).
- Raise
> `bad argument #2 to 'tonumber' (base out of range)`
for invalid bases.
- Update test suite
**Notes:**
- The `arithmetic_test.lua` test suite now passes if run with Lua 5.4.
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Run `make fmt`
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Rename `assert_throws` to `assertThrows` in Lua test suite
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Replace `LuaStringCoercionError` class with sentinel constant
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
---------
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Align Space Lua arithmetic model with standard Lua
* Add missing __unm and __bnot metamethods
- add new basic tests
- add helper for negative tests
* Add comments for ASCII numeric constants
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
This patch fixes the Lua arithmetic model at parser level only. Runtime
level fixtures are left for future work.
MOTIVATION
Space Lua treats all numbers as IEEE-754 doubles (JS semantics), so it
preserves negative zero. Lua uses integers and floats. The literal "-0"
in Lua is parsed as unary minus applied to the integer literal "0",
which yields the integer "0" (no sign). This difference flips the sign
of the divisor in "1/-0" and "-1/-0". Although it could be fixed without
touching the parser by changing only unary minus evaluation, this commit
goes a little further and provides integer vs float differenciating at
the parser level as well uses it to fix the unary minus evaluation.
Extensive tests are added to test this exact change works and the Space
Lua arithmetic model is aligned with Lua. Note that things like `-(expr)`
in general may still produce results inconsistent with Lua. This cannot
be fixed at parser level and must be fixed at runtime level which will
need far more complex change to the Space Lua interpreter code. Therefor
these cases we omitted from the tests.
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>