mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.array: Fix new() library function
Backport of ffe4adbd2af9 since new was added in the 0.12 branch
This commit is contained in:
parent
683b90f871
commit
0fa9d6be37
2 changed files with 10 additions and 1 deletions
|
@ -1,6 +1,13 @@
|
|||
local array = require "util.array";
|
||||
describe("util.array", function ()
|
||||
describe("creation", function ()
|
||||
describe("new", function ()
|
||||
it("works", function ()
|
||||
local a = array.new({"a", "b", "c"});
|
||||
assert.same({"a", "b", "c"}, a);
|
||||
end);
|
||||
end);
|
||||
|
||||
describe("from table", function ()
|
||||
it("works", function ()
|
||||
local a = array({"a", "b", "c"});
|
||||
|
|
|
@ -35,7 +35,9 @@ local function new_array(self, t, _s, _var)
|
|||
return setmetatable(t or {}, array_mt);
|
||||
end
|
||||
|
||||
array.new = new_array;
|
||||
function array.new(t)
|
||||
return setmetatable(t or {}, array_mt);
|
||||
end
|
||||
|
||||
function array_mt.__add(a1, a2)
|
||||
local res = new_array();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue