mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test(old): reorder test_register.vim according to upstream (#17215)
This commit is contained in:
parent
69f37197c0
commit
d0493d1104
@ -1,6 +1,4 @@
|
||||
"
|
||||
" Tests for register operations
|
||||
"
|
||||
|
||||
source check.vim
|
||||
source view_util.vim
|
||||
@ -335,6 +333,86 @@ func Test_put_reg_restart_mode()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for getting register info
|
||||
func Test_get_reginfo()
|
||||
enew
|
||||
call setline(1, ['foo', 'bar'])
|
||||
|
||||
exe 'norm! "zyy'
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
call setreg('y', 'baz')
|
||||
call assert_equal('z', getreginfo('').points_to)
|
||||
call setreg('y', { 'isunnamed': v:true })
|
||||
call assert_equal('y', getreginfo('"').points_to)
|
||||
|
||||
exe '$put'
|
||||
call assert_equal(getreg('y'), getline(3))
|
||||
call setreg('', 'qux')
|
||||
call assert_equal('0', getreginfo('').points_to)
|
||||
call setreg('x', 'quux')
|
||||
call assert_equal('0', getreginfo('').points_to)
|
||||
|
||||
let info = getreginfo('')
|
||||
call assert_equal(getreg('', 1, 1), info.regcontents)
|
||||
call assert_equal(getregtype(''), info.regtype)
|
||||
|
||||
exe "norm! 0\<c-v>e" .. '"zy'
|
||||
let info = getreginfo('z')
|
||||
call assert_equal(getreg('z', 1, 1), info.regcontents)
|
||||
call assert_equal(getregtype('z'), info.regtype)
|
||||
call assert_equal(1, +info.isunnamed)
|
||||
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for restoring register with dict from getreginfo
|
||||
func Test_set_register_dict()
|
||||
enew!
|
||||
|
||||
call setreg('"', #{ regcontents: ['one', 'two'],
|
||||
\ regtype: 'V', points_to: 'z' })
|
||||
call assert_equal(['one', 'two'], getreg('"', 1, 1))
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
call assert_equal('V', info.regtype)
|
||||
call assert_equal(1, +getreginfo('z').isunnamed)
|
||||
|
||||
call setreg('x', #{ regcontents: ['three', 'four'],
|
||||
\ regtype: 'v', isunnamed: v:true })
|
||||
call assert_equal(['three', 'four'], getreg('"', 1, 1))
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('x', info.points_to)
|
||||
call assert_equal('v', info.regtype)
|
||||
call assert_equal(1, +getreginfo('x').isunnamed)
|
||||
|
||||
call setreg('y', #{ regcontents: 'five',
|
||||
\ regtype: "\<c-v>", isunnamed: v:false })
|
||||
call assert_equal("\<c-v>4", getreginfo('y').regtype)
|
||||
call assert_equal(0, +getreginfo('y').isunnamed)
|
||||
call assert_equal(['three', 'four'], getreg('"', 1, 1))
|
||||
call assert_equal('x', getreginfo('"').points_to)
|
||||
|
||||
call setreg('"', #{ regcontents: 'six' })
|
||||
call assert_equal('0', getreginfo('"').points_to)
|
||||
call assert_equal(1, +getreginfo('0').isunnamed)
|
||||
call assert_equal(['six'], getreginfo('0').regcontents)
|
||||
call assert_equal(['six'], getreginfo('"').regcontents)
|
||||
|
||||
let @x = 'one'
|
||||
call setreg('x', {})
|
||||
call assert_equal(1, len(split(execute('reg x'), '\n')))
|
||||
|
||||
call assert_fails("call setreg('0', #{regtype: 'V'}, 'v')", 'E118:')
|
||||
call assert_fails("call setreg('0', #{regtype: 'X'})", 'E475:')
|
||||
call assert_fails("call setreg('0', #{regtype: 'vy'})", 'E475:')
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_v_register()
|
||||
enew
|
||||
call setline(1, 'nothing')
|
||||
@ -433,84 +511,4 @@ func Test_insert_small_delete()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for getting register info
|
||||
func Test_get_reginfo()
|
||||
enew
|
||||
call setline(1, ['foo', 'bar'])
|
||||
|
||||
exe 'norm! "zyy'
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
call setreg('y', 'baz')
|
||||
call assert_equal('z', getreginfo('').points_to)
|
||||
call setreg('y', { 'isunnamed': v:true })
|
||||
call assert_equal('y', getreginfo('"').points_to)
|
||||
|
||||
exe '$put'
|
||||
call assert_equal(getreg('y'), getline(3))
|
||||
call setreg('', 'qux')
|
||||
call assert_equal('0', getreginfo('').points_to)
|
||||
call setreg('x', 'quux')
|
||||
call assert_equal('0', getreginfo('').points_to)
|
||||
|
||||
let info = getreginfo('')
|
||||
call assert_equal(getreg('', 1, 1), info.regcontents)
|
||||
call assert_equal(getregtype(''), info.regtype)
|
||||
|
||||
exe "norm! 0\<c-v>e" .. '"zy'
|
||||
let info = getreginfo('z')
|
||||
call assert_equal(getreg('z', 1, 1), info.regcontents)
|
||||
call assert_equal(getregtype('z'), info.regtype)
|
||||
call assert_equal(1, +info.isunnamed)
|
||||
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for restoring register with dict from getreginfo
|
||||
func Test_set_register_dict()
|
||||
enew!
|
||||
|
||||
call setreg('"', #{ regcontents: ['one', 'two'],
|
||||
\ regtype: 'V', points_to: 'z' })
|
||||
call assert_equal(['one', 'two'], getreg('"', 1, 1))
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('z', info.points_to)
|
||||
call assert_equal('V', info.regtype)
|
||||
call assert_equal(1, +getreginfo('z').isunnamed)
|
||||
|
||||
call setreg('x', #{ regcontents: ['three', 'four'],
|
||||
\ regtype: 'v', isunnamed: v:true })
|
||||
call assert_equal(['three', 'four'], getreg('"', 1, 1))
|
||||
let info = getreginfo('"')
|
||||
call assert_equal('x', info.points_to)
|
||||
call assert_equal('v', info.regtype)
|
||||
call assert_equal(1, +getreginfo('x').isunnamed)
|
||||
|
||||
call setreg('y', #{ regcontents: 'five',
|
||||
\ regtype: "\<c-v>", isunnamed: v:false })
|
||||
call assert_equal("\<c-v>4", getreginfo('y').regtype)
|
||||
call assert_equal(0, +getreginfo('y').isunnamed)
|
||||
call assert_equal(['three', 'four'], getreg('"', 1, 1))
|
||||
call assert_equal('x', getreginfo('"').points_to)
|
||||
|
||||
call setreg('"', #{ regcontents: 'six' })
|
||||
call assert_equal('0', getreginfo('"').points_to)
|
||||
call assert_equal(1, +getreginfo('0').isunnamed)
|
||||
call assert_equal(['six'], getreginfo('0').regcontents)
|
||||
call assert_equal(['six'], getreginfo('"').regcontents)
|
||||
|
||||
let @x = 'one'
|
||||
call setreg('x', {})
|
||||
call assert_equal(1, len(split(execute('reg x'), '\n')))
|
||||
|
||||
call assert_fails("call setreg('0', #{regtype: 'V'}, 'v')", 'E118:')
|
||||
call assert_fails("call setreg('0', #{regtype: 'X'})", 'E475:')
|
||||
call assert_fails("call setreg('0', #{regtype: 'vy'})", 'E475:')
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user