comparison src/testdir/test_global.vim @ 27962:0fa3be75ddc7 v8.2.4506

patch 8.2.4506: "pattern not found" for :global is not an error message Commit: https://github.com/vim/vim/commit/24d9c0557ef52141d12ac32568967b190d247c6f Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 4 21:34:31 2022 +0000 patch 8.2.4506: "pattern not found" for :global is not an error message Problem: "pattern not found" for :global is not an error message. Solution: In Vim9 script make this an actual error, so that try/catch can be used as expected.
author Bram Moolenaar <Bram@vim.org>
date Fri, 04 Mar 2022 22:45:04 +0100
parents 026718ffbfa8
children 34bb46847ba0
comparison
equal deleted inserted replaced
27961:dd28ede556db 27962:0fa3be75ddc7
66 " Test for the 'Pattern found in every line' message 66 " Test for the 'Pattern found in every line' message
67 let v:statusmsg = '' 67 let v:statusmsg = ''
68 v/foo\|bar/p 68 v/foo\|bar/p
69 call assert_notequal('', v:statusmsg) 69 call assert_notequal('', v:statusmsg)
70 70
71 " In Vim9 script this is an error
72 let caught = 'no'
73 try
74 vim9cmd v/foo\|bar/p
75 catch /E538/
76 let caught = 'yes'
77 call assert_match('E538: Pattern found in every line: foo\|bar', v:exception)
78 endtry
79 call assert_equal('yes', caught)
80
81 " In Vim9 script not matching is an error
82 let caught = 'no'
83 try
84 vim9cmd g/foobarnotfound/p
85 catch /E486/
86 let caught = 'yes'
87 call assert_match('E486: Pattern not found: foobarnotfound', v:exception)
88 endtry
89 call assert_equal('yes', caught)
90
71 close! 91 close!
72 endfunc 92 endfunc
73 93
74 " Test for global command with newline character 94 " Test for global command with newline character
75 func Test_global_newline() 95 func Test_global_newline()