test: Fix and add cases for unnamed register

Also:

Add ru to shada tests with all keys

Add test for unset unnamed and register 0
This commit is contained in:
AdnoC
2017-05-29 11:34:08 -04:00
parent 0c3dea5c4d
commit 5908f562df
3 changed files with 27 additions and 5 deletions

View File

@@ -517,11 +517,11 @@ describe('eval', function()
end)
it('sets the unnamed register when the "u" option is passed to setreg', function()
execute("call setreg('a','a reg', 'cu')")
command("call setreg('a','a reg', 'cu')")
eq("a reg", eval('@"'))
execute("call setreg('b','b reg', 'cu')")
command("call setreg('b','b reg', 'cu')")
eq("b reg", eval('@"'))
execute("call setreg('c','c reg', 'c')")
command("call setreg('c','c reg', 'c')")
eq("b reg", eval('@"'))
end)

View File

@@ -179,6 +179,7 @@ describe('In autoload/shada.vim', function()
' + n name \'@\'',
' + rc contents ["abc", "def"]',
' + rt type CHARACTERWISE',
' + ru is_unnamed FALSE',
' + rw block width 10',
' + sb search backward TRUE',
' + sc smartcase value FALSE',
@@ -204,6 +205,7 @@ describe('In autoload/shada.vim', function()
'rt': 0,
'rw': 10,
'rc': ['abc', 'def'],
'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
'n': 0x40,
'l': 10,
'c': 0,
@@ -226,6 +228,8 @@ describe('In autoload/shada.vim', function()
.. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)',
' + rt type 10',
' # Expected boolean',
' + ru is_unnamed 10',
' # Expected boolean',
' + sc smartcase value NIL',
' # Expected boolean',
' + sm magic value "TRUE"',
@@ -240,6 +244,7 @@ describe('In autoload/shada.vim', function()
'sp': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]},
'rt': 10,
'rc': '10',
'ru': 10,
'n': -0x40,
'l': -10,
'c': 'abc',
@@ -720,12 +725,14 @@ describe('In autoload/shada.vim', function()
' # Expected integer',
' + rw block width ""',
' + rt type BLOCKWISE',
' + ru is_unnamed FALSE',
' # Expected boolean',
' + ru is_unnamed ""',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
'rw': "",
'rt': 2,
'ru': ""
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -738,12 +745,14 @@ describe('In autoload/shada.vim', function()
' # Unexpected enum value: expected one of 0 (CHARACTERWISE), '
.. '1 (LINEWISE), 2 (BLOCKWISE)',
' + rt type 10',
' + ru is_unnamed FALSE',
' # Expected boolean',
' + ru is_unnamed ["abc", "def"]',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': 0,
'rw': -1,
'rt': 10,
'ru': ['abc', 'def'],
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',

View File

@@ -148,6 +148,19 @@ describe('ShaDa support code', function()
eq({{'\171«'}, 'v'}, getreg('e'))
end)
it('has a blank unnamed register if it wasn\'t set and register 0 is empty',
function()
setreg('1', {'one'}, 'c')
setreg('2', {'two'}, 'c')
setreg('a', {'a'}, 'c')
nvim_command('qall')
reset()
eq({{}, ''}, getreg('0'))
eq({{'one'}, 'v'}, getreg('1'))
eq({{}, ''}, getreg('"'))
eq({{'a'}, 'v'}, getreg('a'))
end)
it('defaults the unnamed register to register 0 if it wasn\'t set',
function()
setreg('0', {'zero'}, 'c')