aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/channels_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2017-11-27 13:01:49 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2017-12-23 14:02:00 +0100
commit308dd53783314103710a37c9809eddb78279eab4 (patch)
tree569d813e9efdff03fd43b72da88a7d786ab06d60 /test/functional/core/channels_spec.lua
parentaa951b14893d8a30ec3bad6fb4b7064ccda16d5c (diff)
downloadrneovim-308dd53783314103710a37c9809eddb78279eab4.tar.gz
rneovim-308dd53783314103710a37c9809eddb78279eab4.tar.bz2
rneovim-308dd53783314103710a37c9809eddb78279eab4.zip
channel: check for existance before trying to set key
This avoids an error message in async context, where it is not safe.
Diffstat (limited to 'test/functional/core/channels_spec.lua')
-rw-r--r--test/functional/core/channels_spec.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua
index 765e3c5919..e9fc88c01b 100644
--- a/test/functional/core/channels_spec.lua
+++ b/test/functional/core/channels_spec.lua
@@ -246,6 +246,22 @@ describe('channels', function()
eq({"notification", "exit", {id, 0, {'10 PRINT "NVIM"',
'20 GOTO 10', ''}}}, next_msg())
+ -- if dict is reused the new value is not stored,
+ -- but nvim also does not crash
+ command("let id = jobstart(['cat'], g:job_opts)")
+ id = eval("g:id")
+
+ command([[call chansend(id, "cat text\n")]])
+ sleep(10)
+ command("call chanclose(id, 'stdin')")
+
+ -- old value was not overwritten
+ eq({"notification", "exit", {id, 0, {'10 PRINT "NVIM"',
+ '20 GOTO 10', ''}}}, next_msg())
+
+ -- and an error was thrown.
+ eq("E5210: dict key 'stdout' already set for buffered stream in channel "..id, eval('v:errmsg'))
+
-- reset dictionary
source([[
let g:job_opts = {
@@ -261,6 +277,5 @@ describe('channels', function()
-- works correctly with no output
eq({"notification", "exit", {id, 1, {''}}}, next_msg())
-
end)
end)