@@ -168,19 +168,6 @@ misc.to_vimindex = function(text, utfindex)
|
||||
return utfindex + 1
|
||||
end
|
||||
|
||||
---Return readonly version object
|
||||
---@generic T
|
||||
---@param tbl T
|
||||
---@return T
|
||||
misc.readonly = function(tbl)
|
||||
return setmetatable({}, {
|
||||
__index = tbl,
|
||||
__newindex = function()
|
||||
error('this table is readonly.')
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
---Mark the function as deprecated
|
||||
misc.deprecated = function(fn, msg)
|
||||
local printed = false
|
||||
|
||||
@@ -49,12 +49,4 @@ describe('misc', function()
|
||||
assert.are.equal(merged.a, nil)
|
||||
end)
|
||||
|
||||
it('readonly', function()
|
||||
local o = { a = 1, b = 2 }
|
||||
local r = misc.readonly(o)
|
||||
assert.are.equal(r.a, 1)
|
||||
assert.has_error(function()
|
||||
r.a = 5
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user