[lua] Fix bug comparing integers and floating points (fix #4516)

This bug was introduced in:

  db8284f5fc

We've removed the patch in our updated Lua v5.4.6 branch.
This commit is contained in:
David Capello 2024-06-03 11:29:15 -03:00
parent d72be3f354
commit 7ce9f85b39
6 changed files with 19 additions and 6 deletions

2
laf

@ -1 +1 @@
Subproject commit 4a2e2bb3d91ea5f00d2aac17477bc06434a89e14
Subproject commit c82fd98b275cb25122106797af00feabc5015c7f

View File

@ -50,6 +50,13 @@ FILE* lua_user_fopen(const char* fname,
return base::open_file_raw(fname, mode);
}
FILE* lua_user_freopen(const char* fname,
const char* mode,
FILE* stream)
{
return base::reopen_file_raw(fname, mode, stream);
}
namespace app {
namespace script {

View File

@ -8,3 +8,9 @@ assert(100 == math.min(100, 200, 300))
assert(300 == math.max(100, 200, 300))
assert(50 == math.fmod(250, 100))
assert(3141 == math.floor(1000*math.pi))
-- Add tests for integer <-> number comparisons
assert(math.floor(0.5) == 0)
assert(math.floor(0.5) == 0.0)
assert(math.floor(0.5) ~= 0.5)
assert(math.floor(0.5)+0.1-0.1 ~= 0.5)

View File

@ -133,8 +133,8 @@ for _,cm in ipairs{ ColorMode.RGB,
app.sprite = spr
app.command.SaveFileCopyAs{ filename=fn, slice="small_slice", scale=scale }
local c = app.open(fn)
assert(c.width == slice.bounds.width*scale)
assert(c.height == slice.bounds.height*scale)
assert(c.width == math.floor(slice.bounds.width*scale))
assert(c.height == math.floor(slice.bounds.height*scale))
local testImg = Image(spr.cels[1].image, spr.slices[1].bounds)
fix_images(testImg, scale, fileExt, c, cm, c1)

View File

@ -21,8 +21,8 @@ do
a:resize(6, 8)
assert(a.width == 6)
assert(a.height == 8)
assert(a.cels[1].image.width == 32 * 6 / 4) -- Check that the image was resized (not only the canvas)
assert(a.cels[1].image.height == 64 * 8 / 5)
assert(a.cels[1].image.width == math.floor(32 * 6 / 4)) -- Check that the image was resized (not only the canvas)
assert(a.cels[1].image.height == math.floor(64 * 8 / 5))
a:crop{x=-1, y=-1, width=20, height=30}
assert(a.width == 20)
assert(a.height == 30)

2
third_party/lua vendored

@ -1 +1 @@
Subproject commit 04abf20c9e8c973c62b30d0b98f6884ff665b1ba
Subproject commit 2a00e6b0013f54ce80b6e3cefe6514e13229987a