robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local describe , it , before_each =t . describe , t . it , t . before_each 3local pcall_err =t . pcall_err 4local n =require ( 'test.functional.testnvim' )() 5 6local clear , eval , eq =n . clear , n . eval , t . eq 7local command =n . command 8 9describe ( 'v:event' , function () 10before_each ( clear ) 11it ( 'is empty before any autocommand' , function () 12eq ( {} , eval ( 'v:event' )) 13end ) 14 15it ( 'is immutable' , function () 16eq ( false , pcall ( command , 'let v:event = {}' )) 17eq ( false , pcall ( command , 'let v:event.mykey = {}' )) 18end ) 19end ) 20 21describe ( 'v:argf' , function () 22it ( 'is read-only' , function () 23n . clear () 24t . matches ( 'E46' , t . pcall_err ( command , "let v:argf = ['foo']" )) 25end ) 26 27it ( 'gets file args, ignores :argadd, handles "--"' , function () 28local file1 , file2 , file3 ='Xargf_sep1' , 'Xargf_sep2' , 'Xargf_sep3' 29 30n . clear { 31args_rm ={ '--cmd' , '-c' } , 32args ={ 33'--clean' , 34'--cmd' , 35'argadd extrafile.txt' , -- :argadd should not affect v:argf. 36file1 , 37file2 , 38'-c' , 39'let a = 1 + 3' , 40'--' , 41file3 , 42} , 43} 44 45local abs1 =n . fn . fnamemodify ( file1 , ':p' ) 46local abs2 =n . fn . fnamemodify ( file2 , ':p' ) 47local abs3 =n . fn . fnamemodify ( file3 , ':p' ) 48 49eq ( { abs1 , abs2 , abs3 } , n . eval ( 'v:argf' )) 50end ) 51end ) 52 53describe ( 'v:startreason' , function () 54it ( 'is read-only and starts as "normal"' , function () 55n . clear { args ={ '--cmd' , 'let g:early_startreason = v:startreason' } } 56eq ( 'normal' , eval ( 'g:early_startreason' )) 57t . matches ( 'E46' , t . pcall_err ( command , "let v:startreason = 'restart'" )) 58end ) 59end )