aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnoC <adam.r.cutler@gmail.com>2016-05-04 14:17:09 -0400
committerAdnoC <adam.r.cutler@gmail.com>2017-05-31 13:19:08 -0400
commitbeca4dc16c0cc45b97bb04891b19350308026f1f (patch)
treeb42bcf361dadc3eed0fe15c5ceaf5010d8b7d4aa
parent9a91ce4fa6a7504644e10a6761eae5cc5699159a (diff)
downloadrneovim-beca4dc16c0cc45b97bb04891b19350308026f1f.tar.gz
rneovim-beca4dc16c0cc45b97bb04891b19350308026f1f.tar.bz2
rneovim-beca4dc16c0cc45b97bb04891b19350308026f1f.zip
eval/shada: Add testing for unnamed register with setreg and startup
-rw-r--r--test/functional/legacy/eval_spec.lua9
-rw-r--r--test/functional/plugin/shada_spec.lua28
-rw-r--r--test/functional/shada/registers_spec.lua15
3 files changed, 51 insertions, 1 deletions
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua
index d7ef508194..1b6f834019 100644
--- a/test/functional/legacy/eval_spec.lua
+++ b/test/functional/legacy/eval_spec.lua
@@ -516,6 +516,15 @@ describe('eval', function()
eq({'item'}, eval("y"))
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()
command('so test_eval_setup.vim')
command([=[call SetReg('/', ['abc/'])]=])
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index b543037ae2..bf37fbabc5 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -636,6 +636,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
}}] ]]):gsub('\n', ''))
sd2strings_eq({
@@ -645,6 +646,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
}}] ]]):gsub('\n', ''))
@@ -655,9 +657,11 @@ describe('In autoload/shada.vim', function()
' + rc contents ["abc", "def"]',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ["abc", "def"],
+ 'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -668,9 +672,11 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed TRUE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -681,6 +687,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -696,6 +703,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 5',
' + rt type LINEWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -712,6 +720,7 @@ describe('In autoload/shada.vim', function()
' # Expected integer',
' + rw block width ""',
' + rt type BLOCKWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -729,12 +738,31 @@ 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',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': 0,
'rw': -1,
'rt': 10,
}}] ]]):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)
it('works with variable items', function()
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index d8e9892c76..256242cbf6 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -148,10 +148,23 @@ describe('ShaDa support code', function()
eq({{'\171«'}, 'v'}, getreg('e'))
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()
setreg('0', {'zero'}, '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')
reset()
eq({{'zero'}, 'v'}, getreg('0'))