eval/shada: Add testing for unnamed register with setreg and startup

This commit is contained in:
AdnoC
2016-05-04 14:17:09 -04:00
parent 9a91ce4fa6
commit beca4dc16c
3 changed files with 51 additions and 1 deletions

View File

@@ -516,6 +516,15 @@ describe('eval', function()
eq({'item'}, eval("y")) eq({'item'}, eval("y"))
end) end)
it('sets the unnamed register when the "u" option is passed to setreg', function()
execute("call setreg('a','a reg', 'cu')")
eq("a reg", eval('@"'))
execute("call setreg('b','b reg', 'cu')")
eq("b reg", eval('@"'))
execute("call setreg('c','c reg', 'c')")
eq("b reg", eval('@"'))
end)
it('search and expressions', function() it('search and expressions', function()
command('so test_eval_setup.vim') command('so test_eval_setup.vim')
command([=[call SetReg('/', ['abc/'])]=]) command([=[call SetReg('/', ['abc/'])]=])

View File

@@ -636,6 +636,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc', ' # Required key missing: rc',
' + rw block width 0', ' + rw block width 0',
' + rt type CHARACTERWISE', ' + rt type CHARACTERWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
}}] ]]):gsub('\n', '')) }}] ]]):gsub('\n', ''))
sd2strings_eq({ sd2strings_eq({
@@ -645,6 +646,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc', ' # Required key missing: rc',
' + rw block width 0', ' + rw block width 0',
' + rt type CHARACTERWISE', ' + rt type CHARACTERWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
}}] ]]):gsub('\n', '')) }}] ]]):gsub('\n', ''))
@@ -655,9 +657,11 @@ describe('In autoload/shada.vim', function()
' + rc contents ["abc", "def"]', ' + rc contents ["abc", "def"]',
' + rw block width 0', ' + rw block width 0',
' + rt type CHARACTERWISE', ' + rt type CHARACTERWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': ["abc", "def"], 'rc': ["abc", "def"],
'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
}}] ]]):gsub('\n', '')) }}] ]]):gsub('\n', ''))
sd2strings_eq({ sd2strings_eq({
'Register with timestamp ' .. epoch .. ':', 'Register with timestamp ' .. epoch .. ':',
@@ -668,9 +672,11 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"', ' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0', ' + rw block width 0',
' + rt type CHARACTERWISE', ' + rt type CHARACTERWISE',
' + ru is_unnamed TRUE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
}}] ]]):gsub('\n', '')) }}] ]]):gsub('\n', ''))
sd2strings_eq({ sd2strings_eq({
'Register with timestamp ' .. epoch .. ':', 'Register with timestamp ' .. epoch .. ':',
@@ -681,6 +687,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"', ' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0', ' + rw block width 0',
' + rt type CHARACTERWISE', ' + rt type CHARACTERWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -696,6 +703,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"', ' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 5', ' + rw block width 5',
' + rt type LINEWISE', ' + rt type LINEWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -712,6 +720,7 @@ describe('In autoload/shada.vim', function()
' # Expected integer', ' # Expected integer',
' + rw block width ""', ' + rw block width ""',
' + rt type BLOCKWISE', ' + rt type BLOCKWISE',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -729,12 +738,31 @@ describe('In autoload/shada.vim', function()
' # Unexpected enum value: expected one of 0 (CHARACTERWISE), ' ' # Unexpected enum value: expected one of 0 (CHARACTERWISE), '
.. '1 (LINEWISE), 2 (BLOCKWISE)', .. '1 (LINEWISE), 2 (BLOCKWISE)',
' + rt type 10', ' + rt type 10',
' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': { }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20, 'n': 0x20,
'rc': 0, 'rc': 0,
'rw': -1, 'rw': -1,
'rt': 10, 'rt': 10,
}}] ]]):gsub('\n', '')) }}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
' % Key Description Value',
' + n name \' \'',
' + rc contents @',
' | - "abcdefghijklmnopqrstuvwxyz"',
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 5',
' + rt type LINEWISE',
' # Expected boolean',
' + ru is_unnamed 0',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
'rw': 5,
'rt': 1,
'ru': 0,
}}] ]]):gsub('\n', ''))
end) end)
it('works with variable items', function() it('works with variable items', function()

View File

@@ -148,10 +148,23 @@ describe('ShaDa support code', function()
eq({{'\171«'}, 'v'}, getreg('e')) eq({{'\171«'}, 'v'}, getreg('e'))
end) end)
it('remembers which register was the unnamed register when loading', it('defaults the unnamed register to register 0 if it wasn\'t set',
function() function()
setreg('0', {'zero'}, 'c') setreg('0', {'zero'}, 'c')
setreg('1', {'one'}, 'c') setreg('1', {'one'}, 'c')
setreg('2', {'two'}, 'c')
nvim_command('qall')
reset()
eq({{'zero'}, 'v'}, getreg('0'))
eq({{'one'}, 'v'}, getreg('1'))
eq({{'zero'}, 'v'}, getreg('"'))
end)
it('remembers which register was the unnamed register when loading',
function()
setreg('0', {'zero'}, 'c')
setreg('1', {'one'}, 'cu')
setreg('2', {'two'}, 'c')
nvim_command('qall') nvim_command('qall')
reset() reset()
eq({{'zero'}, 'v'}, getreg('0')) eq({{'zero'}, 'v'}, getreg('0'))