mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-02-05 11:33:15 +01:00
Problem: tests: too many imports in the test suite Solution: Clean up the imported scripts Most tests make use of check.vim, so let's just source it once in runtest.vim instead of having each test manually source it. runtest.vim already sources shared.vim, which again sources view_util.vim, so we don't need to source those two common dependencies in all the other tests And then check.vim sources term_util.vim already, so we can in addition drop sourcing it explicitly in each single test script. Note: test_expand_func.vim had to be updated to account for the changed number of sourced files. And finally check.vim uses line-continuation so let's also explicitly enable line continuation via the 'cpo' option value. related: #17677 Signed-off-by: Christian Brabandt <cb@256bit.org>
61 lines
1.5 KiB
VimL
61 lines
1.5 KiB
VimL
" Test for Vim9 script with failures, causing memory leaks to be reported.
|
|
" The leaks happen after a fork() and can be ignored.
|
|
|
|
def Test_assignment()
|
|
if !has('channel')
|
|
CheckFeature channel
|
|
else
|
|
var chan1: channel
|
|
var job1: job
|
|
var job2: job = job_start('willfail')
|
|
endif
|
|
enddef
|
|
|
|
" Unclear why this test causes valgrind to report problems.
|
|
def Test_job_info_return_type()
|
|
if !has('job')
|
|
CheckFeature job
|
|
else
|
|
var job: job = job_start(&shell)
|
|
var jobs = job_info()
|
|
assert_equal('list<job>', typename(jobs))
|
|
assert_equal('dict<any>', typename(job_info(jobs[0])))
|
|
job_stop(job)
|
|
endif
|
|
enddef
|
|
|
|
" Using "idx" from a legacy global function does not work.
|
|
" This caused a crash when called from legacy context.
|
|
" This creates a dict that contains a partial that refers to the dict, causing
|
|
" valgrind to report "possibly leaked memory".
|
|
func Test_partial_call_fails()
|
|
let lines =<< trim END
|
|
vim9script
|
|
|
|
var l = ['a', 'b', 'c']
|
|
def Iter(container: any): any
|
|
var idx = -1
|
|
var obj = {state: container}
|
|
def g:NextItem__(self: dict<any>): any
|
|
++idx
|
|
return self.state[idx]
|
|
enddef
|
|
obj.__next__ = function('g:NextItem__', [obj])
|
|
return obj
|
|
enddef
|
|
|
|
var it = Iter(l)
|
|
echo it.__next__()
|
|
END
|
|
call writefile(lines, 'XpartialCall', 'D')
|
|
let caught = 'no'
|
|
try
|
|
source XpartialCall
|
|
catch /E1248:/
|
|
let caught = 'yes'
|
|
endtry
|
|
call assert_equal('yes', caught)
|
|
delfunc g:NextItem__
|
|
endfunc
|
|
|