# HG changeset patch # User Kim Alvefur # Date 1690036265 -7200 # Node ID 1bb4aa803b323f8ce478011223bb246135ce424a # Parent 22763b30e4582c0ca66acc4b98208e4eb34fe11f util.array: Fix new() library function Backport of ffe4adbd2af9 since new was added in the 0.12 branch diff -r 22763b30e458 -r 1bb4aa803b32 spec/util_array_spec.lua --- a/spec/util_array_spec.lua Mon Jul 17 14:56:57 2023 +0200 +++ b/spec/util_array_spec.lua Sat Jul 22 16:31:05 2023 +0200 @@ -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"}); diff -r 22763b30e458 -r 1bb4aa803b32 util/array.lua --- a/util/array.lua Mon Jul 17 14:56:57 2023 +0200 +++ b/util/array.lua Sat Jul 22 16:31:05 2023 +0200 @@ -35,7 +35,9 @@ 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();