aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/buffer_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-23 11:24:46 +0800
committerGitHub <noreply@github.com>2022-08-23 11:24:46 +0800
commit63df91c10a7ec492adae91c78cb51eb231c77d89 (patch)
treef9fd327fa6494d5a9ffe4440531a4814a2fd89c9 /test/functional/legacy/buffer_spec.lua
parentd5328ea408d93d53b46417a65ca3b2fc99ab64b6 (diff)
downloadrneovim-63df91c10a7ec492adae91c78cb51eb231c77d89.tar.gz
rneovim-63df91c10a7ec492adae91c78cb51eb231c77d89.tar.bz2
rneovim-63df91c10a7ec492adae91c78cb51eb231c77d89.zip
vim-patch:8.2.1046: insufficient tests for src/buffer.c (#19903)
Problem: Insufficient tests for src/buffer.c. Solution: Add more tests. Move comments related tests to a separate file. (Yegappan Lakshmanan, closes vim/vim#6325) https://github.com/vim/vim/commit/b7e2483655d9b68df0c7349918027d800051a28a
Diffstat (limited to 'test/functional/legacy/buffer_spec.lua')
-rw-r--r--test/functional/legacy/buffer_spec.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua
new file mode 100644
index 0000000000..acaa9a51f1
--- /dev/null
+++ b/test/functional/legacy/buffer_spec.lua
@@ -0,0 +1,59 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, source = helpers.clear, helpers.source
+local call, eq, meths = helpers.call, helpers.eq, helpers.meths
+
+local function expected_empty()
+ eq({}, meths.get_vvar('errors'))
+end
+
+describe('buffer', function()
+ before_each(function()
+ clear()
+ meths.ui_attach(80, 24, {})
+ meths.set_option('hidden', false)
+ end)
+
+ it('deleting a modified buffer with :confirm', function()
+ source([[
+ func Test_bdel_with_confirm()
+ new
+ call setline(1, 'test')
+ call assert_fails('bdel', 'E89:')
+ call nvim_input('c')
+ confirm bdel
+ call assert_equal(2, winnr('$'))
+ call assert_equal(1, &modified)
+ call nvim_input('n')
+ confirm bdel
+ call assert_equal(1, winnr('$'))
+ endfunc
+ ]])
+ call('Test_bdel_with_confirm')
+ expected_empty()
+ end)
+
+ it('editing another buffer from a modified buffer with :confirm', function()
+ source([[
+ func Test_goto_buf_with_confirm()
+ new Xfile
+ enew
+ call setline(1, 'test')
+ call assert_fails('b Xfile', 'E37:')
+ call nvim_input('c')
+ call assert_fails('confirm b Xfile', 'E37:')
+ call assert_equal(1, &modified)
+ call assert_equal('', @%)
+ call nvim_input('y')
+ call assert_fails('confirm b Xfile', 'E37:')
+ call assert_equal(1, &modified)
+ call assert_equal('', @%)
+ call nvim_input('n')
+ confirm b Xfile
+ call assert_equal('Xfile', @%)
+ close!
+ endfunc
+ ]])
+ call('Test_goto_buf_with_confirm')
+ expected_empty()
+ end)
+end)