aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/clipboard/clipboard_provider_spec.lua14
-rw-r--r--test/functional/job/job_spec.lua49
2 files changed, 61 insertions, 2 deletions
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua
index e7ca183a0e..c5d8f57008 100644
--- a/test/functional/clipboard/clipboard_provider_spec.lua
+++ b/test/functional/clipboard/clipboard_provider_spec.lua
@@ -55,6 +55,12 @@ local function basic_register_test(noblock)
, stuff and some more
some textsome some text, stuff and some more]])
+ -- deleting a line does update ""
+ feed('ggdd""P')
+ expect([[
+ , stuff and some more
+ some textsome some text, stuff and some more]])
+
feed('ggw<c-v>jwyggP')
if noblock then
expect([[
@@ -72,6 +78,7 @@ end
describe('the unnamed register', function()
before_each(clear)
it('works without provider', function()
+ eq('"', eval('v:register'))
basic_register_test()
end)
end)
@@ -227,6 +234,13 @@ describe('clipboard usage', function()
a line]])
end)
+ it('supports v:register and getreg() without parameters', function()
+ eq('*', eval('v:register'))
+ execute("let g:test_clip['*'] = [['some block',''], 'b']")
+ eq('some block', eval('getreg()'))
+ eq('\02210', eval('getregtype()'))
+ end)
+
end)
it('supports :put', function()
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index c517ae4c1b..df989b3ef9 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -61,7 +61,6 @@ describe('jobs', function()
file:write("abc\0def\n")
file:close()
- -- v:job_data preserves NULs.
nvim('command', "let j = jobstart(['cat', '"..filename.."'], g:job_opts)")
eq({'notification', 'stdout', {0, {'abc\ndef', ''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg())
@@ -249,6 +248,52 @@ describe('jobs', function()
eq({'notification', 'wait', {{-2}}}, next_msg())
end)
+ it('can be called recursively', function()
+ source([[
+ let g:opts = {}
+ let g:counter = 0
+ function g:opts.on_stdout(id, msg)
+ if self.state == 0
+ if self.counter < 10
+ call Run()
+ endif
+ let self.state = 1
+ call jobsend(a:id, "line1\n")
+ elseif self.state == 1
+ let self.state = 2
+ call jobsend(a:id, "line2\n")
+ elseif self.state == 2
+ let self.state = 3
+ call jobsend(a:id, "line3\n")
+ else
+ call rpcnotify(g:channel, 'w', printf('job %d closed', self.counter))
+ call jobclose(a:id, 'stdin')
+ endif
+ endfunction
+ function g:opts.on_exit()
+ call rpcnotify(g:channel, 'w', printf('job %d exited', self.counter))
+ endfunction
+ function Run()
+ let g:counter += 1
+ let j = copy(g:opts)
+ let j.state = 0
+ let j.counter = g:counter
+ call jobwait([
+ \ jobstart([&sh, '-c', 'echo ready; cat -'], j),
+ \ ])
+ endfunction
+ ]])
+ execute('call Run()')
+ local r
+ for i = 10, 1, -1 do
+ r = next_msg()
+ eq('job '..i..' closed', r[3][1])
+ r = next_msg()
+ eq('job '..i..' exited', r[3][1])
+ end
+ eq(10, nvim('eval', 'g:counter'))
+ end)
+
describe('with timeout argument', function()
it('will return -1 if the wait timed out', function()
source([[
@@ -292,7 +337,7 @@ describe('jobs', function()
data[i] = data[i]:gsub('\n', '\000')
end
rv = table.concat(data, '\n')
- rv = rv:gsub('\r\n$', '')
+ rv = rv:gsub('\r\n$', ''):gsub('^\r\n', '')
if rv ~= '' then
break
end