comparison src/testdir/test_lambda.vim @ 28515:c6aadb2c4cd7 v8.2.4782

patch 8.2.4782: accessing freed memory Commit: https://github.com/vim/vim/commit/a929c922b1cb7c84ad1b5d1d0fc9a4f7c68ab8e0 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 18 15:21:17 2022 +0100 patch 8.2.4782: accessing freed memory Problem: Accessing freed memory. Solution: Clear evalarg after checking for trailing characters. (issue #10218)
author Bram Moolenaar <Bram@vim.org>
date Mon, 18 Apr 2022 16:30:03 +0200
parents a35d54d01ade
children 2748a023cc37
comparison
equal deleted inserted replaced
28514:0f69ddbdde1f 28515:c6aadb2c4cd7
1 " Test for lambda and closure 1 " Test for lambda and closure
2 2
3 source check.vim 3 source check.vim
4 import './vim9.vim' as v9
4 5
5 func Test_lambda_feature() 6 func Test_lambda_feature()
6 call assert_equal(1, has('lambda')) 7 call assert_equal(1, has('lambda'))
7 endfunc 8 endfunc
8 9
50 sleep 10m 51 sleep 10m
51 endfor 52 endfor
52 53
53 call timer_stop(s:timer_id) 54 call timer_stop(s:timer_id)
54 call assert_true(s:n > m) 55 call assert_true(s:n > m)
56 endfunc
57
58 func Test_lambda_vim9cmd_linebreak()
59 CheckFeature timers
60
61 let lines =<< trim END
62 vim9cmd call timer_start(10, (x) => {
63 # comment
64 g:result = 'done'
65 })
66 END
67 call v9.CheckScriptSuccess(lines)
68 sleep 50m
69 call assert_equal('done', g:result)
70 unlet g:result
55 endfunc 71 endfunc
56 72
57 func Test_lambda_with_partial() 73 func Test_lambda_with_partial()
58 let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two']) 74 let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two'])
59 call assert_equal(['zero', 'one', 'two', 'three'], l:Cb('three')) 75 call assert_equal(['zero', 'one', 'two', 'three'], l:Cb('three'))