aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_window_cmd.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-28 21:01:36 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-02-28 21:17:42 +0800
commit1e513fd112767e57f2b39dfaa395c83cb4f6a9f7 (patch)
tree9f2b1d8e1c550ad8de0a54d20251014f81aa1883 /src/nvim/testdir/test_window_cmd.vim
parent65af4241996021b2067d2adc97cc2c83c616cbb6 (diff)
downloadrneovim-1e513fd112767e57f2b39dfaa395c83cb4f6a9f7.tar.gz
rneovim-1e513fd112767e57f2b39dfaa395c83cb4f6a9f7.tar.bz2
rneovim-1e513fd112767e57f2b39dfaa395c83cb4f6a9f7.zip
vim-patch:8.2.4670: memory allocation failures for new tab page not tested
Problem: Memory allocation failures for new tab page not tested. Solution: Add tests with failing memory allocation. (Yegappan Lakshmanan, closes vim/vim#10067) https://github.com/vim/vim/commit/72bb47e38f6805050ed6d969f17591bed71f83d4 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/testdir/test_window_cmd.vim')
-rw-r--r--src/nvim/testdir/test_window_cmd.vim46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index 8b9457ae1d..34614832a9 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -1525,6 +1525,52 @@ func Test_win_move_statusline()
%bwipe!
endfunc
+" Test for window allocation failure
+func Test_window_alloc_failure()
+ CheckFunction test_alloc_fail
+ %bw!
+
+ " test for creating a new window above current window
+ call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ call assert_fails('above new', 'E342:')
+ call assert_equal(1, winnr('$'))
+
+ " test for creating a new window below current window
+ call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ call assert_fails('below new', 'E342:')
+ call assert_equal(1, winnr('$'))
+
+ " test for popup window creation failure
+ call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ call assert_fails('call popup_create("Hello", {})', 'E342:')
+ call assert_equal([], popup_list())
+
+ call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ call assert_fails('split', 'E342:')
+ call assert_equal(1, winnr('$'))
+
+ edit Xfile1
+ edit Xfile2
+ call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ call assert_fails('sb Xfile1', 'E342:')
+ call assert_equal(1, winnr('$'))
+ call assert_equal('Xfile2', @%)
+ %bw!
+
+ " FIXME: The following test crashes Vim
+ " test for new tabpage creation failure
+ " call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
+ " call assert_fails('tabnew', 'E342:')
+ " call assert_equal(1, tabpagenr('$'))
+ " call assert_equal(1, winnr('$'))
+
+ " This test messes up the internal Vim window/frame information. So the
+ " Test_window_cmd_cmdwin_with_vsp() test fails after running this test.
+ " Open a new tab and close everything else to fix this issue.
+ tabnew
+ tabonly
+endfunc
+
func Test_win_equal_last_status()
let save_lines = &lines
set lines=20