exe 'set rtp^=' .. getcwd() .. '/Xruntime'
call crash#func()
call writefile(['ok'], 'Xdidit')
- qall
+ qall!
END
writefile(lines, 'Xscript')
RunVim([], [], '-S Xscript')
def Test_invalid_sid()
assert_fails('func <SNR>1234_func', 'E123:')
- if RunVim([], ['wq Xdidit'], '+"func <SNR>1_func"')
+ if RunVim([], ['wq! Xdidit'], '+"func <SNR>1_func"')
assert_equal([], readfile('Xdidit'))
endif
delete('Xdidit')
CheckDefAndScriptSuccess(lines)
enddef
+def Test_define_func_at_command_line()
+ # run in a separate Vim instance to avoid the script context
+ let lines =<< trim END
+ func CheckAndQuit()
+ call assert_fails('call Afunc()', 'E117: Unknown function: Bfunc')
+ call writefile(['errors: ' .. string(v:errors)], 'Xdidcmd')
+ endfunc
+ END
+ writefile([''], 'Xdidcmd')
+ writefile(lines, 'XcallFunc')
+ let buf = RunVimInTerminal('-S XcallFunc', #{rows: 6})
+ # define Afunc() on the command line
+ term_sendkeys(buf, ":def Afunc()\<CR>Bfunc()\<CR>enddef\<CR>")
+ term_sendkeys(buf, ":call CheckAndQuit()\<CR>")
+ WaitForAssert({-> assert_equal(['errors: []'], readfile('Xdidcmd'))})
+
+ call StopVimInTerminal(buf)
+ delete('XcallFunc')
+ delete('Xdidcmd')
+enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
lookup_script(char_u *name, size_t len, int vim9script)
{
int cc;
- hashtab_T *ht = &SCRIPT_VARS(current_sctx.sc_sid);
+ hashtab_T *ht;
dictitem_T *di;
+ if (current_sctx.sc_sid <= 0)
+ return FAIL;
+ ht = &SCRIPT_VARS(current_sctx.sc_sid);
if (vim9script && !script_is_vim9())
return FAIL;
cc = name[len];