aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada/variables_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/shada/variables_spec.lua')
-rw-r--r--test/functional/shada/variables_spec.lua56
1 files changed, 18 insertions, 38 deletions
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index 40101baf8f..f817bcef74 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -33,7 +33,7 @@ describe('ShaDa support code', function()
else
meths.set_var(varname, varval)
end
- -- Exit during `reset` is not a regular exit: it does not write shada
+ -- Exit during `reset` is not a regular exit: it does not write shada
-- automatically
nvim_command('qall')
reset()
@@ -91,35 +91,13 @@ describe('ShaDa support code', function()
eq(0, funcs.exists('g:str_var'))
end)
- it('dumps and loads variables correctly when &encoding is not UTF-8',
+ it('dumps and loads variables correctly with utf-8 strings',
function()
- set_additional_cmd('set encoding=latin1')
reset()
- -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
- meths.set_var('STRVAR', '\171')
- meths.set_var('LSTVAR', {'\171'})
- meths.set_var('DCTVAR', {['\171']='\171'})
- meths.set_var('NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
- {a='Test'}}})
- nvim_command('qall')
- reset()
- eq('\171', meths.get_var('STRVAR'))
- eq({'\171'}, meths.get_var('LSTVAR'))
- eq({['\171']='\171'}, meths.get_var('DCTVAR'))
- eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
- meths.get_var('NESTEDVAR'))
- end)
-
- it('dumps and loads variables correctly when &encoding /= UTF-8 when dumping',
- function()
- set_additional_cmd('set encoding=latin1')
- reset()
- -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
- meths.set_var('STRVAR', '\171')
- meths.set_var('LSTVAR', {'\171'})
- meths.set_var('DCTVAR', {['\171']='\171'})
- meths.set_var('NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
- {a='Test'}}})
+ meths.set_var('STRVAR', '«')
+ meths.set_var('LSTVAR', {'«'})
+ meths.set_var('DCTVAR', {['«']='«'})
+ meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
set_additional_cmd('')
nvim_command('qall')
reset()
@@ -129,20 +107,22 @@ describe('ShaDa support code', function()
eq({['«']={{'«'}, {['«']='«'}, {a='Test'}}}, meths.get_var('NESTEDVAR'))
end)
- it('dumps and loads variables correctly when &encoding /= UTF-8 when loading',
+ it('dumps and loads variables correctly with 8-bit strings',
function()
+ reset()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
- meths.set_var('STRVAR', '«')
- meths.set_var('LSTVAR', {'«'})
- meths.set_var('DCTVAR', {['«']='«'})
- meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
- set_additional_cmd('set encoding=latin1')
+ -- This is invalid unicode, but we should still dump and restore it.
+ meths.set_var('STRVAR', '\171')
+ meths.set_var('LSTVAR', {'\171'})
+ meths.set_var('DCTVAR', {['«\171']='«\171'})
+ meths.set_var('NESTEDVAR', {['\171']={{'\171«'}, {['\171']='\171'},
+ {a='Test'}}})
nvim_command('qall')
reset()
eq('\171', meths.get_var('STRVAR'))
eq({'\171'}, meths.get_var('LSTVAR'))
- eq({['\171']='\171'}, meths.get_var('DCTVAR'))
- eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
+ eq({['«\171']='«\171'}, meths.get_var('DCTVAR'))
+ eq({['\171']={{'\171«'}, {['\171']='\171'}, {a='Test'}}},
meths.get_var('NESTEDVAR'))
end)
@@ -152,7 +132,7 @@ describe('ShaDa support code', function()
meths.set_var('U', '10')
nvim_command('set shada+=!')
set_additional_cmd('set shada+=!')
- eq('Vim(wshada):E951: Error while dumping variable g:F, itself: attempt to dump function reference',
+ eq('Vim(wshada):E5004: Error while dumping variable g:F, itself: attempt to dump function reference',
exc_exec('wshada'))
meths.set_option('shada', '')
reset()
@@ -165,7 +145,7 @@ describe('ShaDa support code', function()
nvim_command('call add(L, L)')
meths.set_var('U', '10')
nvim_command('set shada+=!')
- eq('Vim(wshada):E952: Unable to dump variable g:L: container references itself in index 0',
+ eq('Vim(wshada):E5005: Unable to dump variable g:L: container references itself in index 0',
exc_exec('wshada'))
meths.set_option('shada', '')
set_additional_cmd('set shada+=!')