2015-07-05 16:16:05 -07:00
|
|
|
-- Tests for storing global variables in the .shada file
|
2015-05-05 01:45:49 -07:00
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local lfs = require('lfs')
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, command, eq, neq, eval, wait, spawn =
|
|
|
|
helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval,
|
2015-05-05 01:45:49 -07:00
|
|
|
helpers.wait, helpers.spawn
|
|
|
|
|
2015-07-05 16:16:05 -07:00
|
|
|
describe('storing global variables in ShaDa files', function()
|
|
|
|
local tempname = 'Xtest-functional-legacy-074'
|
2015-05-05 01:45:49 -07:00
|
|
|
setup(function()
|
|
|
|
clear()
|
2015-07-05 16:16:05 -07:00
|
|
|
os.remove(tempname)
|
2015-05-05 01:45:49 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('is working', function()
|
2015-11-17 15:31:22 -07:00
|
|
|
local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE',
|
2015-09-20 06:53:27 -07:00
|
|
|
'-i', 'Xviminfo', '--embed'})
|
2015-05-05 01:45:49 -07:00
|
|
|
helpers.set_session(nvim2)
|
|
|
|
|
|
|
|
local test_dict = {foo = 1, bar = 0, longvarible = 1000}
|
|
|
|
local test_list = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
|
|
|
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
|
|
|
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
|
|
|
|
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
|
|
|
|
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
|
|
|
89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}
|
|
|
|
|
2017-04-08 15:53:47 -07:00
|
|
|
command('set visualbell')
|
|
|
|
command('set shada+=!')
|
|
|
|
command('let MY_GLOBAL_DICT={\'foo\': 1, \'bar\': 0, \'longvarible\': 1000}')
|
|
|
|
-- Store a really long list. Initially this was testing line wrapping in
|
|
|
|
-- viminfo, but shada files has no line wrapping, no matter how long the
|
|
|
|
-- list is.
|
|
|
|
command('let MY_GLOBAL_LIST=range(1, 100)')
|
|
|
|
|
2015-05-05 01:45:49 -07:00
|
|
|
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
|
|
|
eq(test_list, eval('MY_GLOBAL_LIST'))
|
2015-06-12 00:09:12 -07:00
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('wsh! ' .. tempname)
|
2015-05-05 01:45:49 -07:00
|
|
|
wait()
|
2015-06-12 00:09:12 -07:00
|
|
|
|
2015-07-05 16:16:05 -07:00
|
|
|
-- Assert that the shada file exists.
|
|
|
|
neq(nil, lfs.attributes(tempname))
|
2017-04-08 15:53:47 -07:00
|
|
|
command('unlet MY_GLOBAL_DICT')
|
|
|
|
command('unlet MY_GLOBAL_LIST')
|
2015-05-05 01:45:49 -07:00
|
|
|
-- Assert that the variables where deleted.
|
|
|
|
eq(0, eval('exists("MY_GLOBAL_DICT")'))
|
|
|
|
eq(0, eval('exists("MY_GLOBAL_LIST")'))
|
2015-06-12 00:09:12 -07:00
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('rsh! ' .. tempname)
|
2015-06-12 00:09:12 -07:00
|
|
|
|
2015-05-05 01:45:49 -07:00
|
|
|
eq(test_list, eval('MY_GLOBAL_LIST'))
|
|
|
|
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
2015-07-05 16:16:05 -07:00
|
|
|
os.remove(tempname)
|
2015-05-05 01:45:49 -07:00
|
|
|
end)
|
|
|
|
end)
|