enddef
def Test_vim9_import_export()
- writefile(s:export_script_lines, 'Xexport.vim')
+ writefile(s:export_script_lines, 'Xexport.vim', 'D')
var import_script_lines =<< trim END
vim9script
var dir = './'
assert_equal('andthensome', 'andthen'->expo.AddSome())
assert_equal('awesome', 'awe'->expo.AddRef())
END
- writefile(import_script_lines, 'Ximport.vim')
+ writefile(import_script_lines, 'Ximport.vim', 'D')
source Ximport.vim
assert_equal('bobbie', g:result)
writefile(import_assign_const_lines, 'Ximport.vim')
assert_fails('source Ximport.vim', 'E46: Cannot change read-only variable "CONST"', '', 3)
- delete('Ximport.vim')
- delete('Xexport.vim')
-
# Check that in a Vim9 script 'cpo' is set to the Vim default.
# Flags added or removed are also applied to the restored value.
set cpo=abcd
set cpo-=c
g:cpo_after_vim9script = &cpo
END
- writefile(lines, 'Xvim9_script')
+ writefile(lines, 'Xvim9_script', 'D')
source Xvim9_script
assert_equal('fabd', &cpo)
set cpo&vim
export var verylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongname = 'asdf'
END
- writefile(lines, 'Xverylong.vim')
+ writefile(lines, 'Xverylong.vim', 'D')
lines =<< trim END
vim9script
v9.CheckScriptSuccess(lines)
assert_equal('asdf', g:result)
- delete('Xverylong.vim')
unlet g:result
enddef
enddef
export const G = F
END
- writefile(lines, 'Xlib.vim')
+ writefile(lines, 'Xlib.vim', 'D')
lines =<< trim END
vim9script
DoTest()
END
v9.CheckScriptSuccess(lines)
-
- delete('Xlib.vim')
enddef
def Test_export_closure()
NewLspServer()
END
- writefile(lines, 'Xserver.vim')
+ writefile(lines, 'Xserver.vim', 'D')
lines =<< trim END
vim9script
AddServer()
END
v9.CheckScriptSuccess(lines)
-
- delete('Xserver.vim')
enddef
def Test_import_fails()
- writefile([], 'Xfoo.vim')
+ writefile([], 'Xfoo.vim', 'D')
var lines =<< trim END
import './Xfoo.vim' as foo
foo = 'bar'
export var item = 'hello'
import './Xyourself.vim'
END
- writefile(lines, 'Xyourself.vim')
+ writefile(lines, 'Xyourself.vim', 'D')
assert_fails('source Xyourself.vim', 'E1088:')
- delete('Xyourself.vim')
- mkdir('Ximport')
+ mkdir('Ximport', 'R')
writefile(['vim9script'], 'Ximport/.vim')
lines =<< trim END
call writefile(['vim9script', "import './Xfoo.vim' as abc | foobar"], 'Xbar.vim')
assert_fails('source Xbar.vim', 'E492: Not an editor command: foobar')
call delete('Xbar.vim')
-
- delete('Ximport', 'rf')
- delete('Xfoo.vim')
enddef
func g:Trigger()
return 'yes'
enddef
END
- writefile(export_lines, 'Xexport_that.vim')
+ writefile(export_lines, 'Xexport_that.vim', 'D')
var import_lines =<< trim END
vim9script
import './Xexport_that.vim' as that
assert_equal('yes', that.That())
END
- writefile(import_lines, 'Ximport.vim')
+ writefile(import_lines, 'Ximport.vim', 'D')
nnoremap <expr> trigger g:Trigger()
feedkeys('trigger', "xt")
- delete('Xexport_that.vim')
- delete('Ximport.vim')
nunmap trigger
enddef
def Test_import_in_filetype()
# check that :import works when the buffer is locked
- mkdir('ftplugin', 'p')
+ mkdir('ftplugin', 'pR')
var export_lines =<< trim END
vim9script
export var That = 'yes'
assert_equal(1, g:did_load_mytpe)
quit!
- delete('Xexport_ft.vim')
- delete('ftplugin', 'rf')
&rtp = save_rtp
enddef
g:result = nr
enddef
END
- writefile(lines, 'XsomeExport.vim')
+ writefile(lines, 'XsomeExport.vim', 'D')
lines =<< trim END
vim9script
import './XsomeExport.vim' as some
nnoremap <F3> :call <sid>Funcy(42)<cr>
nnoremap <F4> :call <sid>some.Funcx(44)<cr>
END
- writefile(lines, 'Xmapscript.vim')
+ writefile(lines, 'Xmapscript.vim', 'D')
source Xmapscript.vim
feedkeys("\<F3>", "xt")
assert_equal(44, g:result)
unlet g:result
- delete('XsomeExport.vim')
- delete('Xmapscript.vim')
nunmap <F3>
nunmap <F4>
enddef
g:result = 42
enddef
END
- writefile(lines, 'XrelautoloadExport.vim')
+ writefile(lines, 'XrelautoloadExport.vim', 'D')
lines =<< trim END
vim9script
import autoload './XrelautoloadExport.vim' as some
nnoremap <F3> :call <SID>some.Func()<CR>
END
- writefile(lines, 'Xmapscript.vim')
+ writefile(lines, 'Xmapscript.vim', 'D')
source Xmapscript.vim
assert_match('\d\+ A: .*XrelautoloadExport.vim', execute('scriptnames')->split("\n")[-1])
assert_equal(999999, l[0].version)
unlet g:result
- delete('XrelautoloadExport.vim')
- delete('Xmapscript.vim')
nunmap <F3>
enddef
g:result = 49
enddef
END
- mkdir('Ximpdir/autoload', 'p')
+ mkdir('Ximpdir/autoload', 'pR')
writefile(lines, 'Ximpdir/autoload/XautoloadExport.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Ximpdir'
import autoload 'XautoloadExport.vim' as some
nnoremap <F3> :call <SID>some.Func()<CR>
END
- writefile(lines, 'Xmapscript.vim')
+ writefile(lines, 'Xmapscript.vim', 'D')
source Xmapscript.vim
assert_match('\d\+ A: .*autoload/XautoloadExport.vim', execute('scriptnames')->split("\n")[-1])
assert_equal(49, g:result)
unlet g:result
- delete('Xmapscript.vim')
nunmap <F3>
- delete('Ximpdir', 'rf')
&rtp = save_rtp
enddef
return ['abcd']
enddef
END
- writefile(lines, 'Xscript.vim')
+ writefile(lines, 'Xscript.vim', 'D')
lines =<< trim END
vim9script
v9.CheckScriptSuccess(lines)
delcommand Cmd
- delete('Xscript.vim')
enddef
def Test_use_import_with_funcref_in_command_completion()
return ['abcd']
enddef
END
- writefile(lines, 'Xscript.vim')
+ writefile(lines, 'Xscript.vim', 'D')
lines =<< trim END
vim9script
v9.CheckScriptSuccess(lines)
delcommand Cmd
- delete('Xscript.vim')
enddef
def Test_use_autoload_import_in_insert_completion()
- mkdir('Xinsdir/autoload', 'p')
+ mkdir('Xinsdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xinsdir'
set thesaurusfunc=
bwipe!
- delete('Xinsdir', 'rf')
&rtp = save_rtp
enddef
def Test_use_autoload_import_partial_in_opfunc()
- mkdir('Xpartdir/autoload', 'p')
+ mkdir('Xpartdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xpartdir'
set opfunc=
bwipe!
- delete('Xpartdir', 'rf')
nunmap <F3>
&rtp = save_rtp
enddef
def Test_set_opfunc_to_autoload_func_directly()
- mkdir('Xdirdir/autoload', 'p')
+ mkdir('Xdirdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdirdir'
set opfunc=
bwipe!
- delete('Xdirdir', 'rf')
nunmap <F3>
&rtp = save_rtp
enddef
def Test_use_autoload_import_in_fold_expression()
- mkdir('Xfolddir/autoload', 'p')
+ mkdir('Xfolddir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xfolddir'
set foldexpr= foldtext& foldmethod& debug=
bwipe!
- delete('Xfolddir', 'rf')
&rtp = save_rtp
enddef
export var someText = 'some text'
var notexp = 'bad'
END
- writefile(lines, 'XimportRel.vim')
- writefile(lines, 'XimportRel2.vim')
- writefile(lines, 'XimportRel3.vim')
- writefile(lines, 'XimportRel4.vim')
- writefile(lines, 'XimportRel5.vim')
+ writefile(lines, 'XimportRel.vim', 'D')
+ writefile(lines, 'XimportRel2.vim', 'D')
+ writefile(lines, 'XimportRel3.vim', 'D')
+ writefile(lines, 'XimportRel4.vim', 'D')
+ writefile(lines, 'XimportRel5.vim', 'D')
lines =<< trim END
vim9script
DoIt()
END
v9.CheckScriptFailure(lines, 'E484:')
-
- delete('XimportRel.vim')
- delete('XimportRel2.vim')
- delete('XimportRel3.vim')
- delete('XimportRel4.vim')
- delete('XimportRel5.vim')
enddef
def Test_autoload_import_relative_autoload_dir()
- mkdir('autoload', 'p')
+ mkdir('autoload', 'pR')
var lines =<< trim END
vim9script
export def Bar()
v9.CheckScriptSuccess(lines)
unlet g:called_bar
- delete('autoload', 'rf')
enddef
def Test_autoload_import_deleted()
vim9script
export const FOO = 1
END
- writefile(lines, 'Xa.vim')
+ writefile(lines, 'Xa.vim', 'D')
lines =<< trim END
vim9script
var x = Xa.FOO
END
v9.CheckScriptFailure(lines, 'E484:')
-
- delete('Xa.vim')
enddef
def Test_autoload_import_using_const()
.. v:fname_new .. '>>' .. v:fname_out
enddef
END
- writefile(lines, 'Xdiffexpr')
+ writefile(lines, 'Xdiffexpr', 'D')
lines =<< trim END
vim9script
set diffopt&
bwipe!
bwipe!
- delete('Xdiffexpr')
enddef
def Test_import_in_patchexpr()
call writefile(['output file'], v:fname_out)
enddef
END
- writefile(lines, 'Xpatchexpr')
+ writefile(lines, 'Xpatchexpr', 'D')
lines =<< trim END
vim9script
END
v9.CheckScriptSuccess(lines)
- call writefile(['input file'], 'Xinput')
- call writefile(['diff file'], 'Xdiff')
+ call writefile(['input file'], 'Xinput', 'D')
+ call writefile(['diff file'], 'Xdiff', 'D')
:%bwipe!
edit Xinput
diffpatch Xdiff
call assert_equal('output file', getline(1))
- call delete('Xinput')
- call delete('Xdiff')
- call delete('Xpatchexpr')
set patchexpr&
:%bwipe!
enddef
return 0
enddef
END
- writefile(lines, 'Xformatter')
+ writefile(lines, 'Xformatter', 'D')
lines =<< trim END
vim9script
assert_equal('yes', g:did_format)
bwipe!
- delete('Xformatter')
unlet g:did_format
set formatexpr=
enddef
def Test_import_in_includeexpr()
- writefile(['found it'], 'Xthisfile')
+ writefile(['found it'], 'Xthisfile', 'D')
new
var lines =<< trim END
return substitute(v:fname, 'that', 'this', '')
enddef
END
- writefile(lines, 'Xinclude.vim')
+ writefile(lines, 'Xinclude.vim', 'D')
lines =<< trim END
vim9script
bwipe!
bwipe!
set includeexpr=
- delete('Xinclude.vim')
- delete('Xthisfile')
enddef
def Test_import_in_indentexpr()
return 5
enddef
END
- writefile(lines, 'Xindenter')
+ writefile(lines, 'Xindenter', 'D')
lines =<< trim END
vim9script
bwipe!
set indentexpr= debug=
- delete('Xindenter')
enddef
func Test_import_in_printexpr()
return false
enddef
END
- writefile(lines, 'Xprint.vim')
+ writefile(lines, 'Xprint.vim', 'D')
lines =<< trim END
vim9script
hardcopy dummy args
assert_equal('yes', g:printed)
- delete('Xprint.vim')
set printexpr=
enddef
return false # success
enddef
END
- writefile(lines, 'Xconvert.vim')
+ writefile(lines, 'Xconvert.vim', 'D')
lines =<< trim END
vim9script
END
v9.CheckScriptSuccess(lines)
- writefile(['one', 'two'], 'Xiicfile')
+ writefile(['one', 'two'], 'Xiicfile', 'D')
new Xiicfile
write ++enc=ucase Xiicfile1
assert_equal(['ONE', 'TWO'], readfile('Xiicfile1'))
- delete('Xiicfile')
delete('Xiicfile1')
- delete('Xconvert.vim')
bwipe!
set charconvert&
enddef
return [['Fox', 8], ['Fop', 9]]
enddef
END
- writefile(lines, 'Xsuggest.vim')
+ writefile(lines, 'Xsuggest.vim', 'D')
lines =<< trim END
vim9script
set verbose=1 # report errors
call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2))
- delete('Xsuggest.vim')
set nospell spellsuggest& verbose=0
enddef
return e
enddef
END
- writefile(lines, 'XexportRetarg.vim')
+ writefile(lines, 'XexportRetarg.vim', 'D')
lines =<< trim END
vim9script
import './XexportRetarg.vim'
assert_equal('arg', Lambda())
END
v9.CheckScriptSuccess(lines)
-
- delete('XexportRetarg.vim')
enddef
def Test_export_shadows_global_function()
- mkdir('Xglobdir/autoload', 'p')
+ mkdir('Xglobdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xglobdir'
delfunc g:Shadow
bwipe!
- delete('Xglobdir', 'rf')
&rtp = save_rtp
enddef
return 0
enddef
END
- writefile(export, 'XexportCmd.vim')
+ writefile(export, 'XexportCmd.vim', 'D')
var buf = g:RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', {
rows: 6, wait_for_ruler: 0})
g:WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5)))
- delete('XexportCmd.vim')
g:StopVimInTerminal(buf)
enddef
export def TheFunc(x = 0)
enddef
END
- writefile(lines, 'XExportReload')
+ writefile(lines, 'XExportReload', 'D')
lines =<< trim END
vim9script noclear
g:loadCount += 1
return 'once'
enddef
END
- writefile(lines, 'XReloaded')
+ writefile(lines, 'XReloaded', 'D')
g:loadCount = 0
source XReloaded
assert_equal(1, g:loadCount)
assert_equal(3, g:loadCount)
assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values())
- delete('XReloaded')
- delete('XExportReload')
delfunc g:Values
unlet g:loadCount
def Inner()
enddef
END
- lines->writefile('XreloadScript.vim')
+ lines->writefile('XreloadScript.vim', 'D')
source XreloadScript.vim
lines =<< trim END
END
lines->writefile('XreloadScript.vim')
source XreloadScript.vim
-
- delete('XreloadScript.vim')
enddef
def Test_vim_reload_noclear_arg_count()
Call()
g:didload = 1
END
- lines->writefile('XreloadScript_1.vim')
+ lines->writefile('XreloadScript_1.vim', 'D')
source XreloadScript_1.vim
assert_fails('source XreloadScript_1.vim', 'E1106: One argument too many')
unlet g:didload
Call()
g:didload = 1
END
- lines->writefile('XreloadScript_2.vim')
+ lines->writefile('XreloadScript_2.vim', 'D')
source XreloadScript_2.vim
assert_fails('source XreloadScript_2.vim', 'E1106: 2 arguments too many')
unlet g:didload
Call()
g:didload = 1
END
- lines->writefile('XreloadScript_3.vim')
+ lines->writefile('XreloadScript_3.vim', 'D')
source XreloadScript_3.vim
assert_fails('source XreloadScript_3.vim', 'E1190: One argument too few')
unlet g:didload
Call()
g:didload = 1
END
- lines->writefile('XreloadScript_4.vim')
+ lines->writefile('XreloadScript_4.vim', 'D')
source XreloadScript_4.vim
assert_fails('source XreloadScript_4.vim', 'E1190: 2 arguments too few')
unlet g:didload
-
- delete('XreloadScript_1.vim')
- delete('XreloadScript_2.vim')
- delete('XreloadScript_3.vim')
- delete('XreloadScript_4.vim')
enddef
def Test_vim9_reload_noclear_error()
Call()
g:didload = 1
END
- lines->writefile('XreloadScriptErr.vim')
+ lines->writefile('XreloadScriptErr.vim', 'D')
source XreloadScriptErr.vim
assert_fails('source XreloadScriptErr.vim', 'E1001: Variable not found: ax')
unlet g:didload
- delete('XreloadScriptErr.vim')
enddef
def Test_vim9_reload_import()
return valtwo
enddef
END
- writefile(lines + morelines, 'Xreload.vim')
+ writefile(lines + morelines, 'Xreload.vim', 'D')
source Xreload.vim
source Xreload.vim
source Xreload.vim
writefile(lines, 'Xreload.vim')
assert_fails('source Xreload.vim', 'E1041:', '', 3, 'Xreload.vim')
- delete('Xreload.vim')
delete('Ximport.vim')
enddef
return str .. 'xxx'
enddef
END
- writefile(lines, 'Xreload.vim')
+ writefile(lines, 'Xreload.vim', 'D')
source Xreload.vim
echo g:GetStr()
assert_fails('echo g:GetStr()', 'E1150:')
delfunc g:GetStr
- delete('Xreload.vim')
enddef
" Define CallFunc so that the test can be compiled
g:didTheFunc = 1
enddef
END
- writefile(lines, 'XreloadFunc.vim')
+ writefile(lines, 'XreloadFunc.vim', 'D')
source XreloadFunc.vim
CallFunc
assert_equal(1, g:didTheFunc)
- delete('XreloadFunc.vim')
delcommand CallFunc
unlet g:loadedThis
unlet g:didTheFunc
return arg
enddef
END
- writefile(sortlines, 'Xsort.vim')
+ writefile(sortlines, 'Xsort.vim', 'D')
var lines =<< trim END
vim9script
enddef
Test()
END
- writefile(lines, 'Xscript.vim')
+ writefile(lines, 'Xscript.vim', 'D')
source Xscript.vim
assert_equal([4, 3, 2, 1, 0], g:result)
unlet g:result
END
writefile(lines, 'Xscript.vim')
- delete('Xsort.vim')
- delete('Xscript.vim')
-
var Funcref = function('s:RetSome')
assert_equal('some', Funcref())
enddef
return range(10)->filter(FilterFunc)
enddef
END
- writefile(filterLines, 'Xfilter.vim')
+ writefile(filterLines, 'Xfilter.vim', 'D')
var lines =<< trim END
vim9script
TestDirect()
END
v9.CheckScriptSuccess(lines)
- delete('Xfilter.vim')
enddef
def Test_import_absolute()
'UseExported()',
'g:import_disassembled = execute("disass UseExported")',
]
- writefile(import_lines, 'Ximport_abs.vim')
- writefile(s:export_script_lines, 'Xexport_abs.vim')
+ writefile(import_lines, 'Ximport_abs.vim', 'D')
+ writefile(s:export_script_lines, 'Xexport_abs.vim', 'D')
source Ximport_abs.vim
Undo_export_script_lines()
unlet g:imported_abs
unlet g:import_disassembled
-
- delete('Ximport_abs.vim')
- delete('Xexport_abs.vim')
enddef
def Test_import_rtp()
'import "Xexport_rtp.vim" as rtp',
'g:imported_rtp = rtp.exported',
]
- writefile(import_lines, 'Ximport_rtp.vim')
- mkdir('import', 'p')
+ writefile(import_lines, 'Ximport_rtp.vim', 'D')
+ mkdir('import', 'pR')
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
var save_rtp = &rtp
Undo_export_script_lines()
unlet g:imported_rtp
- delete('Ximport_rtp.vim')
- delete('import', 'rf')
enddef
def Test_import_compile_error()
' return notDefined',
'enddef',
]
- writefile(export_lines, 'Xexported.vim')
+ writefile(export_lines, 'Xexported.vim', 'D')
var import_lines = [
'vim9script',
'enddef',
'defcompile',
]
- writefile(import_lines, 'Ximport.vim')
+ writefile(import_lines, 'Ximport.vim', 'D')
try
source Ximport.vim
assert_match('E1001: Variable not found: notDefined', v:exception)
assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint)
endtry
-
- delete('Xexported.vim')
- delete('Ximport.vim')
enddef
def Test_func_overrules_import_fails()
echo 'imported'
enddef
END
- writefile(export_lines, 'XexportedFunc.vim')
+ writefile(export_lines, 'XexportedFunc.vim', 'D')
var lines =<< trim END
vim9script
defcompile
END
v9.CheckScriptFailure(lines, 'E1236:')
-
- delete('XexportedFunc.vim')
enddef
def Test_source_vim9_from_legacy()
return 'text'
enddef
END
- writefile(vim9_lines, 'Xvim9_script.vim')
+ writefile(vim9_lines, 'Xvim9_script.vim', 'D')
var legacy_lines =<< trim END
source Xvim9_script.vim
call assert_equal('global', global)
call assert_equal('global', g:global)
END
- writefile(legacy_lines, 'Xlegacy_script.vim')
+ writefile(legacy_lines, 'Xlegacy_script.vim', 'D')
source Xlegacy_script.vim
assert_equal('global', g:global)
unlet g:global
-
- delete('Xlegacy_script.vim')
- delete('Xvim9_script.vim')
enddef
def Test_import_vim9_from_legacy()
return 'text'
enddef
END
- writefile(vim9_lines, 'Xvim9_export.vim')
+ writefile(vim9_lines, 'Xvim9_export.vim', 'D')
var legacy_lines =<< trim END
import './Xvim9_export.vim' as vim9
call assert_equal('exported', s:vim9.exported)
call assert_equal('text', s:vim9.GetText())
END
- writefile(legacy_lines, 'Xlegacy_script.vim')
+ writefile(legacy_lines, 'Xlegacy_script.vim', 'D')
source Xlegacy_script.vim
assert_equal('global', g:global)
unlet g:global
-
- delete('Xlegacy_script.vim')
- delete('Xvim9_export.vim')
enddef
def Test_cmdline_win()
# if the Vim syntax highlighting uses Vim9 constructs they can be used from
# the command line window.
- mkdir('rtp/syntax', 'p')
+ mkdir('rtp/syntax', 'pR')
var export_lines =<< trim END
vim9script
export var That = 'yes'
au!
augroup END
&rtp = save_rtp
- delete('rtp', 'rf')
enddef
def Test_import_gone_when_sourced_twice()
g:guard = 1
export var name = 'someName'
END
- writefile(exportlines, 'XexportScript.vim')
+ writefile(exportlines, 'XexportScript.vim', 'D')
var lines =<< trim END
vim9script
return expo.name
enddef
END
- writefile(lines, 'XscriptImport.vim')
+ writefile(lines, 'XscriptImport.vim', 'D')
so XscriptImport.vim
assert_equal('someName', g:GetName())
assert_fails('call g:GetName()', 'E1149:')
delfunc g:GetName
- delete('XexportScript.vim')
- delete('XscriptImport.vim')
unlet g:guard
enddef
enddef
END
- mkdir('Xfulldir/autoload', 'p')
+ mkdir('Xfulldir/autoload', 'pR')
writefile(lines, 'Xfulldir/autoload/some.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xfulldir'
writefile(lines, 'Xfulldir/autoload/Other.vim')
assert_equal('other', g:Other#GetOther())
- delete('Xfulldir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload()
- mkdir('Xaldir/autoload', 'p')
+ mkdir('Xaldir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xaldir'
unlet g:prefixed_loaded
unlet g:expected_loaded
- delete('Xaldir', 'rf')
&rtp = save_rtp
enddef
def Test_import_autoload_not_exported()
- mkdir('Xnimdir/autoload', 'p')
+ mkdir('Xnimdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xnimdir'
END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport')
- delete('Xnimdir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload_call()
- mkdir('Xcalldir/autoload', 'p')
+ mkdir('Xcalldir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xcalldir'
v9.CheckScriptSuccess(lines)
unlet g:result
- delete('Xcalldir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_noclear_autoload()
- mkdir('Xnocdir/autoload', 'p')
+ mkdir('Xnocdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xnocdir'
nnoremap <F3> <ScriptCmd>g:result = double.Func()<CR>
END
g:double_loaded = 'no'
- writefile(lines, 'Xloaddouble')
+ writefile(lines, 'Xloaddouble', 'D')
source Xloaddouble
assert_equal('no', g:double_loaded)
assert_equal(true, g:script_loaded)
assert_equal('called', g:result)
assert_equal('yes', g:double_loaded)
- delete('Xloaddouble')
unlet g:double_loaded
unlet g:script_loaded
unlet g:result
- delete('Xnocdir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload_duplicate()
- mkdir('Xdupdir/autoload', 'p')
+ mkdir('Xdupdir/autoload', 'pR')
var lines =<< trim END
vim9script
END
writefile(lines, 'Xdupdir/autoload/dup6func.vim')
assert_fails('source Xdupdir/autoload/dup6func.vim', 'E1041: Redefining script item: "Func"')
-
- delete('Xdupdir', 'rf')
enddef
def Test_autoload_missing_function_name()
- mkdir('Xmisdir/autoload', 'p')
+ mkdir('Xmisdir/autoload', 'pR')
var lines =<< trim END
vim9script
END
writefile(lines, 'Xmisdir/autoload/loadme.vim')
assert_fails('source Xmisdir/autoload/loadme.vim', 'E129:')
-
- delete('Xmisdir', 'rf')
enddef
def Test_autoload_name_wrong()
def Xscriptname#Func()
enddef
END
- writefile(lines, 'Xscriptname.vim')
+ writefile(lines, 'Xscriptname.vim', 'D')
v9.CheckScriptFailure(lines, 'E746:')
- delete('Xscriptname.vim')
- mkdir('Xwrodir/autoload', 'p')
+ mkdir('Xwrodir/autoload', 'pR')
lines =<< trim END
vim9script
def somescript#Func()
enddef
def Test_import_autoload_postponed()
- mkdir('Xpostdir/autoload', 'p')
+ mkdir('Xpostdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xpostdir'
assert_equal('true', g:loaded_postponed)
unlet g:loaded_postponed
- delete('Xpostdir', 'rf')
&rtp = save_rtp
enddef
def Test_import_autoload_override()
- mkdir('Xoverdir/autoload', 'p')
+ mkdir('Xoverdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xoverdir'
test_override('autoload', 1)
test_override('autoload', 0)
unlet g:loaded_override
- delete('Xoverdir', 'rf')
&rtp = save_rtp
enddef
def Test_autoload_mapping()
- mkdir('Xmapdir/autoload', 'p')
+ mkdir('Xmapdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xmapdir'
nunmap yy
unlet g:toggle_loaded
unlet g:toggle_called
- delete('Xmapdir', 'rf')
&rtp = save_rtp
enddef
" test disassembling an auto-loaded function starting with "debug"
def Test_vim9_autoload_disass()
- mkdir('Xdasdir/autoload', 'p')
+ mkdir('Xdasdir/autoload', 'pR')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdasdir'
END
v9.CheckScriptSuccess(lines)
- delete('Xdasdir', 'rf')
&rtp = save_rtp
enddef
enddef
END
- mkdir('Xauldir/autoload', 'p')
+ mkdir('Xauldir/autoload', 'pR')
writefile(lines, 'Xauldir/autoload/foo.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xauldir'
augroup test
autocmd!
augroup END
- delete('Xauldir', 'rf')
&rtp = save_rtp
enddef
enddef
END
- mkdir('Xcasedir/autoload', 'p')
+ mkdir('Xcasedir/autoload', 'pR')
writefile(lines, 'Xcasedir/autoload/CaseSensitive.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xcasedir'
v9.CheckScriptFailure(lines, 'E1262:')
endif
- delete('Xcasedir', 'rf')
&rtp = save_rtp
enddef
catch /wontmatch/
endtry
END
- call mkdir('Xruntime/autoload', 'p')
+ call mkdir('Xruntime/autoload', 'pR')
call writefile(lines, 'Xruntime/autoload/crash.vim')
# run in a separate Vim to avoid the side effects of assert_fails()
call writefile(['ok'], 'Xdidit')
qall!
END
- writefile(lines, 'Xscript')
+ writefile(lines, 'Xscript', 'D')
g:RunVim([], [], '-S Xscript')
assert_equal(['ok'], readfile('Xdidit'))
delete('Xdidit')
- delete('Xscript')
- delete('Xruntime', 'rf')
lines =<< trim END
vim9script
if !has('unix')
CheckUnix
else
- mkdir('Xto/plugin', 'p')
+ mkdir('Xto/plugin', 'pR')
var lines =<< trim END
vim9script
import autoload 'bar.vim'
END
writefile(lines, 'Xto/plugin/foo.vim')
- mkdir('Xto/autoload', 'p')
+ mkdir('Xto/autoload', 'pR')
lines =<< trim END
vim9script
export def Func(): string
unlet g:resultFunc
unlet g:resultValue
&rtp = save_rtp
- delete('Xto', 'rf')
delete('Xfrom', 'rf')
endif
enddef