comparison src/testdir/test_search.vim @ 30769:ae10b91ac6b3 v9.0.0719

patch 9.0.0719: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/56564964e6d0956c29687e8a10cb94fe42f5c097 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 10 22:39:42 2022 +0100 patch 9.0.0719: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Mon, 10 Oct 2022 23:45:04 +0200
parents 6e7b9156b08f
children d80066065462
comparison
equal deleted inserted replaced
30768:97a37fa9b03c 30769:ae10b91ac6b3
722 if h < 3 722 if h < 3
723 return 723 return
724 endif 724 endif
725 " Prepare buffer text 725 " Prepare buffer text
726 let lines = ['abb vim vim vi', 'vimvivim'] 726 let lines = ['abb vim vim vi', 'vimvivim']
727 call writefile(lines, 'Xsearch.txt') 727 call writefile(lines, 'Xsearch.txt', 'D')
728 let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3}) 728 let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
729 729
730 call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])}) 730 call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
731 731
732 call term_sendkeys(buf, ":set incsearch hlsearch\<cr>") 732 call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
741 call assert_notequal(a0, a1) 741 call assert_notequal(a0, a1)
742 call assert_notequal(a0, a3) 742 call assert_notequal(a0, a3)
743 call assert_notequal(a1, a2) 743 call assert_notequal(a1, a2)
744 call assert_equal(a0, a2) 744 call assert_equal(a0, a2)
745 call assert_equal(a1, a3) 745 call assert_equal(a1, a3)
746
746 " clean up 747 " clean up
747 call delete('Xsearch.txt')
748
749 bwipe! 748 bwipe!
750 endfunc 749 endfunc
751 750
752 " Tests for regexp with various magic settings 751 " Tests for regexp with various magic settings
753 func Run_search_regexp_magic_opt() 752 func Run_search_regexp_magic_opt()
857 return 856 return
858 endif 857 endif
859 858
860 " Prepare buffer text 859 " Prepare buffer text
861 let lines = ['abb vim vim vi', 'vimvivim'] 860 let lines = ['abb vim vim vi', 'vimvivim']
862 call writefile(lines, 'Xsearch.txt') 861 call writefile(lines, 'Xsearch.txt', 'D')
863 let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3}) 862 let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
864 863
865 call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])}) 864 call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
866 " wait for vim to complete initialization 865 " wait for vim to complete initialization
867 call TermWait(buf) 866 call TermWait(buf)
926 call TermWait(buf, 100) 925 call TermWait(buf, 100)
927 let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0] 926 let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0]
928 let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0] 927 let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0]
929 call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr')) 928 call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
930 call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr')) 929 call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
931 call delete('Xsearch.txt') 930
932
933 call delete('Xsearch.txt')
934 bwipe! 931 bwipe!
935 endfunc 932 endfunc
936 933
937 func Test_incsearch_cmdline_modifier() 934 func Test_incsearch_cmdline_modifier()
938 CheckOption incsearch 935 CheckOption incsearch
954 \ 'let dots = repeat(".", 120)', 951 \ 'let dots = repeat(".", 120)',
955 \ 'set incsearch cmdheight=2 scrolloff=0', 952 \ 'set incsearch cmdheight=2 scrolloff=0',
956 \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])', 953 \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
957 \ 'normal gg', 954 \ 'normal gg',
958 \ 'redraw', 955 \ 'redraw',
959 \ ], 'Xscript') 956 \ ], 'Xscript', 'D')
960 let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70}) 957 let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
961 " Need to send one key at a time to force a redraw 958 " Need to send one key at a time to force a redraw
962 call term_sendkeys(buf, '/') 959 call term_sendkeys(buf, '/')
963 sleep 100m 960 sleep 100m
964 call term_sendkeys(buf, 't') 961 call term_sendkeys(buf, 't')
970 call term_sendkeys(buf, 'g') 967 call term_sendkeys(buf, 'g')
971 call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {}) 968 call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
972 969
973 call term_sendkeys(buf, "\<Esc>") 970 call term_sendkeys(buf, "\<Esc>")
974 call StopVimInTerminal(buf) 971 call StopVimInTerminal(buf)
975 call delete('Xscript')
976 endfunc 972 endfunc
977 973
978 func Test_incsearch_search_dump() 974 func Test_incsearch_search_dump()
979 CheckOption incsearch 975 CheckOption incsearch
980 CheckScreendump 976 CheckScreendump
983 \ 'set incsearch hlsearch scrolloff=0', 979 \ 'set incsearch hlsearch scrolloff=0',
984 \ 'for n in range(1, 8)', 980 \ 'for n in range(1, 8)',
985 \ ' call setline(n, "foo " . n)', 981 \ ' call setline(n, "foo " . n)',
986 \ 'endfor', 982 \ 'endfor',
987 \ '3', 983 \ '3',
988 \ ], 'Xis_search_script') 984 \ ], 'Xis_search_script', 'D')
989 let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70}) 985 let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70})
990 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 986 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
991 " the 'ambiwidth' check. 987 " the 'ambiwidth' check.
992 sleep 100m 988 sleep 100m
993 989
1000 call term_sendkeys(buf, '/\v') 996 call term_sendkeys(buf, '/\v')
1001 call VerifyScreenDump(buf, 'Test_incsearch_search_02', {}) 997 call VerifyScreenDump(buf, 'Test_incsearch_search_02', {})
1002 call term_sendkeys(buf, "\<Esc>") 998 call term_sendkeys(buf, "\<Esc>")
1003 999
1004 call StopVimInTerminal(buf) 1000 call StopVimInTerminal(buf)
1005 call delete('Xis_search_script')
1006 endfunc 1001 endfunc
1007 1002
1008 func Test_hlsearch_dump() 1003 func Test_hlsearch_dump()
1009 CheckOption hlsearch 1004 CheckOption hlsearch
1010 CheckScreendump 1005 CheckScreendump
1012 call writefile([ 1007 call writefile([
1013 \ 'set hlsearch cursorline', 1008 \ 'set hlsearch cursorline',
1014 \ 'call setline(1, ["xxx", "xxx", "xxx"])', 1009 \ 'call setline(1, ["xxx", "xxx", "xxx"])',
1015 \ '/.*', 1010 \ '/.*',
1016 \ '2', 1011 \ '2',
1017 \ ], 'Xhlsearch_script') 1012 \ ], 'Xhlsearch_script', 'D')
1018 let buf = RunVimInTerminal('-S Xhlsearch_script', {'rows': 6, 'cols': 50}) 1013 let buf = RunVimInTerminal('-S Xhlsearch_script', {'rows': 6, 'cols': 50})
1019 call VerifyScreenDump(buf, 'Test_hlsearch_1', {}) 1014 call VerifyScreenDump(buf, 'Test_hlsearch_1', {})
1020 1015
1021 call term_sendkeys(buf, "/\\_.*\<CR>") 1016 call term_sendkeys(buf, "/\\_.*\<CR>")
1022 call VerifyScreenDump(buf, 'Test_hlsearch_2', {}) 1017 call VerifyScreenDump(buf, 'Test_hlsearch_2', {})
1023 1018
1024 call StopVimInTerminal(buf) 1019 call StopVimInTerminal(buf)
1025 call delete('Xhlsearch_script')
1026 endfunc 1020 endfunc
1027 1021
1028 func Test_hlsearch_and_visual() 1022 func Test_hlsearch_and_visual()
1029 CheckOption hlsearch 1023 CheckOption hlsearch
1030 CheckScreendump 1024 CheckScreendump
1033 \ 'set hlsearch', 1027 \ 'set hlsearch',
1034 \ 'call setline(1, repeat(["xxx yyy zzz"], 3))', 1028 \ 'call setline(1, repeat(["xxx yyy zzz"], 3))',
1035 \ 'hi Search cterm=bold', 1029 \ 'hi Search cterm=bold',
1036 \ '/yyy', 1030 \ '/yyy',
1037 \ 'call cursor(1, 6)', 1031 \ 'call cursor(1, 6)',
1038 \ ], 'Xhlvisual_script') 1032 \ ], 'Xhlvisual_script', 'D')
1039 let buf = RunVimInTerminal('-S Xhlvisual_script', {'rows': 6, 'cols': 40}) 1033 let buf = RunVimInTerminal('-S Xhlvisual_script', {'rows': 6, 'cols': 40})
1040 call term_sendkeys(buf, "vjj") 1034 call term_sendkeys(buf, "vjj")
1041 call VerifyScreenDump(buf, 'Test_hlsearch_visual_1', {}) 1035 call VerifyScreenDump(buf, 'Test_hlsearch_visual_1', {})
1042 call term_sendkeys(buf, "\<Esc>") 1036 call term_sendkeys(buf, "\<Esc>")
1043 1037
1044 call StopVimInTerminal(buf) 1038 call StopVimInTerminal(buf)
1045 call delete('Xhlvisual_script')
1046 endfunc 1039 endfunc
1047 1040
1048 func Test_hlsearch_block_visual_match() 1041 func Test_hlsearch_block_visual_match()
1049 CheckScreendump 1042 CheckScreendump
1050 1043
1051 let lines =<< trim END 1044 let lines =<< trim END
1052 set hlsearch 1045 set hlsearch
1053 call setline(1, ['aa', 'bbbb', 'cccccc']) 1046 call setline(1, ['aa', 'bbbb', 'cccccc'])
1054 END 1047 END
1055 call writefile(lines, 'Xhlsearch_block') 1048 call writefile(lines, 'Xhlsearch_block', 'D')
1056 let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60}) 1049 let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60})
1057 1050
1058 call term_sendkeys(buf, "G\<C-V>$kk\<Esc>") 1051 call term_sendkeys(buf, "G\<C-V>$kk\<Esc>")
1059 sleep 100m 1052 sleep 100m
1060 call term_sendkeys(buf, "/\\%V\<CR>") 1053 call term_sendkeys(buf, "/\\%V\<CR>")
1061 sleep 100m 1054 sleep 100m
1062 call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {}) 1055 call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {})
1063 1056
1064 call StopVimInTerminal(buf) 1057 call StopVimInTerminal(buf)
1065 call delete('Xhlsearch_block')
1066 endfunc 1058 endfunc
1067 1059
1068 func Test_incsearch_substitute() 1060 func Test_incsearch_substitute()
1069 CheckOption incsearch 1061 CheckOption incsearch
1070 1062
1106 set hlsearch scrolloff=0 1098 set hlsearch scrolloff=0
1107 call setline(1, ['one', 'foo', 'bar', 'baz', 'foo the foo and foo', 'bar']) 1099 call setline(1, ['one', 'foo', 'bar', 'baz', 'foo the foo and foo', 'bar'])
1108 hi Search ctermbg=yellow 1100 hi Search ctermbg=yellow
1109 hi CurSearch ctermbg=blue 1101 hi CurSearch ctermbg=blue
1110 END 1102 END
1111 call writefile(lines, 'Xhlsearch_cursearch') 1103 call writefile(lines, 'Xhlsearch_cursearch', 'D')
1112 let buf = RunVimInTerminal('-S Xhlsearch_cursearch', {'rows': 9, 'cols': 60}) 1104 let buf = RunVimInTerminal('-S Xhlsearch_cursearch', {'rows': 9, 'cols': 60})
1113 1105
1114 call term_sendkeys(buf, "gg/foo\<CR>") 1106 call term_sendkeys(buf, "gg/foo\<CR>")
1115 call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_1', {}) 1107 call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_1', {})
1116 1108
1144 call term_sendkeys(buf, "G?^abcd\<CR>Y") 1136 call term_sendkeys(buf, "G?^abcd\<CR>Y")
1145 call term_sendkeys(buf, "kkP") 1137 call term_sendkeys(buf, "kkP")
1146 call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {}) 1138 call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {})
1147 1139
1148 call StopVimInTerminal(buf) 1140 call StopVimInTerminal(buf)
1149 call delete('Xhlsearch_cursearch')
1150 endfunc 1141 endfunc
1151 1142
1152 " Similar to Test_incsearch_substitute() but with a screendump halfway. 1143 " Similar to Test_incsearch_substitute() but with a screendump halfway.
1153 func Test_incsearch_substitute_dump() 1144 func Test_incsearch_substitute_dump()
1154 CheckOption incsearch 1145 CheckOption incsearch
1159 \ 'for n in range(1, 10)', 1150 \ 'for n in range(1, 10)',
1160 \ ' call setline(n, "foo " . n)', 1151 \ ' call setline(n, "foo " . n)',
1161 \ 'endfor', 1152 \ 'endfor',
1162 \ 'call setline(11, "bar 11")', 1153 \ 'call setline(11, "bar 11")',
1163 \ '3', 1154 \ '3',
1164 \ ], 'Xis_subst_script') 1155 \ ], 'Xis_subst_script', 'D')
1165 let buf = RunVimInTerminal('-S Xis_subst_script', {'rows': 9, 'cols': 70}) 1156 let buf = RunVimInTerminal('-S Xis_subst_script', {'rows': 9, 'cols': 70})
1166 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 1157 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
1167 " the 'ambiwidth' check. 1158 " the 'ambiwidth' check.
1168 sleep 100m 1159 sleep 100m
1169 1160
1254 call term_sendkeys(buf, ":\<Up>\<Up>") 1245 call term_sendkeys(buf, ":\<Up>\<Up>")
1255 call VerifyScreenDump(buf, 'Test_incsearch_substitute_14', {}) 1246 call VerifyScreenDump(buf, 'Test_incsearch_substitute_14', {})
1256 call term_sendkeys(buf, "<Esc>") 1247 call term_sendkeys(buf, "<Esc>")
1257 1248
1258 call StopVimInTerminal(buf) 1249 call StopVimInTerminal(buf)
1259 call delete('Xis_subst_script')
1260 endfunc 1250 endfunc
1261 1251
1262 func Test_incsearch_highlighting() 1252 func Test_incsearch_highlighting()
1263 CheckOption incsearch 1253 CheckOption incsearch
1264 CheckScreendump 1254 CheckScreendump
1265 1255
1266 call writefile([ 1256 call writefile([
1267 \ 'set incsearch hlsearch', 1257 \ 'set incsearch hlsearch',
1268 \ 'call setline(1, "hello/there")', 1258 \ 'call setline(1, "hello/there")',
1269 \ ], 'Xis_subst_hl_script') 1259 \ ], 'Xis_subst_hl_script', 'D')
1270 let buf = RunVimInTerminal('-S Xis_subst_hl_script', {'rows': 4, 'cols': 20}) 1260 let buf = RunVimInTerminal('-S Xis_subst_hl_script', {'rows': 4, 'cols': 20})
1271 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 1261 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
1272 " the 'ambiwidth' check. 1262 " the 'ambiwidth' check.
1273 sleep 300m 1263 sleep 300m
1274 1264
1277 call term_sendkeys(buf, ":%s;ello/the") 1267 call term_sendkeys(buf, ":%s;ello/the")
1278 call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {}) 1268 call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {})
1279 call term_sendkeys(buf, "<Esc>") 1269 call term_sendkeys(buf, "<Esc>")
1280 1270
1281 call StopVimInTerminal(buf) 1271 call StopVimInTerminal(buf)
1282 call delete('Xis_subst_hl_script')
1283 endfunc 1272 endfunc
1284 1273
1285 func Test_incsearch_with_change() 1274 func Test_incsearch_with_change()
1286 CheckFeature timers 1275 CheckFeature timers
1287 CheckOption incsearch 1276 CheckOption incsearch
1289 1278
1290 call writefile([ 1279 call writefile([
1291 \ 'set incsearch hlsearch scrolloff=0', 1280 \ 'set incsearch hlsearch scrolloff=0',
1292 \ 'call setline(1, ["one", "two ------ X", "three"])', 1281 \ 'call setline(1, ["one", "two ------ X", "three"])',
1293 \ 'call timer_start(200, { _ -> setline(2, "x")})', 1282 \ 'call timer_start(200, { _ -> setline(2, "x")})',
1294 \ ], 'Xis_change_script') 1283 \ ], 'Xis_change_script', 'D')
1295 let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70}) 1284 let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70})
1296 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 1285 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
1297 " the 'ambiwidth' check. 1286 " the 'ambiwidth' check.
1298 sleep 300m 1287 sleep 300m
1299 1288
1301 call term_sendkeys(buf, ':%s/X') 1290 call term_sendkeys(buf, ':%s/X')
1302 call VerifyScreenDump(buf, 'Test_incsearch_change_01', {}) 1291 call VerifyScreenDump(buf, 'Test_incsearch_change_01', {})
1303 call term_sendkeys(buf, "\<Esc>") 1292 call term_sendkeys(buf, "\<Esc>")
1304 1293
1305 call StopVimInTerminal(buf) 1294 call StopVimInTerminal(buf)
1306 call delete('Xis_change_script')
1307 endfunc 1295 endfunc
1308 1296
1309 " Similar to Test_incsearch_substitute_dump() for :sort 1297 " Similar to Test_incsearch_substitute_dump() for :sort
1310 func Test_incsearch_sort_dump() 1298 func Test_incsearch_sort_dump()
1311 CheckOption incsearch 1299 CheckOption incsearch
1312 CheckScreendump 1300 CheckScreendump
1313 1301
1314 call writefile([ 1302 call writefile([
1315 \ 'set incsearch hlsearch scrolloff=0', 1303 \ 'set incsearch hlsearch scrolloff=0',
1316 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', 1304 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
1317 \ ], 'Xis_sort_script') 1305 \ ], 'Xis_sort_script', 'D')
1318 let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70}) 1306 let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70})
1319 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 1307 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
1320 " the 'ambiwidth' check. 1308 " the 'ambiwidth' check.
1321 sleep 100m 1309 sleep 100m
1322 1310
1327 call term_sendkeys(buf, ':sort! /on') 1315 call term_sendkeys(buf, ':sort! /on')
1328 call VerifyScreenDump(buf, 'Test_incsearch_sort_02', {}) 1316 call VerifyScreenDump(buf, 'Test_incsearch_sort_02', {})
1329 call term_sendkeys(buf, "\<Esc>") 1317 call term_sendkeys(buf, "\<Esc>")
1330 1318
1331 call StopVimInTerminal(buf) 1319 call StopVimInTerminal(buf)
1332 call delete('Xis_sort_script')
1333 endfunc 1320 endfunc
1334 1321
1335 " Similar to Test_incsearch_substitute_dump() for :vimgrep famiry 1322 " Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
1336 func Test_incsearch_vimgrep_dump() 1323 func Test_incsearch_vimgrep_dump()
1337 CheckOption incsearch 1324 CheckOption incsearch
1338 CheckScreendump 1325 CheckScreendump
1339 1326
1340 call writefile([ 1327 call writefile([
1341 \ 'set incsearch hlsearch scrolloff=0', 1328 \ 'set incsearch hlsearch scrolloff=0',
1342 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', 1329 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
1343 \ ], 'Xis_vimgrep_script') 1330 \ ], 'Xis_vimgrep_script', 'D')
1344 let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70}) 1331 let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70})
1345 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by 1332 " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
1346 " the 'ambiwidth' check. 1333 " the 'ambiwidth' check.
1347 sleep 100m 1334 sleep 100m
1348 1335
1366 call term_sendkeys(buf, ':lvimgrepa "the" **/*.txt') 1353 call term_sendkeys(buf, ':lvimgrepa "the" **/*.txt')
1367 call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_05', {}) 1354 call VerifyScreenDump(buf, 'Test_incsearch_vimgrep_05', {})
1368 call term_sendkeys(buf, "\<Esc>") 1355 call term_sendkeys(buf, "\<Esc>")
1369 1356
1370 call StopVimInTerminal(buf) 1357 call StopVimInTerminal(buf)
1371 call delete('Xis_vimgrep_script')
1372 endfunc 1358 endfunc
1373 1359
1374 func Test_keep_last_search_pattern() 1360 func Test_keep_last_search_pattern()
1375 CheckOption incsearch 1361 CheckOption incsearch
1376 1362
1490 " Test that there is no crash when there is a last search pattern but no last 1476 " Test that there is no crash when there is a last search pattern but no last
1491 " substitute pattern. 1477 " substitute pattern.
1492 func Test_no_last_substitute_pat() 1478 func Test_no_last_substitute_pat()
1493 " Use viminfo to set the last search pattern to a string and make the last 1479 " Use viminfo to set the last search pattern to a string and make the last
1494 " substitute pattern the most recent used and make it empty (NULL). 1480 " substitute pattern the most recent used and make it empty (NULL).
1495 call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo') 1481 call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo', 'D')
1496 rviminfo! Xviminfo 1482 rviminfo! Xviminfo
1497 call assert_fails('normal n', 'E35:') 1483 call assert_fails('normal n', 'E35:')
1498
1499 call delete('Xviminfo')
1500 endfunc 1484 endfunc
1501 1485
1502 func Test_search_Ctrl_L_combining() 1486 func Test_search_Ctrl_L_combining()
1503 " Make sure, that Ctrl-L works correctly with combining characters. 1487 " Make sure, that Ctrl-L works correctly with combining characters.
1504 " It uses an artificial example of an 'a' with 4 combining chars: 1488 " It uses an artificial example of an 'a' with 4 combining chars:
1737 call assert_fails('g//p', ['E35:', 'E476:']) 1721 call assert_fails('g//p', ['E35:', 'E476:'])
1738 call assert_fails('v//p', ['E35:', 'E476:']) 1722 call assert_fails('v//p', ['E35:', 'E476:'])
1739 call writefile(v:errors, 'Xresult') 1723 call writefile(v:errors, 'Xresult')
1740 qall! 1724 qall!
1741 [SCRIPT] 1725 [SCRIPT]
1742 call writefile(lines, 'Xscript') 1726 call writefile(lines, 'Xscript', 'D')
1743 1727
1744 if RunVim([], [], '--clean -S Xscript') 1728 if RunVim([], [], '--clean -S Xscript')
1745 call assert_equal([], readfile('Xresult')) 1729 call assert_equal([], readfile('Xresult'))
1746 endif 1730 endif
1747 call delete('Xscript')
1748 call delete('Xresult') 1731 call delete('Xresult')
1749 endfunc 1732 endfunc
1750 1733
1751 " Test for using tilde (~) atom in search. This should use the last used 1734 " Test for using tilde (~) atom in search. This should use the last used
1752 " substitute pattern 1735 " substitute pattern
1760 call assert_fails('exe "normal ?~\<CR>"', ['E33:', 'E383:']) 1743 call assert_fails('exe "normal ?~\<CR>"', ['E33:', 'E383:'])
1761 set regexpengine& 1744 set regexpengine&
1762 call writefile(v:errors, 'Xresult') 1745 call writefile(v:errors, 'Xresult')
1763 qall! 1746 qall!
1764 [SCRIPT] 1747 [SCRIPT]
1765 call writefile(lines, 'Xscript') 1748 call writefile(lines, 'Xscript', 'D')
1766 if RunVim([], [], '--clean -S Xscript') 1749 if RunVim([], [], '--clean -S Xscript')
1767 call assert_equal([], readfile('Xresult')) 1750 call assert_equal([], readfile('Xresult'))
1768 endif 1751 endif
1769 call delete('Xscript')
1770 call delete('Xresult') 1752 call delete('Xresult')
1771 endfunc 1753 endfunc
1772 1754
1773 " Test for searching a pattern that is not present with 'nowrapscan' 1755 " Test for searching a pattern that is not present with 'nowrapscan'
1774 func Test_search_pat_not_found() 1756 func Test_search_pat_not_found()
2010 1992
2011 let commands =<< trim [CODE] 1993 let commands =<< trim [CODE]
2012 set incsearch nohls 1994 set incsearch nohls
2013 call setline(1, ['test', 'xxx']) 1995 call setline(1, ['test', 'xxx'])
2014 [CODE] 1996 [CODE]
2015 call writefile(commands, 'Xincsearch_nl') 1997 call writefile(commands, 'Xincsearch_nl', 'D')
2016 let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10}) 1998 let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10})
2017 call term_sendkeys(buf, '/test') 1999 call term_sendkeys(buf, '/test')
2018 call VerifyScreenDump(buf, 'Test_incsearch_newline1', {}) 2000 call VerifyScreenDump(buf, 'Test_incsearch_newline1', {})
2019 " Need to send one key at a time to force a redraw 2001 " Need to send one key at a time to force a redraw
2020 call term_sendkeys(buf, '\n') 2002 call term_sendkeys(buf, '\n')
2026 call term_sendkeys(buf, "\<CR>") 2008 call term_sendkeys(buf, "\<CR>")
2027 call VerifyScreenDump(buf, 'Test_incsearch_newline5', {}) 2009 call VerifyScreenDump(buf, 'Test_incsearch_newline5', {})
2028 call StopVimInTerminal(buf) 2010 call StopVimInTerminal(buf)
2029 2011
2030 " clean up 2012 " clean up
2031 call delete('Xincsearch_nl')
2032 call test_override("char_avail", 0) 2013 call test_override("char_avail", 0)
2033 bw 2014 bw
2034 endfunc 2015 endfunc
2035 2016
2036 func Test_incsearch_substitute_dump2() 2017 func Test_incsearch_substitute_dump2()
2042 \ 'for n in range(1, 4)', 2023 \ 'for n in range(1, 4)',
2043 \ ' call setline(n, "foo " . n)', 2024 \ ' call setline(n, "foo " . n)',
2044 \ 'endfor', 2025 \ 'endfor',
2045 \ 'call setline(5, "abc|def")', 2026 \ 'call setline(5, "abc|def")',
2046 \ '3', 2027 \ '3',
2047 \ ], 'Xis_subst_script2') 2028 \ ], 'Xis_subst_script2', 'D')
2048 let buf = RunVimInTerminal('-S Xis_subst_script2', {'rows': 9, 'cols': 70}) 2029 let buf = RunVimInTerminal('-S Xis_subst_script2', {'rows': 9, 'cols': 70})
2049 2030
2050 call term_sendkeys(buf, ':%s/\vabc|') 2031 call term_sendkeys(buf, ':%s/\vabc|')
2051 sleep 100m 2032 sleep 100m
2052 call VerifyScreenDump(buf, 'Test_incsearch_sub_01', {}) 2033 call VerifyScreenDump(buf, 'Test_incsearch_sub_01', {})
2057 sleep 100m 2038 sleep 100m
2058 call VerifyScreenDump(buf, 'Test_incsearch_sub_02', {}) 2039 call VerifyScreenDump(buf, 'Test_incsearch_sub_02', {})
2059 2040
2060 2041
2061 call StopVimInTerminal(buf) 2042 call StopVimInTerminal(buf)
2062 call delete('Xis_subst_script2')
2063 endfunc 2043 endfunc
2064 2044
2065 func Test_pattern_is_uppercase_smartcase() 2045 func Test_pattern_is_uppercase_smartcase()
2066 new 2046 new
2067 let input=['abc', 'ABC', 'Abc', 'abC'] 2047 let input=['abc', 'ABC', 'Abc', 'abC']
2144 let lines =<< trim END 2124 let lines =<< trim END
2145 /\%.v 2125 /\%.v
2146 5/ 2126 5/
2147 c 2127 c
2148 END 2128 END
2149 call writefile(lines, 'Xrangesearch') 2129 call writefile(lines, 'Xrangesearch', 'D')
2150 source Xrangesearch 2130 source Xrangesearch
2151 2131
2152 bwipe! 2132 bwipe!
2153 call delete('Xrangesearch')
2154 endfunc 2133 endfunc
2155 2134
2156 2135
2157 " vim: shiftwidth=2 sts=2 expandtab 2136 " vim: shiftwidth=2 sts=2 expandtab