# HG changeset patch # User Kim Alvefur # Date 1690036265 -7200 # Node ID ffe4adbd2af90b8778f2db1c824e2d7d3bbfbba8 # Parent 2902c54f45a6c84cddb587d8fa9eaf9049db6090 util.array: Fix new() library function diff -r 2902c54f45a6 -r ffe4adbd2af9 spec/util_array_spec.lua --- a/spec/util_array_spec.lua Sat Jul 22 16:20:36 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 2902c54f45a6 -r ffe4adbd2af9 util/array.lua --- a/util/array.lua Sat Jul 22 16:20:36 2023 +0200 +++ b/util/array.lua Sat Jul 22 16:31:05 2023 +0200 @@ -36,7 +36,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();