aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/excmd_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-12 12:18:10 +0800
committerGitHub <noreply@github.com>2022-07-12 12:18:10 +0800
commit540d1af90e2276a8bd3b5edb1a63c8225a1aa423 (patch)
treea5d15ea92d0197cd0f5c3b08d6c95071fc0913ba /test/functional/legacy/excmd_spec.lua
parent034d28c705ccb93dea27613cbf91ba3f9c1caaa7 (diff)
parent53392f48b1e258bc11afdad7104930d7c1a361da (diff)
downloadrneovim-540d1af90e2276a8bd3b5edb1a63c8225a1aa423.tar.gz
rneovim-540d1af90e2276a8bd3b5edb1a63c8225a1aa423.tar.bz2
rneovim-540d1af90e2276a8bd3b5edb1a63c8225a1aa423.zip
Merge pull request #19330 from zeertzjq/vim-8.2.0203
vim-patch:8.2.0203: :helptags and some other functionality not tested
Diffstat (limited to 'test/functional/legacy/excmd_spec.lua')
-rw-r--r--test/functional/legacy/excmd_spec.lua156
1 files changed, 156 insertions, 0 deletions
diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua
index 174f7d292e..6b3b265579 100644
--- a/test/functional/legacy/excmd_spec.lua
+++ b/test/functional/legacy/excmd_spec.lua
@@ -1,9 +1,15 @@
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
+local command = helpers.command
local exec_lua = helpers.exec_lua
+local feed = helpers.feed
local meths = helpers.meths
+local poke_eventloop = helpers.poke_eventloop
+local read_file = helpers.read_file
local source = helpers.source
local eq = helpers.eq
+local write_file = helpers.write_file
local function sizeoflong()
if not exec_lua('return pcall(require, "ffi")') then
@@ -30,3 +36,153 @@ describe('Ex command', function()
]]
end)
end)
+
+it(':confirm command dialog', function()
+ local screen
+
+ local function start_new()
+ clear()
+ screen = Screen.new(60, 20)
+ screen:attach()
+ end
+
+ write_file('foo', 'foo1\n')
+ write_file('bar', 'bar1\n')
+
+ -- Test for saving all the modified buffers
+ start_new()
+ command("set nomore")
+ command("new foo")
+ command("call setline(1, 'foo2')")
+ command("new bar")
+ command("call setline(1, 'bar2')")
+ command("wincmd b")
+ feed(':confirm qall\n')
+ screen:expect([[
+ bar2 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ bar [+] |
+ foo2 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ foo [+] |
+ |
+ ~ |
+ ~ |
+ |
+ :confirm qall |
+ Save changes to "bar"? |
+ [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ |
+ ]])
+ feed('A')
+ poke_eventloop()
+
+ eq('foo2\n', read_file('foo'))
+ eq('bar2\n', read_file('bar'))
+
+ -- Test for discarding all the changes to modified buffers
+ start_new()
+ command("set nomore")
+ command("new foo")
+ command("call setline(1, 'foo3')")
+ command("new bar")
+ command("call setline(1, 'bar3')")
+ command("wincmd b")
+ feed(':confirm qall\n')
+ screen:expect([[
+ bar3 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ bar [+] |
+ foo3 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ foo [+] |
+ |
+ ~ |
+ ~ |
+ |
+ :confirm qall |
+ Save changes to "bar"? |
+ [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ |
+ ]])
+ feed('D')
+ poke_eventloop()
+
+ eq('foo2\n', read_file('foo'))
+ eq('bar2\n', read_file('bar'))
+
+ -- Test for saving and discarding changes to some buffers
+ start_new()
+ command("set nomore")
+ command("new foo")
+ command("call setline(1, 'foo4')")
+ command("new bar")
+ command("call setline(1, 'bar4')")
+ command("wincmd b")
+ feed(':confirm qall\n')
+ screen:expect([[
+ bar4 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ bar [+] |
+ foo4 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ foo [+] |
+ |
+ ~ |
+ ~ |
+ |
+ :confirm qall |
+ Save changes to "bar"? |
+ [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ |
+ ]])
+ feed('N')
+ screen:expect([[
+ bar4 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ bar [+] |
+ foo4 |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ foo [+] |
+ |
+ |
+ :confirm qall |
+ Save changes to "bar"? |
+ |
+ Save changes to "foo"? |
+ [Y]es, (N)o, (C)ancel: ^ |
+ ]])
+ feed('Y')
+ poke_eventloop()
+
+ eq('foo4\n', read_file('foo'))
+ eq('bar2\n', read_file('bar'))
+
+ os.remove('foo')
+ os.remove('bar')
+end)