mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 18:11:47 +00:00
feat(eval/method): partially port v8.1.1953
Adds method call support for all functions in the patch, but it cannot
be fully ported due to missing tests for:
- index(): requires Blobs from v8.1.0735.
Note that index() was already added as a method in v8.1.1803;
this patch only adds a test.
- iconv(): requires v8.1.1136 for test_termcodes.vim.
Nvim deprecated inputdialog(), so it no longer has an eval.txt entry.
Keep the test for hlexists() commented-out, just like previously. (Nvim
always defines the Number group, so it always returns 1 instead)
Cannot include both changes to test_syn_attr.vim as Nvim doesn't support
":hi term=..."; however, both test the same ->hlID() syntax anyway.
This commit is contained in:
@@ -418,8 +418,8 @@ endfunc
|
||||
func Test_breakindent11()
|
||||
" test strdisplaywidth()
|
||||
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
|
||||
let text=getline(2)
|
||||
let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
|
||||
let text = getline(2)
|
||||
let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
|
||||
call assert_equal(width, strdisplaywidth(text))
|
||||
call s:close_windows('set sbr=')
|
||||
endfunc
|
||||
@@ -431,7 +431,7 @@ func Test_breakindent11_vartabs()
|
||||
" test strdisplaywidth()
|
||||
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
|
||||
let text = getline(2)
|
||||
let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
|
||||
let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
|
||||
call assert_equal(width, strdisplaywidth(text))
|
||||
call s:close_windows('set sbr= vts&')
|
||||
endfunc
|
||||
|
||||
@@ -1127,7 +1127,7 @@ endfunc
|
||||
|
||||
func Test_hlexists()
|
||||
call assert_equal(0, hlexists('does_not_exist'))
|
||||
" call assert_equal(0, hlexists('Number'))
|
||||
" call assert_equal(0, 'Number'->hlexists())
|
||||
call assert_equal(0, highlight_exists('does_not_exist'))
|
||||
" call assert_equal(0, highlight_exists('Number'))
|
||||
syntax on
|
||||
@@ -1160,7 +1160,7 @@ endfunc
|
||||
func Test_inputlist()
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
|
||||
call assert_equal(1, c)
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx')
|
||||
call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx')
|
||||
call assert_equal(2, c)
|
||||
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
|
||||
call assert_equal(3, c)
|
||||
@@ -1413,7 +1413,7 @@ func Test_reg_executing_and_recording()
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:regs += [reg_executing()]
|
||||
let g:typed = input('?')
|
||||
let g:typed = '?'->input()
|
||||
let g:regs += [reg_executing()]
|
||||
endfunc
|
||||
call feedkeys("@qy\<CR>", 'xt')
|
||||
@@ -1429,6 +1429,25 @@ func Test_reg_executing_and_recording()
|
||||
unlet s:reg_stat
|
||||
endfunc
|
||||
|
||||
func Test_inputsecret()
|
||||
map W :call TestFunc()<CR>
|
||||
let @q = "W"
|
||||
let g:typed1 = ''
|
||||
let g:typed2 = ''
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:typed1 = '?'->inputsecret()
|
||||
let g:typed2 = inputsecret('password: ')
|
||||
endfunc
|
||||
call feedkeys("@qsomething\<CR>else\<CR>", 'xt')
|
||||
call assert_equal("something", g:typed1)
|
||||
call assert_equal("else", g:typed2)
|
||||
delfunc TestFunc
|
||||
unmap W
|
||||
unlet g:typed1
|
||||
unlet g:typed2
|
||||
endfunc
|
||||
|
||||
func Test_getchar()
|
||||
call feedkeys('a', '')
|
||||
call assert_equal(char2nr('a'), getchar())
|
||||
|
||||
@@ -17,7 +17,7 @@ func GetCwdInfo(win, tab)
|
||||
let lflag = haslocaldir(a:win)
|
||||
else
|
||||
let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
|
||||
let lflag = haslocaldir(a:win, a:tab)
|
||||
let lflag = a:win->haslocaldir(a:tab)
|
||||
endif
|
||||
return bufname . ' ' . dirname . ' ' . lflag
|
||||
endfunc
|
||||
|
||||
@@ -13,7 +13,7 @@ function History_Tests(hist)
|
||||
call assert_equal(-1, histnr(a:hist))
|
||||
call assert_equal('', histget(a:hist))
|
||||
|
||||
call assert_true(histadd(a:hist, 'ls'))
|
||||
call assert_true('ls'->histadd(a:hist))
|
||||
call assert_true(histadd(a:hist, 'buffers'))
|
||||
call assert_equal('buffers', histget(a:hist))
|
||||
call assert_equal('ls', histget(a:hist, -2))
|
||||
@@ -22,14 +22,14 @@ function History_Tests(hist)
|
||||
call assert_equal('', histget(a:hist, -5))
|
||||
call assert_equal(2, histnr(a:hist))
|
||||
call assert_true(histdel(a:hist, 2))
|
||||
call assert_false(histdel(a:hist, 7))
|
||||
call assert_false(a:hist->histdel(7))
|
||||
call assert_equal(1, histnr(a:hist))
|
||||
call assert_equal('ls', histget(a:hist, -1))
|
||||
|
||||
call assert_true(histadd(a:hist, 'buffers'))
|
||||
call assert_true(histadd(a:hist, 'ls'))
|
||||
call assert_equal('ls', histget(a:hist, -1))
|
||||
call assert_equal(4, histnr(a:hist))
|
||||
call assert_equal('ls', a:hist->histget(-1))
|
||||
call assert_equal(4, a:hist->histnr())
|
||||
|
||||
let a=execute('history ' . a:hist)
|
||||
call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a)
|
||||
|
||||
@@ -573,7 +573,7 @@ func Test_lockvar_script_autoload()
|
||||
set rtp+=./sautest
|
||||
lockvar g:footest#x
|
||||
unlockvar g:footest#x
|
||||
call assert_equal(-1, islocked('g:footest#x'))
|
||||
call assert_equal(-1, 'g:footest#x'->islocked())
|
||||
call assert_equal(0, exists('g:footest#x'))
|
||||
call assert_equal(1, g:footest#x)
|
||||
let &rtp = old_rtp
|
||||
|
||||
@@ -8,7 +8,7 @@ func Test_missing_attr()
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
|
||||
hi Mine cterm=standout gui=undercurl
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
|
||||
call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui'))
|
||||
hi Mine gui=strikethrough
|
||||
call assert_equal('1', synIDattr(hlID("Mine"), "strikethrough", 'gui'))
|
||||
hi Mine cterm=NONE gui=NONE
|
||||
|
||||
@@ -104,7 +104,7 @@ func Test_true_false_arg()
|
||||
call Try_arg_true_false('maparg("asdf", "i", %v%)', "", "asdff")
|
||||
call Try_arg_true_false('FilterMapArg(maparg("asdf", "i", 1, %v%))', "asdff", {'rhs': 'asdff'})
|
||||
|
||||
call Try_arg_true_false('hasmapto("asdf", "i", %v%)', 0, 1)
|
||||
call Try_arg_true_false('"asdf"->hasmapto("i", %v%)', 0, 1)
|
||||
|
||||
new colored
|
||||
call setline(1, '<here>')
|
||||
|
||||
Reference in New Issue
Block a user