comparison src/testdir/test_vim9_script.vim @ 27950:aacc98a38cf3 v8.2.4500

patch 8.2.4500: Vim9: can declare a global variable on the command line Commit: https://github.com/vim/vim/commit/0e1574c4069ded47c170fcd7a47a0df66693a5f4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 3 17:05:35 2022 +0000 patch 8.2.4500: Vim9: can declare a global variable on the command line Problem: Vim9: can declare a global variable on the command line. Solution: Disallow declaring a variable on the command line. (closes https://github.com/vim/vim/issues/9881)
author Bram Moolenaar <Bram@vim.org>
date Thu, 03 Mar 2022 18:15:03 +0100
parents f57b8db06f26
children 2485bf68de34
comparison
equal deleted inserted replaced
27949:46782f635e4d 27950:aacc98a38cf3
3324 3324
3325 " Use :function so we can use Check commands 3325 " Use :function so we can use Check commands
3326 func Test_no_redraw_when_restoring_cpo() 3326 func Test_no_redraw_when_restoring_cpo()
3327 CheckScreendump 3327 CheckScreendump
3328 CheckFeature timers 3328 CheckFeature timers
3329 3329 call Run_test_no_redraw_when_restoring_cpo()
3330 let lines =<< trim END 3330 endfunc
3331
3332 def Run_test_no_redraw_when_restoring_cpo()
3333 var lines =<< trim END
3331 vim9script 3334 vim9script
3332 export def Func() 3335 export def Func()
3333 enddef 3336 enddef
3334 END 3337 END
3335 call mkdir('Xdir/autoload', 'p') 3338 mkdir('Xdir/autoload', 'p')
3336 call writefile(lines, 'Xdir/autoload/script.vim') 3339 writefile(lines, 'Xdir/autoload/script.vim')
3337 3340
3338 let lines =<< trim END 3341 lines =<< trim END
3339 vim9script 3342 vim9script
3340 set cpo+=M 3343 set cpo+=M
3341 exe 'set rtp^=' .. getcwd() .. '/Xdir' 3344 exe 'set rtp^=' .. getcwd() .. '/Xdir'
3342 au CmdlineEnter : ++once timer_start(0, (_) => script#Func()) 3345 au CmdlineEnter : ++once timer_start(0, (_) => script#Func())
3343 setline(1, 'some text') 3346 setline(1, 'some text')
3344 END 3347 END
3345 call writefile(lines, 'XTest_redraw_cpo') 3348 writefile(lines, 'XTest_redraw_cpo')
3346 let buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) 3349 var buf = g:RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6})
3347 call term_sendkeys(buf, "V:") 3350 term_sendkeys(buf, "V:")
3348 call VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) 3351 g:VerifyScreenDump(buf, 'Test_vim9_no_redraw', {})
3349 3352
3350 " clean up 3353 # clean up
3351 call term_sendkeys(buf, "\<Esc>u") 3354 term_sendkeys(buf, "\<Esc>u")
3352 call g:StopVimInTerminal(buf) 3355 g:StopVimInTerminal(buf)
3353 call delete('XTest_redraw_cpo') 3356 delete('XTest_redraw_cpo')
3354 call delete('Xdir', 'rf') 3357 delete('Xdir', 'rf')
3358 enddef
3359
3360 func Test_reject_declaration()
3361 CheckScreendump
3362 call Run_test_reject_declaration()
3355 endfunc 3363 endfunc
3356 3364
3365 def Run_test_reject_declaration()
3366 var buf = g:RunVimInTerminal('', {'rows': 6})
3367 term_sendkeys(buf, ":vim9cmd var x: number\<CR>")
3368 g:VerifyScreenDump(buf, 'Test_vim9_reject_declaration', {})
3369
3370 # clean up
3371 g:StopVimInTerminal(buf)
3372 enddef
3357 3373
3358 def Test_unset_any_variable() 3374 def Test_unset_any_variable()
3359 var lines =<< trim END 3375 var lines =<< trim END
3360 var name: any 3376 var name: any
3361 assert_equal(0, name) 3377 assert_equal(0, name)