test: Rename meth_pcall to pcall_err

- Rename `meth_pcall`.
- Make `pcall_err` raise an error if the function does not fail.
- Add `vim.pesc()` to treat a string as literal where a Lua pattern is
  expected.
This commit is contained in:
Justin M. Keyes
2019-09-03 22:51:45 +02:00
parent 638f2b6dee
commit af946046b9
13 changed files with 124 additions and 112 deletions

View File

@@ -178,9 +178,20 @@ local function trim(s)
return s:match('^%s*(.*%S)') or ''
end
--- Escapes magic chars in a Lua pattern string.
---
--@see https://github.com/rxi/lume
--@param s String to escape
--@returns %-escaped pattern string
local function pesc(s)
assert(type(s) == 'string')
return s:gsub('[%(%)%.%%%+%-%*%?%[%]%^%$]', '%%%1')
end
local module = {
deepcopy = deepcopy,
gsplit = gsplit,
pesc = pesc,
split = split,
tbl_contains = tbl_contains,
tbl_extend = tbl_extend,