diff options
author | Daniel Hahler <git@thequod.de> | 2019-12-02 13:38:58 +0100 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-03-30 21:55:51 -0400 |
commit | 1c5e347b8c2a63a2c971c153e7baf1ec052080e3 (patch) | |
tree | b48676cc135a279c895be86a3cd9895b6005b463 | |
parent | d6cac809b009e7066c8761b1466fe08378146d22 (diff) | |
download | rneovim-1c5e347b8c2a63a2c971c153e7baf1ec052080e3.tar.gz rneovim-1c5e347b8c2a63a2c971c153e7baf1ec052080e3.tar.bz2 rneovim-1c5e347b8c2a63a2c971c153e7baf1ec052080e3.zip |
more tests
-rw-r--r-- | test/functional/ex_cmds/dict_notifications_spec.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index 6830587961..e5c9a20db3 100644 --- a/test/functional/ex_cmds/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -397,4 +397,53 @@ describe('VimL dictionary notifications', function() eq("Vim(call):Couldn't find a watcher matching key and callback", eval('g:exc')) end) + it('does not call watcher added in callback', function() + source([[ + let g:d = {} + let g:calls = [] + + function! W1(...) abort + call add(g:calls, 'W1') + call dictwatcheradd(g:d, '*', function('W2')) + endfunction + + function! W2(...) abort + call add(g:calls, 'W2') + endfunction + + call dictwatcheradd(g:d, '*', function('W1')) + let g:d.foo = 23 + ]]) + eq(23, eval('g:d.foo')) + eq({"W1"}, eval('g:calls')) + end) + + it('calls watcher deleted in callback', function() + source([[ + let g:d = {} + let g:calls = [] + + function! W1(...) abort + call add(g:calls, "W1") + call dictwatcherdel(g:d, '*', function('W2')) + endfunction + + function! W2(...) abort + call add(g:calls, "W2") + endfunction + + call dictwatcheradd(g:d, '*', function('W1')) + call dictwatcheradd(g:d, '*', function('W2')) + let g:d.foo = 123 + + unlet g:d + let g:d = {} + call dictwatcheradd(g:d, '*', function('W2')) + call dictwatcheradd(g:d, '*', function('W1')) + let g:d.foo = 123 + ]]) + eq(123, eval('g:d.foo')) + eq({"W1", "W2", "W2", "W1"}, eval('g:calls')) + end) + end) |