@@ -386,6 +386,70 @@ func Test_normal09_operatorfunc()
386386 norm V10j,,
387387 call assert_equal (22 , g: a )
388388
389+ " Use a lambda function for 'opfunc'
390+ unmap <buffer> ,,
391+ call cursor (1 , 1 )
392+ let g: a= 0
393+ nmap <buffer> <silent> ,, :set opfunc={type\ ->\ CountSpaces(type)}<CR> g@
394+ vmap <buffer> <silent> ,, :<C-U> call CountSpaces(visualmode(), 1)<CR>
395+ 50
396+ norm V2j,,
397+ call assert_equal (6 , g: a )
398+ norm V,,
399+ call assert_equal (2 , g: a )
400+ norm ,,l
401+ call assert_equal (0 , g: a )
402+ 50
403+ exe " norm 0\<c-v> 10j2l,,"
404+ call assert_equal (11 , g: a )
405+ 50
406+ norm V10j,,
407+ call assert_equal (22 , g: a )
408+
409+ " use a partial function for 'opfunc'
410+ let g: OpVal = 0
411+ func ! Test_opfunc1 (x , y , type )
412+ let g: OpVal = a: x + a: y
413+ endfunc
414+ set opfunc = function (' Test_opfunc1' ,\ [5 ,\ 7 ])
415+ normal ! g @l
416+ call assert_equal (12 , g: OpVal )
417+ " delete the function and try to use g@
418+ delfunc Test_opfunc1
419+ call test_garbagecollect_now ()
420+ call assert_fails (' normal! g@l' , ' E117:' )
421+ set opfunc =
422+
423+ " use a funcref for 'opfunc'
424+ let g: OpVal = 0
425+ func ! Test_opfunc2 (x , y , type )
426+ let g: OpVal = a: x + a: y
427+ endfunc
428+ set opfunc = funcref (' Test_opfunc2' ,\ [4 ,\ 3 ])
429+ normal ! g @l
430+ call assert_equal (7 , g: OpVal )
431+ " delete the function and try to use g@
432+ delfunc Test_opfunc2
433+ call test_garbagecollect_now ()
434+ call assert_fails (' normal! g@l' , ' E933:' )
435+ set opfunc =
436+
437+ " Try to use a function with two arguments for 'operatorfunc'
438+ let g: OpVal = 0
439+ func ! Test_opfunc3 (x , y )
440+ let g: OpVal = 4
441+ endfunc
442+ set opfunc = Test_opfunc3
443+ call assert_fails (' normal! g@l' , ' E119:' )
444+ call assert_equal (0 , g: OpVal )
445+ set opfunc =
446+ delfunc Test_opfunc3
447+ unlet g: OpVal
448+
449+ " Try to use a lambda function with two arguments for 'operatorfunc'
450+ set opfunc = {x ,\ y \ - >\ ' done' }
451+ call assert_fails (' normal! g@l' , ' E119:' )
452+
389453 " clean up
390454 unmap <buffer> ,,
391455 set opfunc =
0 commit comments