aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada/variables_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-04-26 15:31:39 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 21:59:52 +0300
commite143be7f3da154db20a0fc3b709a3ab240c0ec7f (patch)
treec05e53ff582bcf2a8a683d4ddd8b62b92ca393c0 /test/functional/shada/variables_spec.lua
parent5e34d4873b760e038093596e5d44fa0e8ee20036 (diff)
downloadrneovim-e143be7f3da154db20a0fc3b709a3ab240c0ec7f.tar.gz
rneovim-e143be7f3da154db20a0fc3b709a3ab240c0ec7f.tar.bz2
rneovim-e143be7f3da154db20a0fc3b709a3ab240c0ec7f.zip
functests: Add tests for ShaDa variables dumping/reading
Diffstat (limited to 'test/functional/shada/variables_spec.lua')
-rw-r--r--test/functional/shada/variables_spec.lua84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
new file mode 100644
index 0000000000..c0b94b102e
--- /dev/null
+++ b/test/functional/shada/variables_spec.lua
@@ -0,0 +1,84 @@
+-- ShaDa variables saving/reading support
+local helpers = require('test.functional.helpers')
+local nvim, nvim_command, nvim_eval, eq =
+ helpers.nvim, helpers.command, helpers.eval, helpers.eq
+
+local shada_helpers = require('test.functional.shada.helpers')
+local reset, set_additional_cmd, clear =
+ shada_helpers.reset, shada_helpers.set_additional_cmd,
+ shada_helpers.clear
+
+describe('ShaDa support code', function()
+ before_each(reset)
+ after_each(clear)
+
+ it('is able to dump and read back string variable', function()
+ nvim('set_var', 'STRVAR', 'foo')
+ nvim_command('set viminfo+=!')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo+=!')
+ nvim_command('rviminfo')
+ eq('foo', nvim('get_var', 'STRVAR'))
+ end)
+
+ local autotest = function(tname, varname, varval)
+ it('is able to dump and read back ' .. tname .. ' variable automatically',
+ function()
+ set_additional_cmd('set viminfo+=!')
+ reset()
+ nvim('set_var', varname, varval)
+ -- Exit during `reset` is not a regular exit: it does not write viminfo
+ -- automatically
+ nvim_command('qall')
+ reset()
+ eq(varval, nvim('get_var', varname))
+ end)
+ end
+
+ autotest('string', 'STRVAR', 'foo')
+ autotest('number', 'NUMVAR', 42)
+ autotest('float', 'FLTVAR', 42.5)
+ autotest('dictionary', 'DCTVAR', {a=10})
+ autotest('list', 'LSTVAR', {{a=10}, {b=10.5}, {c='str'}})
+
+ it('does not read back variables without `!` in &viminfo', function()
+ nvim('set_var', 'STRVAR', 'foo')
+ nvim_command('set viminfo+=!')
+ nvim_command('wviminfo')
+ set_additional_cmd('set viminfo-=!')
+ reset()
+ nvim_command('rviminfo')
+ eq(0, nvim_eval('exists("g:STRVAR")'))
+ end)
+
+ it('does not dump variables without `!` in &viminfo', function()
+ nvim_command('set viminfo-=!')
+ nvim('set_var', 'STRVAR', 'foo')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo+=!')
+ nvim_command('rviminfo')
+ eq(0, nvim_eval('exists("g:STRVAR")'))
+ end)
+
+ it('does not dump session variables', function()
+ nvim_command('set viminfo+=!')
+ nvim('set_var', 'StrVar', 'foo')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo+=!')
+ nvim_command('rviminfo')
+ eq(0, nvim_eval('exists("g:StrVar")'))
+ end)
+
+ it('does not dump regular variables', function()
+ nvim_command('set viminfo+=!')
+ nvim('set_var', 'str_var', 'foo')
+ nvim_command('wviminfo')
+ reset()
+ nvim_command('set viminfo+=!')
+ nvim_command('rviminfo')
+ eq(0, nvim_eval('exists("g:str_var")'))
+ end)
+end)