comparison src/testdir/test_vim9_class.vim @ 31835:5ce5d78afcc9 v9.0.1250

patch 9.0.1250: cannot use an object method with :defer Commit: https://github.com/vim/vim/commit/8dbab1d8ceb82a0fb693a1b7fcb57a2dfb4de068 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 27 20:14:02 2023 +0000 patch 9.0.1250: cannot use an object method with :defer Problem: Cannot use an object method with :defer. (Ernie Rael) Solution: Find the object method and generate code to call it. (closes #11886)
author Bram Moolenaar <Bram@vim.org>
date Fri, 27 Jan 2023 21:15:03 +0100
parents 3516e35f409f
children ffa11e2757e7
comparison
equal deleted inserted replaced
31834:8d782c45028a 31835:5ce5d78afcc9
1329 assert_equal(['A'], g:result) 1329 assert_equal(['A'], g:result)
1330 END 1330 END
1331 v9.CheckScriptSuccess(lines) 1331 v9.CheckScriptSuccess(lines)
1332 enddef 1332 enddef
1333 1333
1334 def Test_defer_with_object()
1335 var lines =<< trim END
1336 vim9script
1337
1338 class CWithEE
1339 def Enter()
1340 g:result ..= "entered/"
1341 enddef
1342 def Exit()
1343 g:result ..= "exited"
1344 enddef
1345 endclass
1346
1347 def With(ee: CWithEE, F: func)
1348 ee.Enter()
1349 defer ee.Exit()
1350 F()
1351 enddef
1352
1353 g:result = ''
1354 var obj = CWithEE.new()
1355 obj->With(() => {
1356 g:result ..= "called/"
1357 })
1358 assert_equal('entered/called/exited', g:result)
1359 END
1360 v9.CheckScriptSuccess(lines)
1361 unlet g:result
1362 enddef
1363
1334 1364
1335 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 1365 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker