comparison src/testdir/test_search.vim @ 19705:599793519c85 v8.2.0409

patch 8.2.0409: search test leaves file behind Commit: https://github.com/vim/vim/commit/b68df220c5278365792b8f94d8d6f34d329b7746 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 19 15:05:28 2020 +0100 patch 8.2.0409: search test leaves file behind Problem: Search test leaves file behind. Solution: Delete the file. Also use Check commands.
author Bram Moolenaar <Bram@vim.org>
date Thu, 19 Mar 2020 15:15:04 +0100
parents 5512aa74cb62
children 546bdeef35f1
comparison
equal deleted inserted replaced
19704:9aec979e8fdd 19705:599793519c85
3 source shared.vim 3 source shared.vim
4 source screendump.vim 4 source screendump.vim
5 source check.vim 5 source check.vim
6 6
7 func Test_search_cmdline() 7 func Test_search_cmdline()
8 if !exists('+incsearch') 8 CheckOption incsearch
9 return 9
10 endif
11 " need to disable char_avail, 10 " need to disable char_avail,
12 " so that expansion of commandline works 11 " so that expansion of commandline works
13 call test_override("char_avail", 1) 12 call test_override("char_avail", 1)
14 new 13 new
15 call setline(1, [' 1', ' 2 these', ' 3 the', ' 4 their', ' 5 there', ' 6 their', ' 7 the', ' 8 them', ' 9 these', ' 10 foobar']) 14 call setline(1, [' 1', ' 2 these', ' 3 the', ' 4 their', ' 5 there', ' 6 their', ' 7 the', ' 8 them', ' 9 these', ' 10 foobar'])
200 call test_override("char_avail", 0) 199 call test_override("char_avail", 0)
201 bw! 200 bw!
202 endfunc 201 endfunc
203 202
204 func Test_search_cmdline2() 203 func Test_search_cmdline2()
205 if !exists('+incsearch') 204 CheckOption incsearch
206 return 205
207 endif
208 " need to disable char_avail, 206 " need to disable char_avail,
209 " so that expansion of commandline works 207 " so that expansion of commandline works
210 call test_override("char_avail", 1) 208 call test_override("char_avail", 1)
211 new 209 new
212 call setline(1, [' 1', ' 2 these', ' 3 the theother']) 210 call setline(1, [' 1', ' 2 these', ' 3 the theother'])
444 call test_override("char_avail", 0) 442 call test_override("char_avail", 0)
445 bw! 443 bw!
446 endfunc 444 endfunc
447 445
448 func Test_search_cmdline3() 446 func Test_search_cmdline3()
449 if !exists('+incsearch') 447 CheckOption incsearch
450 return 448
451 endif
452 call Cmdline3_prep() 449 call Cmdline3_prep()
453 1 450 1
454 " first match 451 " first match
455 call feedkeys("/the\<c-l>\<cr>", 'tx') 452 call feedkeys("/the\<c-l>\<cr>", 'tx')
456 call assert_equal(' 2 the~e', getline('.')) 453 call assert_equal(' 2 the~e', getline('.'))
457 454
458 call Incsearch_cleanup() 455 call Incsearch_cleanup()
459 endfunc 456 endfunc
460 457
461 func Test_search_cmdline3s() 458 func Test_search_cmdline3s()
462 if !exists('+incsearch') 459 CheckOption incsearch
463 return 460
464 endif
465 call Cmdline3_prep() 461 call Cmdline3_prep()
466 1 462 1
467 call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx') 463 call feedkeys(":%s/the\<c-l>/xxx\<cr>", 'tx')
468 call assert_equal(' 2 xxxe', getline('.')) 464 call assert_equal(' 2 xxxe', getline('.'))
469 undo 465 undo
483 479
484 call Incsearch_cleanup() 480 call Incsearch_cleanup()
485 endfunc 481 endfunc
486 482
487 func Test_search_cmdline3g() 483 func Test_search_cmdline3g()
488 if !exists('+incsearch') 484 CheckOption incsearch
489 return 485
490 endif
491 call Cmdline3_prep() 486 call Cmdline3_prep()
492 1 487 1
493 call feedkeys(":g/the\<c-l>/d\<cr>", 'tx') 488 call feedkeys(":g/the\<c-l>/d\<cr>", 'tx')
494 call assert_equal(' 3 the theother', getline(2)) 489 call assert_equal(' 3 the theother', getline(2))
495 undo 490 undo
506 501
507 call Incsearch_cleanup() 502 call Incsearch_cleanup()
508 endfunc 503 endfunc
509 504
510 func Test_search_cmdline3v() 505 func Test_search_cmdline3v()
511 if !exists('+incsearch') 506 CheckOption incsearch
512 return 507
513 endif
514 call Cmdline3_prep() 508 call Cmdline3_prep()
515 1 509 1
516 call feedkeys(":v/the\<c-l>/d\<cr>", 'tx') 510 call feedkeys(":v/the\<c-l>/d\<cr>", 'tx')
517 call assert_equal(1, line('$')) 511 call assert_equal(1, line('$'))
518 call assert_equal(' 2 the~e', getline(1)) 512 call assert_equal(' 2 the~e', getline(1))
523 517
524 call Incsearch_cleanup() 518 call Incsearch_cleanup()
525 endfunc 519 endfunc
526 520
527 func Test_search_cmdline4() 521 func Test_search_cmdline4()
528 if !exists('+incsearch') 522 CheckOption incsearch
529 return 523
530 endif
531 " need to disable char_avail, 524 " need to disable char_avail,
532 " so that expansion of commandline works 525 " so that expansion of commandline works
533 call test_override("char_avail", 1) 526 call test_override("char_avail", 1)
534 new 527 new
535 call setline(1, [' 1 the first', ' 2 the second', ' 3 the third']) 528 call setline(1, [' 1 the first', ' 2 the second', ' 3 the third'])
557 call test_override("char_avail", 0) 550 call test_override("char_avail", 0)
558 bw! 551 bw!
559 endfunc 552 endfunc
560 553
561 func Test_search_cmdline5() 554 func Test_search_cmdline5()
562 if !exists('+incsearch') 555 CheckOption incsearch
563 return 556
564 endif
565 " Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work 557 " Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
566 " regardless char_avail. 558 " regardless char_avail.
567 new 559 new
568 call setline(1, [' 1 the first', ' 2 the second', ' 3 the third', '']) 560 call setline(1, [' 1 the first', ' 2 the second', ' 3 the third', ''])
569 set incsearch 561 set incsearch
579 endfunc 571 endfunc
580 572
581 func Test_search_cmdline6() 573 func Test_search_cmdline6()
582 " Test that consecutive matches 574 " Test that consecutive matches
583 " are caught by <c-g>/<c-t> 575 " are caught by <c-g>/<c-t>
584 if !exists('+incsearch') 576 CheckOption incsearch
585 return 577
586 endif
587 " need to disable char_avail, 578 " need to disable char_avail,
588 " so that expansion of commandline works 579 " so that expansion of commandline works
589 call test_override("char_avail", 1) 580 call test_override("char_avail", 1)
590 new 581 new
591 call setline(1, [' bbvimb', '']) 582 call setline(1, [' bbvimb', ''])
619 endfunc 610 endfunc
620 611
621 func Test_search_cmdline7() 612 func Test_search_cmdline7()
622 " Test that an pressing <c-g> in an empty command line 613 " Test that an pressing <c-g> in an empty command line
623 " does not move the cursor 614 " does not move the cursor
624 if !exists('+incsearch') 615 CheckOption incsearch
625 return 616
626 endif
627 " need to disable char_avail, 617 " need to disable char_avail,
628 " so that expansion of commandline works 618 " so that expansion of commandline works
629 call test_override("char_avail", 1) 619 call test_override("char_avail", 1)
630 new 620 new
631 let @/ = 'b' 621 let @/ = 'b'
752 set undolevels& 742 set undolevels&
753 enew! 743 enew!
754 endfunc 744 endfunc
755 745
756 func Test_search_cmdline_incsearch_highlight() 746 func Test_search_cmdline_incsearch_highlight()
757 if !exists('+incsearch') 747 CheckOption incsearch
758 return 748
759 endif
760 set incsearch hlsearch 749 set incsearch hlsearch
761 " need to disable char_avail, 750 " need to disable char_avail,
762 " so that expansion of commandline works 751 " so that expansion of commandline works
763 call test_override("char_avail", 1) 752 call test_override("char_avail", 1)
764 new 753 new
872 call delete('Xsearch.txt') 861 call delete('Xsearch.txt')
873 bwipe! 862 bwipe!
874 endfunc 863 endfunc
875 864
876 func Test_incsearch_cmdline_modifier() 865 func Test_incsearch_cmdline_modifier()
877 if !exists('+incsearch') 866 CheckOption incsearch
878 return 867
879 endif
880 call test_override("char_avail", 1) 868 call test_override("char_avail", 1)
881 new 869 new
882 call setline(1, ['foo']) 870 call setline(1, ['foo'])
883 set incsearch 871 set incsearch
884 " Test that error E14 does not occur in parsing command modifier. 872 " Test that error E14 does not occur in parsing command modifier.
916 call StopVimInTerminal(buf) 904 call StopVimInTerminal(buf)
917 call delete('Xscript') 905 call delete('Xscript')
918 endfunc 906 endfunc
919 907
920 func Test_incsearch_search_dump() 908 func Test_incsearch_search_dump()
921 if !exists('+incsearch') 909 CheckOption incsearch
922 return 910 CheckScreendump
923 endif 911
924 if !CanRunVimInTerminal()
925 throw 'Skipped: cannot make screendumps'
926 endif
927 call writefile([ 912 call writefile([
928 \ 'set incsearch hlsearch scrolloff=0', 913 \ 'set incsearch hlsearch scrolloff=0',
929 \ 'for n in range(1, 8)', 914 \ 'for n in range(1, 8)',
930 \ ' call setline(n, "foo " . n)', 915 \ ' call setline(n, "foo " . n)',
931 \ 'endfor', 916 \ 'endfor',
949 call StopVimInTerminal(buf) 934 call StopVimInTerminal(buf)
950 call delete('Xis_search_script') 935 call delete('Xis_search_script')
951 endfunc 936 endfunc
952 937
953 func Test_incsearch_substitute() 938 func Test_incsearch_substitute()
954 if !exists('+incsearch') 939 CheckOption incsearch
955 return 940
956 endif
957 call test_override("char_avail", 1) 941 call test_override("char_avail", 1)
958 new 942 new
959 set incsearch 943 set incsearch
960 for n in range(1, 10) 944 for n in range(1, 10)
961 call setline(n, 'foo ' . n) 945 call setline(n, 'foo ' . n)
971 call Incsearch_cleanup() 955 call Incsearch_cleanup()
972 endfunc 956 endfunc
973 957
974 " Similar to Test_incsearch_substitute() but with a screendump halfway. 958 " Similar to Test_incsearch_substitute() but with a screendump halfway.
975 func Test_incsearch_substitute_dump() 959 func Test_incsearch_substitute_dump()
976 if !exists('+incsearch') 960 CheckOption incsearch
977 return 961 CheckScreendump
978 endif 962
979 if !CanRunVimInTerminal()
980 throw 'Skipped: cannot make screendumps'
981 endif
982 call writefile([ 963 call writefile([
983 \ 'set incsearch hlsearch scrolloff=0', 964 \ 'set incsearch hlsearch scrolloff=0',
984 \ 'for n in range(1, 10)', 965 \ 'for n in range(1, 10)',
985 \ ' call setline(n, "foo " . n)', 966 \ ' call setline(n, "foo " . n)',
986 \ 'endfor', 967 \ 'endfor',
1083 call StopVimInTerminal(buf) 1064 call StopVimInTerminal(buf)
1084 call delete('Xis_subst_script') 1065 call delete('Xis_subst_script')
1085 endfunc 1066 endfunc
1086 1067
1087 func Test_incsearch_highlighting() 1068 func Test_incsearch_highlighting()
1088 if !exists('+incsearch') 1069 CheckOption incsearch
1089 return 1070 CheckScreendump
1090 endif
1091 if !CanRunVimInTerminal()
1092 throw 'Skipped: cannot make screendumps'
1093 endif
1094 1071
1095 call writefile([ 1072 call writefile([
1096 \ 'set incsearch hlsearch', 1073 \ 'set incsearch hlsearch',
1097 \ 'call setline(1, "hello/there")', 1074 \ 'call setline(1, "hello/there")',
1098 \ ], 'Xis_subst_hl_script') 1075 \ ], 'Xis_subst_hl_script')
1104 " Using a different search delimiter should still highlight matches 1081 " Using a different search delimiter should still highlight matches
1105 " that contain a '/'. 1082 " that contain a '/'.
1106 call term_sendkeys(buf, ":%s;ello/the") 1083 call term_sendkeys(buf, ":%s;ello/the")
1107 call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {}) 1084 call VerifyScreenDump(buf, 'Test_incsearch_substitute_15', {})
1108 call term_sendkeys(buf, "<Esc>") 1085 call term_sendkeys(buf, "<Esc>")
1086
1087 call StopVimInTerminal(buf)
1088 call delete('Xis_subst_hl_script')
1109 endfunc 1089 endfunc
1110 1090
1111 func Test_incsearch_with_change() 1091 func Test_incsearch_with_change()
1112 if !has('timers') || !exists('+incsearch') || !CanRunVimInTerminal() 1092 CheckFeature timers
1113 throw 'Skipped: cannot make screendumps and/or timers feature and/or incsearch option missing' 1093 CheckOption incsearch
1114 endif 1094 CheckScreendump
1115 1095
1116 call writefile([ 1096 call writefile([
1117 \ 'set incsearch hlsearch scrolloff=0', 1097 \ 'set incsearch hlsearch scrolloff=0',
1118 \ 'call setline(1, ["one", "two ------ X", "three"])', 1098 \ 'call setline(1, ["one", "two ------ X", "three"])',
1119 \ 'call timer_start(200, { _ -> setline(2, "x")})', 1099 \ 'call timer_start(200, { _ -> setline(2, "x")})',
1132 call delete('Xis_change_script') 1112 call delete('Xis_change_script')
1133 endfunc 1113 endfunc
1134 1114
1135 " Similar to Test_incsearch_substitute_dump() for :sort 1115 " Similar to Test_incsearch_substitute_dump() for :sort
1136 func Test_incsearch_sort_dump() 1116 func Test_incsearch_sort_dump()
1137 if !exists('+incsearch') 1117 CheckOption incsearch
1138 return 1118 CheckScreendump
1139 endif 1119
1140 if !CanRunVimInTerminal()
1141 throw 'Skipped: cannot make screendumps'
1142 endif
1143 call writefile([ 1120 call writefile([
1144 \ 'set incsearch hlsearch scrolloff=0', 1121 \ 'set incsearch hlsearch scrolloff=0',
1145 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', 1122 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
1146 \ ], 'Xis_sort_script') 1123 \ ], 'Xis_sort_script')
1147 let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70}) 1124 let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70})
1158 call delete('Xis_sort_script') 1135 call delete('Xis_sort_script')
1159 endfunc 1136 endfunc
1160 1137
1161 " Similar to Test_incsearch_substitute_dump() for :vimgrep famiry 1138 " Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
1162 func Test_incsearch_vimgrep_dump() 1139 func Test_incsearch_vimgrep_dump()
1163 if !exists('+incsearch') 1140 CheckOption incsearch
1164 return 1141 CheckScreendump
1165 endif 1142
1166 if !CanRunVimInTerminal()
1167 throw 'Skipped: cannot make screendumps'
1168 endif
1169 call writefile([ 1143 call writefile([
1170 \ 'set incsearch hlsearch scrolloff=0', 1144 \ 'set incsearch hlsearch scrolloff=0',
1171 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', 1145 \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
1172 \ ], 'Xis_vimgrep_script') 1146 \ ], 'Xis_vimgrep_script')
1173 let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70}) 1147 let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70})
1199 call StopVimInTerminal(buf) 1173 call StopVimInTerminal(buf)
1200 call delete('Xis_vimgrep_script') 1174 call delete('Xis_vimgrep_script')
1201 endfunc 1175 endfunc
1202 1176
1203 func Test_keep_last_search_pattern() 1177 func Test_keep_last_search_pattern()
1204 if !exists('+incsearch') 1178 CheckOption incsearch
1205 return 1179
1206 endif
1207 new 1180 new
1208 call setline(1, ['foo', 'foo', 'foo']) 1181 call setline(1, ['foo', 'foo', 'foo'])
1209 set incsearch 1182 set incsearch
1210 call test_override("char_avail", 1) 1183 call test_override("char_avail", 1)
1211 let @/ = 'bar' 1184 let @/ = 'bar'
1220 call test_override("ALL", 0) 1193 call test_override("ALL", 0)
1221 set noincsearch 1194 set noincsearch
1222 endfunc 1195 endfunc
1223 1196
1224 func Test_word_under_cursor_after_match() 1197 func Test_word_under_cursor_after_match()
1225 if !exists('+incsearch') 1198 CheckOption incsearch
1226 return 1199
1227 endif
1228 new 1200 new
1229 call setline(1, 'foo bar') 1201 call setline(1, 'foo bar')
1230 set incsearch 1202 set incsearch
1231 call test_override("char_avail", 1) 1203 call test_override("char_avail", 1)
1232 try 1204 try
1239 call test_override("ALL", 0) 1211 call test_override("ALL", 0)
1240 set noincsearch 1212 set noincsearch
1241 endfunc 1213 endfunc
1242 1214
1243 func Test_subst_word_under_cursor() 1215 func Test_subst_word_under_cursor()
1244 if !exists('+incsearch') 1216 CheckOption incsearch
1245 return 1217
1246 endif
1247 new 1218 new
1248 call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)']) 1219 call setline(1, ['int SomeLongName;', 'for (xxx = 1; xxx < len; ++xxx)'])
1249 set incsearch 1220 set incsearch
1250 call test_override("char_avail", 1) 1221 call test_override("char_avail", 1)
1251 call feedkeys("/LongName\<CR>", 'ntx') 1222 call feedkeys("/LongName\<CR>", 'ntx')
1256 call test_override("ALL", 0) 1227 call test_override("ALL", 0)
1257 set noincsearch 1228 set noincsearch
1258 endfunc 1229 endfunc
1259 1230
1260 func Test_search_undefined_behaviour() 1231 func Test_search_undefined_behaviour()
1261 if !has("terminal") 1232 CheckFeature terminal
1262 return 1233
1263 endif
1264 let h = winheight(0) 1234 let h = winheight(0)
1265 if h < 3 1235 if h < 3
1266 return 1236 return
1267 endif 1237 endif
1268 " did cause an undefined left shift 1238 " did cause an undefined left shift
1324 " ' ̀' U+0300 Dec:768 COMBINING GRAVE ACCENT &#x300; /\%u300\Z "\u0300" 1294 " ' ̀' U+0300 Dec:768 COMBINING GRAVE ACCENT &#x300; /\%u300\Z "\u0300"
1325 " ' ́' U+0301 Dec:769 COMBINING ACUTE ACCENT &#x301; /\%u301\Z "\u0301" 1295 " ' ́' U+0301 Dec:769 COMBINING ACUTE ACCENT &#x301; /\%u301\Z "\u0301"
1326 " ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE &#x307; /\%u307\Z "\u0307" 1296 " ' ̇' U+0307 Dec:775 COMBINING DOT ABOVE &#x307; /\%u307\Z "\u0307"
1327 " ' ̣' U+0323 Dec:803 COMBINING DOT BELOW &#x323; /\%u323 "\u0323" 1297 " ' ̣' U+0323 Dec:803 COMBINING DOT BELOW &#x323; /\%u323 "\u0323"
1328 " Those should also appear on the commandline 1298 " Those should also appear on the commandline
1329 if !exists('+incsearch') 1299 CheckOption incsearch
1330 return 1300
1331 endif
1332 call Cmdline3_prep() 1301 call Cmdline3_prep()
1333 1 1302 1
1334 let bufcontent = ['', 'Miạ̀́̇m'] 1303 let bufcontent = ['', 'Miạ̀́̇m']
1335 call append('$', bufcontent) 1304 call append('$', bufcontent)
1336 call feedkeys("/Mi\<c-l>\<c-l>\<cr>", 'tx') 1305 call feedkeys("/Mi\<c-l>\<c-l>\<cr>", 'tx')
1375 " This was also giving an internal error 1344 " This was also giving an internal error
1376 call assert_fails('call search(" \\((\\v[[=P=]]){185}+ ")', 'E871:') 1345 call assert_fails('call search(" \\((\\v[[=P=]]){185}+ ")', 'E871:')
1377 endfunc 1346 endfunc
1378 1347
1379 func Test_incsearch_add_char_under_cursor() 1348 func Test_incsearch_add_char_under_cursor()
1380 if !exists('+incsearch') 1349 CheckOption incsearch
1381 return 1350
1382 endif
1383 set incsearch 1351 set incsearch
1384 new 1352 new
1385 call setline(1, ['find match', 'anything']) 1353 call setline(1, ['find match', 'anything'])
1386 1 1354 1
1387 call test_override('char_avail', 1) 1355 call test_override('char_avail', 1)