mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:8.0.0358,8.0.0359 (#7832)
vim-patch:8.0.0358: invalid memory access in C-indent code Problem: Invalid memory access in C-indent code. Solution: Don't go over end of empty line. (Dominique Pelle, closes vim/vim#1492)60629d6425
vim-patch:8.0.0359: 'number' and 'relativenumber' are not properly tested Problem: 'number' and 'relativenumber' are not properly tested. Solution: Add tests, change old style to new style tests. (Ozaki Kiichi, closes vim/vim#1447)dc9a081712
This commit is contained in:

committed by
Justin M. Keyes

parent
5d2dd2ebe2
commit
649123d07c
@@ -6907,7 +6907,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
|||||||
if (try_match && *look == keytyped) {
|
if (try_match && *look == keytyped) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
look++;
|
if (*look != NUL) {
|
||||||
|
look++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -52,6 +52,7 @@ NEW_TESTS ?= \
|
|||||||
test_diffmode.res \
|
test_diffmode.res \
|
||||||
test_farsi.res \
|
test_farsi.res \
|
||||||
test_filter_map.res \
|
test_filter_map.res \
|
||||||
|
test_findfile.res \
|
||||||
test_fnameescape.res \
|
test_fnameescape.res \
|
||||||
test_fold.res \
|
test_fold.res \
|
||||||
test_ga.res \
|
test_ga.res \
|
||||||
@@ -76,6 +77,7 @@ NEW_TESTS ?= \
|
|||||||
test_mksession_utf8.res \
|
test_mksession_utf8.res \
|
||||||
test_nested_function.res \
|
test_nested_function.res \
|
||||||
test_normal.res \
|
test_normal.res \
|
||||||
|
test_number.res \
|
||||||
test_options.res \
|
test_options.res \
|
||||||
test_profile.res \
|
test_profile.res \
|
||||||
test_quickfix.res \
|
test_quickfix.res \
|
||||||
|
@@ -12,6 +12,7 @@ source test_expr_utf8.vim
|
|||||||
source test_feedkeys.vim
|
source test_feedkeys.vim
|
||||||
source test_filter_cmd.vim
|
source test_filter_cmd.vim
|
||||||
source test_filter_map.vim
|
source test_filter_map.vim
|
||||||
|
source test_findfile.vim
|
||||||
source test_float_func.vim
|
source test_float_func.vim
|
||||||
source test_functions.vim
|
source test_functions.vim
|
||||||
source test_ga.vim
|
source test_ga.vim
|
||||||
|
25
src/nvim/testdir/test_findfile.vim
Normal file
25
src/nvim/testdir/test_findfile.vim
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
" Test for findfile()
|
||||||
|
"
|
||||||
|
func Test_findfile()
|
||||||
|
new
|
||||||
|
let cwd=getcwd()
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
" Tests may be run from a shadow directory, so an extra cd needs to be done to
|
||||||
|
" get above src/
|
||||||
|
if fnamemodify(getcwd(), ':t') != 'src'
|
||||||
|
cd ../..
|
||||||
|
else
|
||||||
|
cd ..
|
||||||
|
endif
|
||||||
|
set ssl
|
||||||
|
|
||||||
|
call assert_equal('src/nvim/testdir/test_findfile.vim', findfile('test_findfile.vim','src/nvim/test*'))
|
||||||
|
exe "cd" cwd
|
||||||
|
cd ..
|
||||||
|
call assert_equal('testdir/test_findfile.vim', findfile('test_findfile.vim','test*'))
|
||||||
|
call assert_equal('testdir/test_findfile.vim', findfile('test_findfile.vim','testdir'))
|
||||||
|
|
||||||
|
exe "cd" cwd
|
||||||
|
q!
|
||||||
|
endfunc
|
254
src/nvim/testdir/test_number.vim
Normal file
254
src/nvim/testdir/test_number.vim
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
" Test for 'number' and 'relativenumber'
|
||||||
|
|
||||||
|
source view_util.vim
|
||||||
|
|
||||||
|
func! s:screen_lines(start, end) abort
|
||||||
|
return ScreenLines([a:start, a:end], 8)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! s:compare_lines(expect, actual)
|
||||||
|
call assert_equal(a:expect, a:actual)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! s:test_windows(h, w) abort
|
||||||
|
call NewWindow(a:h, a:w)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! s:close_windows() abort
|
||||||
|
call CloseWindow()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! s:validate_cursor() abort
|
||||||
|
" update skipcol.
|
||||||
|
" wincol():
|
||||||
|
" f_wincol
|
||||||
|
" -> validate_cursor
|
||||||
|
" -> curs_columns
|
||||||
|
call wincol()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_set_options()
|
||||||
|
set nu rnu
|
||||||
|
call assert_equal(1, &nu)
|
||||||
|
call assert_equal(1, &rnu)
|
||||||
|
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call assert_equal(1, &nu)
|
||||||
|
call assert_equal(1, &rnu)
|
||||||
|
call s:close_windows()
|
||||||
|
|
||||||
|
set nu& rnu&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_set_global_and_local()
|
||||||
|
" setlocal must NOT reset the other global value
|
||||||
|
set nonu nornu
|
||||||
|
setglobal nu
|
||||||
|
setlocal rnu
|
||||||
|
call assert_equal(1, &g:nu)
|
||||||
|
|
||||||
|
set nonu nornu
|
||||||
|
setglobal rnu
|
||||||
|
setlocal nu
|
||||||
|
call assert_equal(1, &g:rnu)
|
||||||
|
|
||||||
|
" setglobal MUST reset the other global value
|
||||||
|
set nonu nornu
|
||||||
|
setglobal nu
|
||||||
|
setglobal rnu
|
||||||
|
call assert_equal(1, &g:nu)
|
||||||
|
|
||||||
|
set nonu nornu
|
||||||
|
setglobal rnu
|
||||||
|
setglobal nu
|
||||||
|
call assert_equal(1, &g:rnu)
|
||||||
|
|
||||||
|
" set MUST reset the other global value
|
||||||
|
set nonu nornu
|
||||||
|
set nu
|
||||||
|
set rnu
|
||||||
|
call assert_equal(1, &g:nu)
|
||||||
|
|
||||||
|
set nonu nornu
|
||||||
|
set rnu
|
||||||
|
set nu
|
||||||
|
call assert_equal(1, &g:rnu)
|
||||||
|
|
||||||
|
set nu& rnu&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_number()
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call setline(1, ["abcdefghij", "klmnopqrst", "uvwxyzABCD", "EFGHIJKLMN", "OPQRSTUVWX", "YZ"])
|
||||||
|
setl number
|
||||||
|
let lines = s:screen_lines(1, 4)
|
||||||
|
let expect = [
|
||||||
|
\ " 1 abcd",
|
||||||
|
\ " 2 klmn",
|
||||||
|
\ " 3 uvwx",
|
||||||
|
\ " 4 EFGH",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_relativenumber()
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call setline(1, ["abcdefghij", "klmnopqrst", "uvwxyzABCD", "EFGHIJKLMN", "OPQRSTUVWX", "YZ"])
|
||||||
|
3
|
||||||
|
setl relativenumber
|
||||||
|
let lines = s:screen_lines(1, 6)
|
||||||
|
let expect = [
|
||||||
|
\ " 2 abcd",
|
||||||
|
\ " 1 klmn",
|
||||||
|
\ " 0 uvwx",
|
||||||
|
\ " 1 EFGH",
|
||||||
|
\ " 2 OPQR",
|
||||||
|
\ " 3 YZ ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_number_with_relativenumber()
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call setline(1, ["abcdefghij", "klmnopqrst", "uvwxyzABCD", "EFGHIJKLMN", "OPQRSTUVWX", "YZ"])
|
||||||
|
4
|
||||||
|
setl number relativenumber
|
||||||
|
let lines = s:screen_lines(1, 6)
|
||||||
|
let expect = [
|
||||||
|
\ " 3 abcd",
|
||||||
|
\ " 2 klmn",
|
||||||
|
\ " 1 uvwx",
|
||||||
|
\ "4 EFGH",
|
||||||
|
\ " 1 OPQR",
|
||||||
|
\ " 2 YZ ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_number_with_linewrap1()
|
||||||
|
call s:test_windows(3, 20)
|
||||||
|
normal! 61ia
|
||||||
|
setl number wrap
|
||||||
|
call s:validate_cursor()
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ "--1 aaaa",
|
||||||
|
\ " aaaa",
|
||||||
|
\ " aaaa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
|
||||||
|
func XTest_number_with_linewrap2()
|
||||||
|
call s:test_windows(3, 20)
|
||||||
|
normal! 61ia
|
||||||
|
setl number wrap
|
||||||
|
call s:validate_cursor()
|
||||||
|
0
|
||||||
|
call s:validate_cursor()
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ " 1 aaaa",
|
||||||
|
\ " aaaa",
|
||||||
|
\ " aaaa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Pending: https://groups.google.com/forum/#!topic/vim_dev/tzNKP7EDWYI
|
||||||
|
func XTest_number_with_linewrap3()
|
||||||
|
call s:test_windows(4, 20)
|
||||||
|
normal! 81ia
|
||||||
|
setl number wrap
|
||||||
|
call s:validate_cursor()
|
||||||
|
setl nonumber
|
||||||
|
call s:validate_cursor()
|
||||||
|
let lines = s:screen_lines(1, 4)
|
||||||
|
let expect = [
|
||||||
|
\ "aaaaaaaa",
|
||||||
|
\ "aaaaaaaa",
|
||||||
|
\ "aaaaaaaa",
|
||||||
|
\ "a ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_numberwidth()
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call setline(1, repeat(['aaaa'], 10))
|
||||||
|
setl number numberwidth=6
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ " 1 aa",
|
||||||
|
\ " 2 aa",
|
||||||
|
\ " 3 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
set relativenumber
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ "1 aa",
|
||||||
|
\ " 1 aa",
|
||||||
|
\ " 2 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
set nonumber
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ " 0 aa",
|
||||||
|
\ " 1 aa",
|
||||||
|
\ " 2 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_numberwidth_adjusted()
|
||||||
|
call s:test_windows(10, 20)
|
||||||
|
call setline(1, repeat(['aaaa'], 10000))
|
||||||
|
setl number numberwidth=4
|
||||||
|
let lines = s:screen_lines(1, 3)
|
||||||
|
let expect = [
|
||||||
|
\ " 1 aa",
|
||||||
|
\ " 2 aa",
|
||||||
|
\ " 3 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
$
|
||||||
|
let lines = s:screen_lines(8, 10)
|
||||||
|
let expect = [
|
||||||
|
\ " 9998 aa",
|
||||||
|
\ " 9999 aa",
|
||||||
|
\ "10000 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
setl relativenumber
|
||||||
|
let lines = s:screen_lines(8, 10)
|
||||||
|
let expect = [
|
||||||
|
\ " 2 aa",
|
||||||
|
\ " 1 aa",
|
||||||
|
\ "10000 aa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
setl nonumber
|
||||||
|
let lines = s:screen_lines(8, 10)
|
||||||
|
let expect = [
|
||||||
|
\ " 2 aaaa",
|
||||||
|
\ " 1 aaaa",
|
||||||
|
\ " 0 aaaa",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
@@ -119,6 +119,13 @@ func Check_dir_option(name)
|
|||||||
call assert_fails("set " . a:name . "=/not.*there", "E474:")
|
call assert_fails("set " . a:name . "=/not.*there", "E474:")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_cinkeys()
|
||||||
|
" This used to cause invalid memory access
|
||||||
|
set cindent cinkeys=0
|
||||||
|
norm a
|
||||||
|
set cindent& cinkeys&
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_dictionary()
|
func Test_dictionary()
|
||||||
call Check_dir_option('dictionary')
|
call Check_dir_option('dictionary')
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -1,116 +0,0 @@
|
|||||||
-- - Some tests for setting 'number' and 'relativenumber'
|
|
||||||
-- This is not all that useful now that the options are no longer reset when
|
|
||||||
-- setting the other.
|
|
||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
|
||||||
local feed = helpers.feed
|
|
||||||
local clear, expect, source = helpers.clear, helpers.expect, helpers.source
|
|
||||||
|
|
||||||
describe("setting 'number' and 'relativenumber'", function()
|
|
||||||
setup(clear)
|
|
||||||
|
|
||||||
it('is working', function()
|
|
||||||
source([[
|
|
||||||
set hidden nu rnu
|
|
||||||
redir @a | set nu? | set rnu? | redir END
|
|
||||||
e! xx
|
|
||||||
redir @b | set nu? | set rnu? | redir END
|
|
||||||
e! #
|
|
||||||
$put ='results:'
|
|
||||||
$put a
|
|
||||||
$put b
|
|
||||||
|
|
||||||
set nonu nornu
|
|
||||||
setglobal nu
|
|
||||||
setlocal rnu
|
|
||||||
redir @c | setglobal nu? | redir END
|
|
||||||
set nonu nornu
|
|
||||||
setglobal rnu
|
|
||||||
setlocal nu
|
|
||||||
redir @d | setglobal rnu? | redir END
|
|
||||||
$put =':setlocal must NOT reset the other global value'
|
|
||||||
$put c
|
|
||||||
$put d
|
|
||||||
|
|
||||||
set nonu nornu
|
|
||||||
setglobal nu
|
|
||||||
setglobal rnu
|
|
||||||
redir @e | setglobal nu? | redir END
|
|
||||||
set nonu nornu
|
|
||||||
setglobal rnu
|
|
||||||
setglobal nu
|
|
||||||
redir @f | setglobal rnu? | redir END
|
|
||||||
$put =':setglobal MUST reset the other global value'
|
|
||||||
$put e
|
|
||||||
$put f
|
|
||||||
|
|
||||||
set nonu nornu
|
|
||||||
set nu
|
|
||||||
set rnu
|
|
||||||
redir @g | setglobal nu? | redir END
|
|
||||||
set nonu nornu
|
|
||||||
set rnu
|
|
||||||
set nu
|
|
||||||
redir @h | setglobal rnu? | redir END
|
|
||||||
$put =':set MUST reset the other global value'
|
|
||||||
$put g
|
|
||||||
$put h
|
|
||||||
]])
|
|
||||||
|
|
||||||
-- Remove empty line
|
|
||||||
feed('ggdd')
|
|
||||||
|
|
||||||
-- Assert buffer contents.
|
|
||||||
expect([[
|
|
||||||
results:
|
|
||||||
|
|
||||||
number
|
|
||||||
relativenumber
|
|
||||||
|
|
||||||
number
|
|
||||||
relativenumber
|
|
||||||
:setlocal must NOT reset the other global value
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
relativenumber
|
|
||||||
:setglobal MUST reset the other global value
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
relativenumber
|
|
||||||
:set MUST reset the other global value
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
relativenumber]])
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- - Some tests for findfile() function
|
|
||||||
describe('findfile', function()
|
|
||||||
setup(clear)
|
|
||||||
|
|
||||||
it('is working', function()
|
|
||||||
-- Assume test is being run from project root
|
|
||||||
source([[
|
|
||||||
$put ='Testing findfile'
|
|
||||||
$put =''
|
|
||||||
set ssl
|
|
||||||
$put =findfile('vim.c','src/nvim/ap*')
|
|
||||||
cd src/nvim
|
|
||||||
$put =findfile('vim.c','ap*')
|
|
||||||
$put =findfile('vim.c','api')
|
|
||||||
]])
|
|
||||||
|
|
||||||
-- Remove empty line
|
|
||||||
feed('ggdd')
|
|
||||||
|
|
||||||
expect([[
|
|
||||||
Testing findfile
|
|
||||||
|
|
||||||
src/nvim/api/vim.c
|
|
||||||
api/vim.c
|
|
||||||
api/vim.c]])
|
|
||||||
end)
|
|
||||||
end)
|
|
Reference in New Issue
Block a user