Mercurial > vim
comparison src/testdir/test_window_cmd.vim @ 19748:d089bd9511c0 v8.2.0430
patch 8.2.0430: window creation failure not properly tested
Commit: https://github.com/vim/vim/commit/5080b0a0470511bae6176a704d4591d1caba0d07
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 22 21:23:47 2020 +0100
patch 8.2.0430: window creation failure not properly tested
Problem: Window creation failure not properly tested.
Solution: Improve the test. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5826)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 22 Mar 2020 21:30:04 +0100 |
parents | a653d1a165ef |
children | 0927df746554 |
comparison
equal
deleted
inserted
replaced
19747:1f4dc8bc8b24 | 19748:d089bd9511c0 |
---|---|
1005 call assert_equal(1, &readonly) | 1005 call assert_equal(1, &readonly) |
1006 call assert_equal(2, winnr('$')) | 1006 call assert_equal(2, winnr('$')) |
1007 close | 1007 close |
1008 endfunc | 1008 endfunc |
1009 | 1009 |
1010 " Create maximum number of horizontally or vertically split windows and then | |
1011 " run commands that create a new horizontally/vertically split window | |
1012 func Run_noroom_for_newwindow_test(dir_arg) | |
1013 let dir = (a:dir_arg == 'v') ? 'vert ' : '' | |
1014 | |
1015 " Open as many windows as possible | |
1016 for i in range(500) | |
1017 try | |
1018 exe dir . 'new' | |
1019 catch /E36:/ | |
1020 break | |
1021 endtry | |
1022 endfor | |
1023 | |
1024 call writefile(['first', 'second', 'third'], 'Xfile1') | |
1025 call writefile([], 'Xfile2') | |
1026 call writefile([], 'Xfile3') | |
1027 | |
1028 " Argument list related commands | |
1029 args Xfile1 Xfile2 Xfile3 | |
1030 next | |
1031 for cmd in ['sargument 2', 'snext', 'sprevious', 'sNext', 'srewind', | |
1032 \ 'sfirst', 'slast'] | |
1033 call assert_fails(dir .. cmd, 'E36:') | |
1034 endfor | |
1035 %argdelete | |
1036 | |
1037 " Buffer related commands | |
1038 set modified | |
1039 hide enew | |
1040 for cmd in ['sbuffer Xfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind', | |
1041 \ 'sbfirst', 'sblast', 'sball', 'sbmodified', 'sunhide'] | |
1042 call assert_fails(dir .. cmd, 'E36:') | |
1043 endfor | |
1044 | |
1045 " Window related commands | |
1046 for cmd in ['split', 'split Xfile2', 'new', 'new Xfile3', 'sview Xfile1', | |
1047 \ 'sfind runtest.vim'] | |
1048 call assert_fails(dir .. cmd, 'E36:') | |
1049 endfor | |
1050 | |
1051 " Help | |
1052 call assert_fails(dir .. 'help', 'E36:') | |
1053 call assert_fails(dir .. 'helpgrep window', 'E36:') | |
1054 | |
1055 " Command-line window | |
1056 if a:dir_arg == 'h' | |
1057 " Cmd-line window is always a horizontally split window | |
1058 call assert_beeps('call feedkeys("q:\<CR>", "xt")') | |
1059 endif | |
1060 | |
1061 " Quickfix and location list window | |
1062 if has('quickfix') | |
1063 cexpr '' | |
1064 call assert_fails(dir .. 'copen', 'E36:') | |
1065 lexpr '' | |
1066 call assert_fails(dir .. 'lopen', 'E36:') | |
1067 | |
1068 " Preview window | |
1069 call assert_fails(dir .. 'pedit Xfile2', 'E36:') | |
1070 call setline(1, 'abc') | |
1071 call assert_fails(dir .. 'psearch abc', 'E36:') | |
1072 endif | |
1073 | |
1074 " Window commands (CTRL-W ^ and CTRL-W f) | |
1075 if a:dir_arg == 'h' | |
1076 call assert_fails('call feedkeys("\<C-W>^", "xt")', 'E36:') | |
1077 call setline(1, 'Xfile1') | |
1078 call assert_fails('call feedkeys("gg\<C-W>f", "xt")', 'E36:') | |
1079 endif | |
1080 enew! | |
1081 | |
1082 " Tag commands (:stag, :stselect and :stjump) | |
1083 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | |
1084 \ "second\tXfile1\t2", | |
1085 \ "third\tXfile1\t3",], | |
1086 \ 'Xtags') | |
1087 set tags=Xtags | |
1088 call assert_fails(dir .. 'stag second', 'E36:') | |
1089 call assert_fails('call feedkeys(":" .. dir .. "stselect second\n1\n", "xt")', 'E36:') | |
1090 call assert_fails(dir .. 'stjump second', 'E36:') | |
1091 call assert_fails(dir .. 'ptag second', 'E36:') | |
1092 set tags& | |
1093 call delete('Xtags') | |
1094 | |
1095 " :isplit and :dsplit | |
1096 call setline(1, ['#define FOO 1', 'FOO']) | |
1097 normal 2G | |
1098 call assert_fails(dir .. 'isplit FOO', 'E36:') | |
1099 call assert_fails(dir .. 'dsplit FOO', 'E36:') | |
1100 | |
1101 " terminal | |
1102 if has('terminal') | |
1103 call assert_fails(dir .. 'terminal', 'E36:') | |
1104 endif | |
1105 | |
1106 %bwipe! | |
1107 call delete('Xfile1') | |
1108 call delete('Xfile2') | |
1109 call delete('Xfile3') | |
1110 only | |
1111 endfunc | |
1112 | |
1113 func Test_split_cmds_with_no_room() | |
1114 call Run_noroom_for_newwindow_test('h') | |
1115 call Run_noroom_for_newwindow_test('v') | |
1116 endfunc | |
1117 | |
1010 " vim: shiftwidth=2 sts=2 expandtab | 1118 " vim: shiftwidth=2 sts=2 expandtab |