whitequark / rlua

Ruby to Lua bindings library.
http://whitequark.github.com/rlua/
MIT License
27 stars 10 forks source link

Fix/lua5.3 integer and lib loading #12

Closed hugopeixoto closed 4 years ago

hugopeixoto commented 4 years ago

11 broke some functionalities.

Lua 5.1 luaopen_* functions did all the job of setting the global name. In 5.3 the loading mechanism changed a bit. This caused no global name being set (__load_stdib(:debug) didn't set a debug variable).

Lua 5.3 added support for integers, as a subtype of number. They're now enforcing next() in arrays to receive integer keys, and rlua was converting numbers to floats, which broke Lua::Table#each.

Added some tests for both breakages.

whitequark commented 4 years ago

Looks like CI is failing.

hugopeixoto commented 4 years ago

Had some trouble figuring it out.

I was using value = 10000000000000000 to test for larger than 2**64 numbers. In Lua 5.3.1 this overflowed and set the constant to a valid integer. In Lua 5.3.3 this was fixed. 5.3.3 is not available in Ubuntu Xenial. I ended up removing the test, as it was kind of redundant with the value = 1.0 test.

I had some extra troubles with the current set of ruby versions (1.9.3 - 2.3.0). Ruby changed its integer classes from Fixnum and Bignum to Integer only. I changed the test from .class == Integer to .integer? to be able to test this in both old and new versions.

I also relaxed the bundler version spec from ~> 1.10 to >= 1.10 to be able to use 2.x in recent ruby versions.