robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each =t . describe , t . it , t . before_each 5local command =n . command 6local eq =t . eq 7local clear =n . clear 8local fn =n . fn 9local pcall_err =t . pcall_err 10local assert_alive =n . assert_alive 11 12describe ( 'nlua_call_excmd excmds' , function () 13-- Exercise nlua_call_excmd by testing commands implemented with it (:log, :lsp). 14 15before_each ( function () 16clear () 17end ) 18 19it ( 'error propagation, formatting' , function () 20t . eq ( 'Vim(lsp):E5800: Invalid :lsp subcommand: bogus' , pcall_err ( command , 'lsp bogus' )) 21t . matches ( 'Vim%(log%):E5200: No such log.*' , pcall_err ( command , 'log bogus' )) 22end ) 23end ) 24 25describe ( 'excmds' , function () 26before_each ( function () 27clear () 28end ) 29 30local function check_excmd_err ( cmd , err ) 31eq ( err .. ': ' .. cmd , pcall_err ( command , cmd )) 32end 33 34it ( 'handle integer overflow from user-input #5555' , function () 35command ( ':9999999999999999999999999999999999999999' ) 36command ( ':later 9999999999999999999999999999999999999999' ) 37command ( ':echo expand("#<9999999999999999999999999999999999999999")' ) 38command ( ':lockvar 9999999999999999999999999999999999999999' ) 39command ( 40':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999' 41) 42check_excmd_err ( 43':tabnext 9999999999999999999999999999999999999999' , 44'Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999' 45) 46eq ( 47'Vim(Next):E163: There is only one file to edit' , 48pcall_err ( command , ':N 9999999999999999999999999999999999999999' ) 49) 50check_excmd_err ( 51':bdelete 9999999999999999999999999999999999999999' , 52'Vim(bdelete):E516: No buffers were deleted' 53) 54eq ( 55'Vim(menu):E329: No menu "9999999999999999999999999999999999999999"' , 56pcall_err ( command , ':menu 9999999999999999999999999999999999999999' ) 57) 58eq ( 59'Vim(substitute):E1510: Value too large: 9999999999999999999999999999999999999999' , 60pcall_err ( command , ':%s/./b/9999999999999999999999999999999999999999' ) 61) 62assert_alive () 63end ) 64 65it ( 'listing long user command does not crash' , function () 66command ( 'execute "command" repeat("T", 255) ":"' ) 67command ( 'command' ) 68end ) 69 70it ( ':def is an unknown command #23149' , function () 71eq ( 'Vim:E492: Not an editor command: def' , pcall_err ( command , 'def' )) 72eq ( 1 , fn . exists ( ':d' )) 73eq ( 'delete' , fn . fullcommand ( 'd' )) 74eq ( 1 , fn . exists ( ':de' )) 75eq ( 'delete' , fn . fullcommand ( 'de' )) 76eq ( 0 , fn . exists ( ':def' )) 77eq ( '' , fn . fullcommand ( 'def' )) 78eq ( 1 , fn . exists ( ':defe' )) 79eq ( 'defer' , fn . fullcommand ( 'defe' )) 80eq ( 2 , fn . exists ( ':defer' )) 81eq ( 'defer' , fn . fullcommand ( 'defer' )) 82end ) 83 84it ( 'various command abbreviations' , function () 85-- :connect needs at least :conn 86eq ( 'change' , fn . fullcommand ( 'c' )) 87eq ( 'copy' , fn . fullcommand ( 'co' )) 88eq ( 'continue' , fn . fullcommand ( 'con' )) 89eq ( 'connect' , fn . fullcommand ( 'conn' )) 90-- :restart needs at least :rest 91eq ( 'read' , fn . fullcommand ( 'r' )) 92eq ( 'read' , fn . fullcommand ( 're' )) 93eq ( 'resize' , fn . fullcommand ( 'res' )) 94eq ( 'restart' , fn . fullcommand ( 'rest' )) 95end ) 96end )