diff --git a/set-0.2.1-1.rockspec b/set-0.2.1-1.rockspec index cbd98d0..f58e1fc 100644 --- a/set-0.2.1-1.rockspec +++ b/set-0.2.1-1.rockspec @@ -13,7 +13,7 @@ description = { license = "LGPL+" } dependencies = { - "lua >= 5.2", + "lua >= 5.1", "lunitx >= 0.6" } build = { diff --git a/set-0.2.1-2.rockspec b/set-0.2.1-2.rockspec new file mode 100644 index 0000000..c47ae73 --- /dev/null +++ b/set-0.2.1-2.rockspec @@ -0,0 +1,25 @@ +package = "set" +version = "0.2.1-2" +source = { + url = "git://github.com/wscherphof/lua-set.git", + branch = "v0.2.1" +} +description = { + summary = "Straightforward Set library", + detailed = [[ + Creating and manipulating sets, including + (union), - (subtraction), * (intersection), len(), and tostring() + ]], + homepage = "http://wscherphof.github.io/lua-set/", + license = "LGPL+" +} +dependencies = { + "lua >= 5.1", + "lunitx >= 0.6" +} +build = { + type = "builtin", + copy_directories = {"doc", "tst"}, + modules = { + ["Set.init"] = "src/Set/init.lua" + } +} diff --git a/tst/init.lua b/tst/init.lua index c278bbc..5a6d45b 100644 --- a/tst/init.lua +++ b/tst/init.lua @@ -1,6 +1,6 @@ require("luarocks.loader") -- Omit next line in actual module clients; it's only to support development of the module itself -package.path = "../src/?/init.lua;" .. package.path +package.path = "../src/?/init.lua;" .. "./src/?/init.lua;" .. package.path local lunitx = require("lunitx") module("test_set", lunitx.testcase, package.seeall) @@ -36,7 +36,26 @@ end function test_tostring() assert_equal(Set.mt.__tostring(Set:new({1, 2, 3})), "{1, 2, 3}") assert_equal(9, #Set.mt.__tostring(Set:new({"a", "b", "c"})), "{a, b, c} (or in a different permutation)") - assert_equal(23, #Set.mt.__tostring(Set:new({ {} })), "{table: 0x7ff498c52ea0} (but a different same-length key)") + local expected_length; + -- this will be 18 on lua5.2, 19 on luajit, and either 17 or 18 on lua5.1 randomly + -- those numbers might totally change on a 32 bit architecture. + expected_length = #(tostring({}))+2; + if _VERSION == 'Lua 5.1' then + if jit then + weird = 19 ~= expected_length; + else + if(expected_length ~= 17 and expected_length ~= 18) then + weird = true + end + end + else + weird = 18 ~= expected_length + end + if weird then + print('Warning: expected_length of tostring(table) was sort of weird: '..expected_length) + end + + assert_equal(expected_length, #Set.mt.__tostring(Set:new({ {} })), "{table: 0x7ff498c52ea0} (but a different same-length key)") end function test_new_len()