comparison src/testdir/test_lambda.vim @ 9721:79862f44c647 v7.4.2136

commit https://github.com/vim/vim/commit/580164481924ed8611eb79f0247a0eb1ca0b3b9a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 31 18:30:22 2016 +0200 patch 7.4.2136 Problem: Closure function fails. Solution: Don't reset uf_scoped when it points to another funccal.
author Christian Brabandt <cb@256bit.org>
date Sun, 31 Jul 2016 18:45:06 +0200
parents 4a7a88404076
children 80ac9cf77c9b
comparison
equal deleted inserted replaced
9720:8c110d08b87f 9721:79862f44c647
245 endfunction 245 endfunction
246 246
247 call assert_false(has_key(s:foo(), 'x')) 247 call assert_false(has_key(s:foo(), 'x'))
248 call test_garbagecollect_now() 248 call test_garbagecollect_now()
249 endfunction 249 endfunction
250
251 function! LambdaFoo()
252 let x = 0
253 function! LambdaBar() closure
254 let x += 1
255 return x
256 endfunction
257 return function('LambdaBar')
258 endfunction
259
260 func Test_closure_refcount()
261 let g:Count = LambdaFoo()
262 call test_garbagecollect_now()
263 call assert_equal(1, g:Count())
264 let g:Count2 = LambdaFoo()
265 call test_garbagecollect_now()
266 call assert_equal(1, g:Count2())
267 call assert_equal(2, g:Count())
268 call assert_equal(3, g:Count2())
269
270 " This causes memory access errors.
271 " delfunc LambdaFoo
272 " delfunc LambdaBar
273 endfunc