Problem:
Subdirectories like "visual", "insert", "normal" encourage people to
separate *related* tests for no good reason.  Typically the _mode_ is
not the relevant topic of a test (and when it is, _then_ create
an appropriate describe() or it()).

Solution:
- Delete the various `test/functional/<mode>/` subdirectories, move
  their tests to more meaningful topics.
- Rename `…/normal/` to `…/editor/`.
  - Move or merge `…/visual/*` and `…/insert/*` tests into here where
    appropriate.
- Rename `…/eval/` to `…/vimscript/`.
  - Move `…/viml/*` into here also.

* test(reorg): insert/* => editor/mode_insert_spec.lua
* test(reorg): cmdline/* => editor/mode_cmdline_spec.lua
* test(reorg): eval core tests => eval_spec.lua
This commit is contained in:
Justin M. Keyes
2021-09-17 09:16:40 -07:00
committed by GitHub
parent d56002f7b7
commit d8de4eb685
67 changed files with 322 additions and 538 deletions

View File

@@ -1,34 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, insert, funcs, eq, feed =
helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
describe('cmdline CTRL-R', function()
before_each(clear)
it('pasting non-special register inserts <CR> *between* lines', function()
insert([[
line1abc
line2somemoretext
]])
-- Yank 2 lines linewise, then paste to cmdline.
feed([[<C-\><C-N>gg0yj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
eq('line1abc\rline2somemoretext', funcs.getcmdline())
-- Yank 2 lines charwise, then paste to cmdline.
feed([[<C-\><C-N>gg05lyvj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
eq('abc\rline2', funcs.getcmdline())
-- Yank 1 line linewise, then paste to cmdline.
feed([[<C-\><C-N>ggyy:<C-R>0]])
-- No <CR> inserted.
eq('line1abc', funcs.getcmdline())
end)
it('pasting special register inserts <CR>, <NL>', function()
feed([[:<C-R>="foo\nbar\rbaz"<CR>]])
eq('foo\nbar\rbaz', funcs.getcmdline())
end)
end)

View File

@@ -1,32 +1,40 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command = helpers.command
local eq = helpers.eq
local expect = helpers.expect
local funcs = helpers.funcs
local eq = helpers.eq
describe('insert-mode', function()
describe('meta-keys #8226 #13042', function()
before_each(function()
clear()
end)
it('CTRL-@', function()
-- Inserts last-inserted text, leaves insert-mode.
it('ALT/META, normal-mode', function()
-- Unmapped ALT-chords behave as ESC+c
insert('hello')
feed('i<C-@>x')
expect('hellhello')
-- C-Space is the same as C-@.
-- CTRL-SPC inserts last-inserted text, leaves insert-mode.
feed('i<C-Space>x')
expect('hellhellhello')
-- CTRL-A inserts last inserted text
feed('i<C-A>x')
expect('hellhellhellhelloxo')
feed('0<A-x><M-x>')
expect('llo')
-- Mapped ALT-chord behaves as mapped.
command('nnoremap <M-l> Ameta-l<Esc>')
command('nnoremap <A-j> Aalt-j<Esc>')
feed('<A-j><M-l>')
expect('lloalt-jmeta-l')
end)
it('ALT/META #8213', function()
it('ALT/META, visual-mode', function()
-- Unmapped ALT-chords behave as ESC+c
insert('peaches')
feed('viw<A-x>viw<M-x>')
expect('peach')
-- Mapped ALT-chord behaves as mapped.
command('vnoremap <M-l> Ameta-l<Esc>')
command('vnoremap <A-j> Aalt-j<Esc>')
feed('viw<A-j>viw<M-l>')
expect('peachalt-jmeta-l')
end)
it('ALT/META insert-mode', function()
-- Mapped ALT-chord behaves as mapped.
command('inoremap <M-l> meta-l')
command('inoremap <A-j> alt-j')

View File

@@ -1,8 +1,41 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, meths, funcs, eq =
helpers.clear, helpers.meths, helpers.funcs, helpers.eq
-- Cmdline-mode tests.
describe('history support code', function()
local helpers = require('test.functional.helpers')(after_each)
local clear, insert, funcs, eq, feed =
helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
local meths = helpers.meths
describe('cmdline CTRL-R', function()
before_each(clear)
it('pasting non-special register inserts <CR> *between* lines', function()
insert([[
line1abc
line2somemoretext
]])
-- Yank 2 lines linewise, then paste to cmdline.
feed([[<C-\><C-N>gg0yj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
eq('line1abc\rline2somemoretext', funcs.getcmdline())
-- Yank 2 lines charwise, then paste to cmdline.
feed([[<C-\><C-N>gg05lyvj:<C-R>0]])
-- <CR> inserted between lines, NOT after the final line.
eq('abc\rline2', funcs.getcmdline())
-- Yank 1 line linewise, then paste to cmdline.
feed([[<C-\><C-N>ggyy:<C-R>0]])
-- No <CR> inserted.
eq('line1abc', funcs.getcmdline())
end)
it('pasting special register inserts <CR>, <NL>', function()
feed([[:<C-R>="foo\nbar\rbaz"<CR>]])
eq('foo\nbar\rbaz', funcs.getcmdline())
end)
end)
describe('cmdline history', function()
before_each(clear)
it('correctly clears start of the history', function()

View File

@@ -0,0 +1,89 @@
-- Insert-mode tests.
local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local expect = helpers.expect
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local meths = helpers.meths
describe('insert-mode', function()
before_each(function()
clear()
end)
it('CTRL-@', function()
-- Inserts last-inserted text, leaves insert-mode.
insert('hello')
feed('i<C-@>x')
expect('hellhello')
-- C-Space is the same as C-@.
-- CTRL-SPC inserts last-inserted text, leaves insert-mode.
feed('i<C-Space>x')
expect('hellhellhello')
-- CTRL-A inserts last inserted text
feed('i<C-A>x')
expect('hellhellhellhelloxo')
end)
describe('Ctrl-R', function()
it('works', function()
command("let @@ = 'test'")
feed('i<C-r>"')
expect('test')
end)
it('works with multi-byte text', function()
command("let @@ = 'påskägg'")
feed('i<C-r>"')
expect('påskägg')
end)
end)
describe('Ctrl-O', function()
it('enters command mode for one command', function()
feed('ihello world<C-o>')
feed(':let ctrlo = "test"<CR>')
feed('iii')
expect('hello worldiii')
eq(1, eval('ctrlo ==# "test"'))
end)
it('re-enters insert mode at the end of the line when running startinsert', function()
-- #6962
feed('ihello world<C-o>')
feed(':startinsert<CR>')
feed('iii')
expect('hello worldiii')
end)
it('re-enters insert mode at the beginning of the line when running startinsert', function()
insert('hello world')
feed('0<C-o>')
feed(':startinsert<CR>')
feed('aaa')
expect('aaahello world')
end)
it('re-enters insert mode in the middle of the line when running startinsert', function()
insert('hello world')
feed('bi<C-o>')
feed(':startinsert<CR>')
feed('ooo')
expect('hello oooworld')
end)
it("doesn't cancel Ctrl-O mode when processing event", function()
feed('iHello World<c-o>')
eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event
eq(2, eval('1+1')) -- causes K_EVENT key
eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode
feed('dd')
eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode
expect('') -- executed the command
end)
end)
end)

View File

@@ -1,3 +1,5 @@
-- Visual-mode tests.
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
@@ -6,10 +8,10 @@ local expect = helpers.expect
local feed = helpers.feed
local meths = helpers.meths
describe('select-mode Ctrl-O', function()
describe('visual-mode', function()
before_each(clear)
it("doesn't cancel Ctrl-O mode when processing event", function()
it("select-mode Ctrl-O doesn't cancel Ctrl-O mode when processing event #15688", function()
feed('iHello World<esc>gh<c-o>')
eq({mode='vs', blocking=false}, meths.get_mode()) -- fast event
eq(2, eval('1+1')) -- causes K_EVENT key
@@ -21,3 +23,4 @@ describe('select-mode Ctrl-O', function()
expect('h') -- selection is the whole line and is replaced
end)
end)

View File

@@ -1,50 +0,0 @@
local lfs = require('lfs')
local helpers = require('test.functional.helpers')(after_each)
local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq
local write_file = helpers.write_file
describe("backtick expansion", function()
setup(function()
clear()
lfs.mkdir("test-backticks")
write_file("test-backticks/file1", "test file 1")
write_file("test-backticks/file2", "test file 2")
write_file("test-backticks/file3", "test file 3")
lfs.mkdir("test-backticks/subdir")
write_file("test-backticks/subdir/file4", "test file 4")
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
command('silent cd test-backticks')
end)
teardown(function()
helpers.rmdir('test-backticks')
end)
it("with default 'shell'", function()
if helpers.iswin() then
command(":silent args `dir /b *2`")
else
command(":silent args `echo ***2`")
end
eq({ "file2", }, eval("argv()"))
if helpers.iswin() then
command(":silent args `dir /s/b *4`")
eq({ "subdir\\file4", }, eval("map(argv(), 'fnamemodify(v:val, \":.\")')"))
else
command(":silent args `echo */*4`")
eq({ "subdir/file4", }, eval("argv()"))
end
end)
it("with shell=fish", function()
if eval("executable('fish')") == 0 then
pending('missing "fish" command')
return
end
command("set shell=fish")
command(":silent args `echo ***2`")
eq({ "file2", }, eval("argv()"))
command(":silent args `echo */*4`")
eq({ "subdir/file4", }, eval("argv()"))
end)
end)

View File

@@ -1,37 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local matches = helpers.matches
local exc_exec = helpers.exc_exec
local iswin = helpers.iswin
local eval = helpers.eval
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
local range = helpers.funcs.range
before_each(clear)
it('printf()', function()
local printf = helpers.funcs.printf
local rep = helpers.funcs['repeat']
local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'
eq(expected, printf(rep('%d,', max_func_args-1), unpack(range(2, max_func_args))))
local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
eq('Vim(call):E740: Too many arguments for function printf', ret)
end)
it('rpcnotify()', function()
local rpcnotify = helpers.funcs.rpcnotify
local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args)))
eq(1, ret)
ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
eq('Vim(call):E740: Too many arguments for function rpcnotify', ret)
end)
end)
it('windowsversion()', function()
clear()
matches(iswin() and '^%d+%.%d+$' or '^$', eval('windowsversion()'))
end)

View File

@@ -1,61 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local command = helpers.command
local meths = helpers.meths
local clear = helpers.clear
local sleep = helpers.sleep
local poke_eventloop = helpers.poke_eventloop
local feed = helpers.feed
local eq = helpers.eq
local dur
local min_dur = 8
local len = 131072
describe('List support code', function()
if not pending('does not actually allows interrupting with just got_int', function() end) then return end
-- The following tests are confirmed to work with os_breakcheck() just before
-- `if (got_int) {break;}` in tv_list_copy and list_join_inner() and not to
-- work without.
setup(function()
clear()
dur = 0
while true do
command(([[
let rt = reltime()
let bl = range(%u)
let dur = reltimestr(reltime(rt))
]]):format(len))
dur = tonumber(meths.get_var('dur'))
if dur >= min_dur then
-- print(('Using len %u, dur %g'):format(len, dur))
break
else
len = len * 2
end
end
end)
it('allows interrupting copy', function()
feed(':let t_rt = reltime()<CR>:let t_bl = copy(bl)<CR>')
sleep(min_dur / 16 * 1000)
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
local t_dur = tonumber(meths.get_var('t_dur'))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
end
end)
it('allows interrupting join', function()
feed(':let t_rt = reltime()<CR>:let t_j = join(bl)<CR>')
sleep(min_dur / 16 * 1000)
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
local t_dur = tonumber(meths.get_var('t_dur'))
print(('t_dur: %g'):format(t_dur))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
end
end)
end)

View File

@@ -1,54 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
local expect = helpers.expect
local feed = helpers.feed
local insert = helpers.insert
local meths = helpers.meths
describe('insert-mode Ctrl-O', function()
before_each(clear)
it('enters command mode for one command', function()
feed('ihello world<C-o>')
feed(':let ctrlo = "test"<CR>')
feed('iii')
expect('hello worldiii')
eq(1, eval('ctrlo ==# "test"'))
end)
it('re-enters insert mode at the end of the line when running startinsert', function()
-- #6962
feed('ihello world<C-o>')
feed(':startinsert<CR>')
feed('iii')
expect('hello worldiii')
end)
it('re-enters insert mode at the beginning of the line when running startinsert', function()
insert('hello world')
feed('0<C-o>')
feed(':startinsert<CR>')
feed('aaa')
expect('aaahello world')
end)
it('re-enters insert mode in the middle of the line when running startinsert', function()
insert('hello world')
feed('bi<C-o>')
feed(':startinsert<CR>')
feed('ooo')
expect('hello oooworld')
end)
it("doesn't cancel Ctrl-O mode when processing event", function()
feed('iHello World<c-o>')
eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event
eq(2, eval('1+1')) -- causes K_EVENT key
eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode
feed('dd')
eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode
expect('') -- executed the command
end)
end)

View File

@@ -1,19 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, feed = helpers.clear, helpers.feed
local expect, command = helpers.expect, helpers.command
describe('insert-mode Ctrl-R', function()
before_each(clear)
it('works', function()
command("let @@ = 'test'")
feed('i<C-r>"')
expect('test')
end)
it('works with multi-byte text', function()
command("let @@ = 'påskägg'")
feed('i<C-r>"')
expect('påskägg')
end)
end)

View File

@@ -1,22 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command = helpers.command
local expect = helpers.expect
describe('meta-keys-in-normal-mode', function()
before_each(function()
clear()
end)
it('ALT/META', function()
-- Unmapped ALT-chords behave as Esc+c
insert('hello')
feed('0<A-x><M-x>')
expect('llo')
-- Mapped ALT-chord behaves as mapped.
command('nnoremap <M-l> Ameta-l<Esc>')
command('nnoremap <A-j> Aalt-j<Esc>')
feed('<A-j><M-l>')
expect('lloalt-jmeta-l')
end)
end)

View File

@@ -1,216 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
local dedent = helpers.dedent
local redir_exec = helpers.redir_exec
before_each(clear)
local function check_func(fname, body, indent)
if type(body) == 'number' then
body = ('return %i'):format(body)
end
eq(dedent(([[
function %s()%s
endfunction]]
), 3):format(
fname,
body and ('\n1' .. (' '):rep(2 + (indent or 8)) .. body) or ''),
redir_exec('function ' .. fname))
end
describe(':endfunction', function()
it('accepts bang', function()
eq('', redir_exec([[
function F()
endfunction!
]]))
check_func('F')
eq('', redir_exec([[
function! F()
return 1
endfunction!
]]))
check_func('F', 1)
end)
it('accepts comments', function()
eq('', redir_exec([[
function F1()
endfunction " Comment
]]))
check_func('F1')
eq('', redir_exec([[
function F2()
endfunction " }}}
]]))
check_func('F2')
eq('', redir_exec([[
function F3()
endfunction " F3
]]))
check_func('F3')
eq('', redir_exec([[
function F4()
endfunction! " F4
]]))
check_func('F4')
eq('', redir_exec([[
function! F4()
return 2
endfunction! " F4
]]))
check_func('F4', 2)
end)
it('accepts function name', function()
eq('', redir_exec([[
function F0()
endfunction F0
]]))
check_func('F0')
eq('', redir_exec([[
function F1()
endfunction! F1
]]))
check_func('F1')
eq('', redir_exec([[
function! F2()
endfunction! F2
]]))
check_func('F2')
eq('', redir_exec([[
function! F2()
return 3
endfunction! F2
]]))
check_func('F2', 3)
end)
it('accepts weird characters', function()
eq('', redir_exec([[
function F1()
endfunction: }}}
]]))
check_func('F1')
-- From accurev
eq('', redir_exec([[
function F2()
endfunction :}}}
]]))
check_func('F2')
-- From cream-vimabbrev
eq('', redir_exec([[
function F3()
endfunction 1}}}
]]))
check_func('F3')
-- From pyunit
eq('', redir_exec([[
function F4()
endfunction # }}}
]]))
check_func('F4')
-- From vim-lldb
eq('', redir_exec([[
function F5()
endfunction()
]]))
check_func('F5')
-- From vim-mail
eq('', redir_exec([[
function F6()
endfunction;
]]))
check_func('F6')
end)
it('accepts commented bar', function()
eq('', redir_exec([[
function F1()
endfunction " F1 | echo 42
]]))
check_func('F1')
eq('', redir_exec([[
function! F1()
return 42
endfunction! " F1 | echo 42
]]))
check_func('F1', 42)
end)
it('accepts uncommented bar', function()
eq('\n42', redir_exec([[
function F1()
endfunction | echo 42
]]))
check_func('F1')
end)
it('allows running multiple commands', function()
eq('\n2', redir_exec([[
function F1()
echo 2
endfunction
call F1()
]]))
check_func('F1', 'echo 2')
eq('\n2\n3\n4', redir_exec([[
function F2()
echo 2
endfunction F2
function F3()
echo 3
endfunction " F3
function! F4()
echo 4
endfunction!
call F2()
call F3()
call F4()
]]))
check_func('F2', 'echo 2')
check_func('F3', 'echo 3')
check_func('F4', 'echo 4')
end)
it('allows running multiple commands with only one character in between',
function()
eq('\n3', redir_exec(dedent([[
function! F1()
echo 3
endfunction!
call F1()]])))
check_func('F1', 'echo 3', 2)
eq('\n4', redir_exec(dedent([[
function F5()
echo 4
endfunction
call F5()]])))
check_func('F5', 'echo 4', 2)
eq('\n5', redir_exec(dedent([[
function F6()
echo 5
endfunction " TEST
call F6()]])))
check_func('F6', 'echo 5', 2)
eq('\n6', redir_exec(dedent([[
function F7()
echo 6
endfunction F7
call F7()]])))
check_func('F7', 'echo 6', 2)
eq('\n2\n3\n4', redir_exec(dedent([[
function F2()
echo 2
endfunction F2
function F3()
echo 3
endfunction " F3
function! F4()
echo 4
endfunction!
call F2()
call F3()
call F4()]])))
check_func('F2', 'echo 2', 2)
check_func('F3', 'echo 3', 2)
check_func('F4', 'echo 4', 2)
end)
end)
-- vim: foldmarker=▶,▲

View File

@@ -0,0 +1,146 @@
-- Tests for core Vimscript "eval" behavior.
--
-- See also:
-- let_spec.lua
-- null_spec.lua
-- operators_spec.lua
--
-- Tests for the Vimscript |functions| library should live in:
-- test/functional/vimscript/<funcname>_spec.lua
-- test/functional/vimscript/functions_spec.lua
local helpers = require('test.functional.helpers')(after_each)
local lfs = require('lfs')
local clear = helpers.clear
local eq = helpers.eq
local exc_exec = helpers.exc_exec
local eval = helpers.eval
local command = helpers.command
local write_file = helpers.write_file
local meths = helpers.meths
local sleep = helpers.sleep
local poke_eventloop = helpers.poke_eventloop
local feed = helpers.feed
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
local range = helpers.funcs.range
before_each(clear)
it('printf()', function()
local printf = helpers.funcs.printf
local rep = helpers.funcs['repeat']
local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'
eq(expected, printf(rep('%d,', max_func_args-1), unpack(range(2, max_func_args))))
local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
eq('Vim(call):E740: Too many arguments for function printf', ret)
end)
it('rpcnotify()', function()
local rpcnotify = helpers.funcs.rpcnotify
local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args)))
eq(1, ret)
ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
eq('Vim(call):E740: Too many arguments for function rpcnotify', ret)
end)
end)
describe("backtick expansion", function()
setup(function()
clear()
lfs.mkdir("test-backticks")
write_file("test-backticks/file1", "test file 1")
write_file("test-backticks/file2", "test file 2")
write_file("test-backticks/file3", "test file 3")
lfs.mkdir("test-backticks/subdir")
write_file("test-backticks/subdir/file4", "test file 4")
-- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
command('silent cd test-backticks')
end)
teardown(function()
helpers.rmdir('test-backticks')
end)
it("with default 'shell'", function()
if helpers.iswin() then
command(":silent args `dir /b *2`")
else
command(":silent args `echo ***2`")
end
eq({ "file2", }, eval("argv()"))
if helpers.iswin() then
command(":silent args `dir /s/b *4`")
eq({ "subdir\\file4", }, eval("map(argv(), 'fnamemodify(v:val, \":.\")')"))
else
command(":silent args `echo */*4`")
eq({ "subdir/file4", }, eval("argv()"))
end
end)
it("with shell=fish", function()
if eval("executable('fish')") == 0 then
pending('missing "fish" command')
return
end
command("set shell=fish")
command(":silent args `echo ***2`")
eq({ "file2", }, eval("argv()"))
command(":silent args `echo */*4`")
eq({ "subdir/file4", }, eval("argv()"))
end)
end)
describe('List support code', function()
local dur
local min_dur = 8
local len = 131072
if not pending('does not actually allows interrupting with just got_int', function() end) then return end
-- The following tests are confirmed to work with os_breakcheck() just before
-- `if (got_int) {break;}` in tv_list_copy and list_join_inner() and not to
-- work without.
setup(function()
clear()
dur = 0
while true do
command(([[
let rt = reltime()
let bl = range(%u)
let dur = reltimestr(reltime(rt))
]]):format(len))
dur = tonumber(meths.get_var('dur'))
if dur >= min_dur then
-- print(('Using len %u, dur %g'):format(len, dur))
break
else
len = len * 2
end
end
end)
it('allows interrupting copy', function()
feed(':let t_rt = reltime()<CR>:let t_bl = copy(bl)<CR>')
sleep(min_dur / 16 * 1000)
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
local t_dur = tonumber(meths.get_var('t_dur'))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
end
end)
it('allows interrupting join', function()
feed(':let t_rt = reltime()<CR>:let t_j = join(bl)<CR>')
sleep(min_dur / 16 * 1000)
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
local t_dur = tonumber(meths.get_var('t_dur'))
print(('t_dur: %g'):format(t_dur))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
end
end)
end)

View File

@@ -0,0 +1,20 @@
-- Tests for misc Vimscript |functions|.
--
-- If a function is non-trivial, consider moving its spec to:
-- test/functional/vimscript/<funcname>_spec.lua
--
-- Core "eval" tests live in eval_spec.lua.
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eval = helpers.eval
local iswin = helpers.iswin
local matches = helpers.matches
before_each(clear)
it('windowsversion()', function()
clear()
matches(iswin() and '^%d+%.%d+$' or '^$', eval('windowsversion()'))
end)

View File

@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local exc_exec, source = helpers.exc_exec, helpers.source
describe('viml', function()
describe('vimscript', function()
before_each(clear)
it('parses `<SID>` with turkish locale', function()

View File

@@ -1,22 +0,0 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command = helpers.command
local expect = helpers.expect
describe('meta-keys-in-visual-mode', function()
before_each(function()
clear()
end)
it('ALT/META', function()
-- Unmapped ALT-chords behave as Esc+c
insert('peaches')
feed('viw<A-x>viw<M-x>')
expect('peach')
-- Mapped ALT-chord behaves as mapped.
command('vnoremap <M-l> Ameta-l<Esc>')
command('vnoremap <A-j> Aalt-j<Esc>')
feed('viw<A-j>viw<M-l>')
expect('peachalt-jmeta-l')
end)
end)