mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:8.2.0615: regexp benchmark stest is old style (#20940)
Problem: Regexp benchmark stest is old style.
Solution: Make it a new style test. Fix using a NULL list. Add more tests.
(Yegappan Lakshmanan, closes vim/vim#5963)
ad48e6c159
N/A patches:
vim-patch:9.0.0829: wrong counts in macro comment
This commit is contained in:
parent
daf9a63d67
commit
a86295cd5c
@ -5581,6 +5581,13 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, const typval_T
|
||||
const char *line = NULL;
|
||||
if (lines->v_type == VAR_LIST) {
|
||||
l = lines->vval.v_list;
|
||||
if (l == NULL || tv_list_len(l) == 0) {
|
||||
// set proper return code
|
||||
if (lnum > curbuf->b_ml.ml_line_count) {
|
||||
rettv->vval.v_number = 1; // FAIL
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
li = tv_list_first(l);
|
||||
} else {
|
||||
line = tv_get_string_chk(lines);
|
||||
@ -5651,6 +5658,7 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, const typval_T
|
||||
update_topline(curwin);
|
||||
}
|
||||
|
||||
done:
|
||||
if (!is_curbuf) {
|
||||
curbuf = curbuf_save;
|
||||
curwin = curwin_save;
|
||||
|
@ -533,6 +533,8 @@ func Test_augroup_warning()
|
||||
redir END
|
||||
call assert_notmatch("W19:", res)
|
||||
au! VimEnter
|
||||
|
||||
call assert_fails('augroup!', 'E471:')
|
||||
endfunc
|
||||
|
||||
func Test_BufReadCmdHelp()
|
||||
|
@ -303,6 +303,7 @@ func Test_blob_index()
|
||||
call assert_equal(3, index(0z11110111, 0x11, -2))
|
||||
call assert_equal(0, index(0z11110111, 0x11, -10))
|
||||
call assert_fails("echo index(0z11110111, 0x11, [])", 'E745:')
|
||||
call assert_equal(-1, index(v:_null_blob, 1))
|
||||
|
||||
call assert_fails('call index("asdf", 0)', 'E897:')
|
||||
endfunc
|
||||
|
@ -19,8 +19,19 @@ func Test_setbufline_getbufline()
|
||||
call setline(1, ['a', 'b', 'c'])
|
||||
let b = bufnr('%')
|
||||
wincmd w
|
||||
|
||||
call assert_equal(1, setbufline(b, 5, 'x'))
|
||||
call assert_equal(1, setbufline(b, 5, ['x']))
|
||||
call assert_equal(1, setbufline(b, 5, []))
|
||||
call assert_equal(1, setbufline(b, 5, v:_null_list))
|
||||
|
||||
call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
|
||||
call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
|
||||
call assert_equal(1, []->setbufline(bufnr('$') + 1, 1))
|
||||
call assert_equal(1, v:_null_list->setbufline(bufnr('$') + 1, 1))
|
||||
|
||||
call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
|
||||
|
||||
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
|
||||
call assert_equal(['c'], b->getbufline(3))
|
||||
call assert_equal(['d'], getbufline(b, 4))
|
||||
@ -84,9 +95,29 @@ func Test_appendbufline()
|
||||
call setline(1, ['a', 'b', 'c'])
|
||||
let b = bufnr('%')
|
||||
wincmd w
|
||||
|
||||
call assert_equal(1, appendbufline(b, -1, 'x'))
|
||||
call assert_equal(1, appendbufline(b, -1, ['x']))
|
||||
call assert_equal(1, appendbufline(b, -1, []))
|
||||
call assert_equal(1, appendbufline(b, -1, v:_null_list))
|
||||
|
||||
call assert_equal(1, appendbufline(b, 4, 'x'))
|
||||
call assert_equal(1, appendbufline(b, 4, ['x']))
|
||||
call assert_equal(1, appendbufline(b, 4, []))
|
||||
call assert_equal(1, appendbufline(b, 4, v:_null_list))
|
||||
|
||||
call assert_equal(1, appendbufline(1234, 1, 'x'))
|
||||
call assert_equal(1, appendbufline(1234, 1, ['x']))
|
||||
call assert_equal(1, appendbufline(1234, 1, []))
|
||||
call assert_equal(1, appendbufline(1234, 1, v:_null_list))
|
||||
|
||||
call assert_equal(0, appendbufline(b, 1, []))
|
||||
call assert_equal(0, appendbufline(b, 1, v:_null_list))
|
||||
call assert_equal(1, appendbufline(b, 3, []))
|
||||
call assert_equal(1, appendbufline(b, 3, v:_null_list))
|
||||
|
||||
call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
|
||||
|
||||
call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
|
||||
call assert_equal(['c'], getbufline(b, 3))
|
||||
call assert_equal(['d'], getbufline(b, 4))
|
||||
|
@ -1270,6 +1270,11 @@ func Test_verbosefile()
|
||||
let log = readfile('Xlog')
|
||||
call assert_match("foo\nbar", join(log, "\n"))
|
||||
call delete('Xlog')
|
||||
call mkdir('Xdir')
|
||||
if !has('win32') " FIXME: no error on Windows, libuv bug?
|
||||
call assert_fails('set verbosefile=Xdir', 'E474:')
|
||||
endif
|
||||
call delete('Xdir', 'd')
|
||||
endfunc
|
||||
|
||||
func Test_verbose_option()
|
||||
|
@ -798,18 +798,41 @@ func Test_mode()
|
||||
delfunction OperatorFunc
|
||||
endfunc
|
||||
|
||||
" Test for append()
|
||||
func Test_append()
|
||||
enew!
|
||||
split
|
||||
call append(0, ["foo"])
|
||||
call append(1, [])
|
||||
call append(1, v:_null_list)
|
||||
call assert_equal(['foo', ''], getline(1, '$'))
|
||||
split
|
||||
only
|
||||
undo
|
||||
undo
|
||||
|
||||
" Using $ instead of '$' must give an error
|
||||
call assert_fails("call append($, 'foobar')", 'E116:')
|
||||
endfunc
|
||||
|
||||
" Test for setline()
|
||||
func Test_setline()
|
||||
new
|
||||
call setline(0, ["foo"])
|
||||
call setline(0, [])
|
||||
call setline(0, v:_null_list)
|
||||
call setline(1, ["bar"])
|
||||
call setline(1, [])
|
||||
call setline(1, v:_null_list)
|
||||
call setline(2, [])
|
||||
call setline(2, v:_null_list)
|
||||
call setline(3, [])
|
||||
call setline(3, v:_null_list)
|
||||
call setline(2, ["baz"])
|
||||
call assert_equal(['bar', 'baz'], getline(1, '$'))
|
||||
close!
|
||||
endfunc
|
||||
|
||||
func Test_getbufvar()
|
||||
let bnr = bufnr('%')
|
||||
let b:var_num = '1234'
|
||||
@ -917,6 +940,7 @@ func Test_match_func()
|
||||
call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5))
|
||||
call assert_equal(4, match('testing', 'ing', -1))
|
||||
call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:')
|
||||
call assert_equal(-1, match(v:_null_list, 2))
|
||||
endfunc
|
||||
|
||||
func Test_matchend()
|
||||
@ -1922,6 +1946,7 @@ func Test_call()
|
||||
call assert_equal(3, 'len'->call([123]))
|
||||
call assert_fails("call call('len', 123)", 'E714:')
|
||||
call assert_equal(0, call('', []))
|
||||
call assert_equal(0, call('len', v:_null_list))
|
||||
|
||||
function Mylen() dict
|
||||
return len(self.data)
|
||||
|
@ -372,6 +372,7 @@ func Test_getsettagstack()
|
||||
call assert_fails("call settagstack(1, {'items' : 10})", 'E714')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 10)", 'E928')
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962')
|
||||
call assert_equal(-1, settagstack(0, v:_null_dict))
|
||||
|
||||
set tags=Xtags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
|
@ -1142,6 +1142,18 @@ func Test_split_cmds_with_no_room()
|
||||
call Run_noroom_for_newwindow_test('v')
|
||||
endfunc
|
||||
|
||||
" Test for various wincmd failures
|
||||
func Test_wincmd_fails()
|
||||
only!
|
||||
call assert_beeps("normal \<C-W>w")
|
||||
call assert_beeps("normal \<C-W>p")
|
||||
call assert_beeps("normal \<C-W>gk")
|
||||
call assert_beeps("normal \<C-W>r")
|
||||
call assert_beeps("normal \<C-W>K")
|
||||
call assert_beeps("normal \<C-W>H")
|
||||
call assert_beeps("normal \<C-W>2gt")
|
||||
endfunc
|
||||
|
||||
func Test_window_resize()
|
||||
" Vertical :resize (absolute, relative, min and max size).
|
||||
vsplit
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Test for benchmarking RE engine.
|
||||
-- Test for benchmarking the RE engine.
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local insert, source = helpers.insert, helpers.source
|
||||
@ -13,13 +13,13 @@ local sample_file = 'src/nvim/testdir/samples/re.freeze.txt'
|
||||
local measure_cmd =
|
||||
[[call Measure(%d, ']] .. sample_file .. [[', '\s\+\%%#\@<!$', '+5')]]
|
||||
local measure_script = [[
|
||||
func! Measure(re, file, pattern, arg)
|
||||
func Measure(re, file, pattern, arg)
|
||||
let sstart = reltime()
|
||||
|
||||
execute 'set re=' . a:re
|
||||
execute 'set re=' .. a:re
|
||||
execute 'split' a:arg a:file
|
||||
call search(a:pattern, '', '', 10000)
|
||||
q!
|
||||
quit!
|
||||
|
||||
$put =printf('file: %s, re: %d, time: %s', a:file, a:re, reltimestr(reltime(sstart)))
|
||||
endfunc]]
|
@ -69,7 +69,7 @@ describe('NULL', function()
|
||||
null_expr_test('can be splice-indexed', 'L[:]', 0, {})
|
||||
null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0)
|
||||
null_test('is accepted by :for', 'for x in L|throw x|endfor', 0)
|
||||
null_expr_test('does not crash append()', 'append(1, L)', 0, 0, function()
|
||||
null_expr_test('does not crash append()', 'append(0, L)', 0, 0, function()
|
||||
eq({''}, curbufmeths.get_lines(0, -1, false))
|
||||
end)
|
||||
null_expr_test('does not crash setline()', 'setline(1, L)', 0, 0, function()
|
||||
|
Loading…
Reference in New Issue
Block a user