mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
more tests
This commit is contained in:
parent
d6cac809b0
commit
1c5e347b8c
@ -397,4 +397,53 @@ describe('VimL dictionary notifications', function()
|
|||||||
eq("Vim(call):Couldn't find a watcher matching key and callback", eval('g:exc'))
|
eq("Vim(call):Couldn't find a watcher matching key and callback", eval('g:exc'))
|
||||||
end)
|
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)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user