aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/buffer_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-06 18:16:57 -0700
committerGitHub <noreply@github.com>2019-09-06 18:16:57 -0700
commit158b78062e9daa65203b4591dae733dd6c11ad2c (patch)
treee6988da22f16062b57d50daeda084bcc489a6a1d /test/functional/api/buffer_spec.lua
parent638f2b6dee7439de303bea12dec80240617e8034 (diff)
parent7e1c9598617a140e40a0a22676c0631294617246 (diff)
downloadrneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.tar.gz
rneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.tar.bz2
rneovim-158b78062e9daa65203b4591dae733dd6c11ad2c.zip
Merge #10932 'test: Eliminate expect_err'
Diffstat (limited to 'test/functional/api/buffer_spec.lua')
-rw-r--r--test/functional/api/buffer_spec.lua32
1 files changed, 14 insertions, 18 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index 849fbedd01..da7515f012 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -10,11 +10,10 @@ local exc_exec = helpers.exc_exec
local feed_command = helpers.feed_command
local insert = helpers.insert
local NIL = helpers.NIL
-local meth_pcall = helpers.meth_pcall
local command = helpers.command
local bufmeths = helpers.bufmeths
local feed = helpers.feed
-local expect_err = helpers.expect_err
+local pcall_err = helpers.pcall_err
describe('api/buf', function()
before_each(clear)
@@ -191,17 +190,14 @@ describe('api/buf', function()
it('fails correctly when input is not valid', function()
eq(1, curbufmeths.get_number())
- local err, emsg = pcall(bufmeths.set_lines, 1, 1, 2, false, {'b\na'})
- eq(false, err)
- local exp_emsg = 'String cannot contain newlines'
- -- Expected {filename}:{lnum}: {exp_emsg}
- eq(': ' .. exp_emsg, emsg:sub(-#exp_emsg - 2))
+ eq([[String cannot contain newlines]],
+ pcall_err(bufmeths.set_lines, 1, 1, 2, false, {'b\na'}))
end)
it("fails if 'nomodifiable'", function()
command('set nomodifiable')
- expect_err([[Buffer is not 'modifiable']],
- bufmeths.set_lines, 1, 1, 2, false, {'a','b'})
+ eq([[Buffer is not 'modifiable']],
+ pcall_err(bufmeths.set_lines, 1, 1, 2, false, {'a','b'}))
end)
it('has correct line_count when inserting and deleting', function()
@@ -407,8 +403,8 @@ describe('api/buf', function()
eq(16, get_offset(3))
eq(24, get_offset(4))
eq(29, get_offset(5))
- eq({false,'Index out of bounds'}, meth_pcall(get_offset, 6))
- eq({false,'Index out of bounds'}, meth_pcall(get_offset, -1))
+ eq('Index out of bounds', pcall_err(get_offset, 6))
+ eq('Index out of bounds', pcall_err(get_offset, -1))
curbufmeths.set_option('eol', false)
curbufmeths.set_option('fixeol', false)
@@ -441,15 +437,15 @@ describe('api/buf', function()
eq(1, funcs.exists('b:lua'))
curbufmeths.del_var('lua')
eq(0, funcs.exists('b:lua'))
- eq({false, 'Key not found: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))
+ eq( 'Key not found: lua', pcall_err(curbufmeths.del_var, 'lua'))
curbufmeths.set_var('lua', 1)
command('lockvar b:lua')
- eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.del_var, 'lua'))
- eq({false, 'Key is locked: lua'}, meth_pcall(curbufmeths.set_var, 'lua', 1))
- eq({false, 'Key is read-only: changedtick'},
- meth_pcall(curbufmeths.del_var, 'changedtick'))
- eq({false, 'Key is read-only: changedtick'},
- meth_pcall(curbufmeths.set_var, 'changedtick', 1))
+ eq('Key is locked: lua', pcall_err(curbufmeths.del_var, 'lua'))
+ eq('Key is locked: lua', pcall_err(curbufmeths.set_var, 'lua', 1))
+ eq('Key is read-only: changedtick',
+ pcall_err(curbufmeths.del_var, 'changedtick'))
+ eq('Key is read-only: changedtick',
+ pcall_err(curbufmeths.set_var, 'changedtick', 1))
end)
end)