aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/shada/history_spec.lua155
-rw-r--r--test/functional/shada/registers_spec.lua33
-rw-r--r--test/functional/shada/variables_spec.lua55
3 files changed, 243 insertions, 0 deletions
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 811afd268f..5a7db2bfa6 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -124,4 +124,159 @@ describe('ShaDa support code', function()
nvim_command('&')
eq('goo', nvim_eval('getline(1)'))
end)
+
+ it('dumps and loads history correctly when &encoding is not UTF-8', function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_feed(':echo "\171"\n')
+ nvim_command('qall')
+ reset()
+ eq('echo "\171"', nvim_eval('histget(":", -1)'))
+ end)
+
+ it('dumps and loads history 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
+ nvim_feed(':echo "\171"\n')
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ eq('echo "«"', nvim_eval('histget(":", -1)'))
+ end)
+
+ it('dumps and loads history correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_feed(':echo "«"\n')
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ eq('echo "\171"', nvim_eval('histget(":", -1)'))
+ end)
+
+ it('dumps and loads replacement correctly when &encoding is not UTF-8',
+ function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('substitute/./\171/ge')
+ nvim_command('qall!')
+ reset()
+ nvim_eval('setline(".", ["."])')
+ nvim_command('&')
+ eq('\171', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps&loads replacement 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
+ nvim_command('substitute/./\171/ge')
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["."])')
+ nvim_command('&')
+ eq('«', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps&loads replacement correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('substitute/./«/ge')
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["."])')
+ nvim_command('&')
+ eq('\171', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps and loads substitute pattern correctly when &encoding is not UTF-8',
+ function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('substitute/\171/./ge')
+ nvim_command('qall!')
+ reset()
+ nvim_eval('setline(".", ["\171«"])')
+ nvim_command('&')
+ eq('.«', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps&loads s/pattern 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
+ nvim_command('substitute/\171/./ge')
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["«\171"])')
+ nvim_command('&')
+ eq('.\171', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps&loads s/pattern correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('substitute/«/./ge')
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["\171«"])')
+ nvim_command('&')
+ eq('.«', nvim_eval('getline(".")'))
+ end)
+
+ it('dumps and loads search pattern correctly when &encoding is not UTF-8',
+ function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('silent! /\171/')
+ nvim_command('set viminfo+=/0')
+ nvim_command('qall!')
+ reset()
+ nvim_eval('setline(".", ["\171«"])')
+ nvim_command('~&')
+ eq('«', nvim_eval('getline(".")'))
+ eq('', nvim_eval('histget("/", -1)'))
+ end)
+
+ it('dumps&loads /pattern 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
+ nvim_command('silent! /\171/')
+ nvim_command('set viminfo+=/0')
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["«\171"])')
+ nvim_command('~&')
+ eq('\171', nvim_eval('getline(".")'))
+ eq('', nvim_eval('histget("/", -1)'))
+ end)
+
+ it('dumps&loads /pattern correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim_command('silent! /«/')
+ nvim_command('set viminfo+=/0')
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ nvim_eval('setline(".", ["\171«"])')
+ nvim_command('~&')
+ eq('«', nvim_eval('getline(".")'))
+ eq('', nvim_eval('histget("/", -1)'))
+ end)
end)
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index 75c86628a6..7efb100cd6 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -138,4 +138,37 @@ describe('ShaDa support code', function()
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
eq({nil, ''}, getreg('h'))
end)
+
+ it('dumps and loads register correctly when &encoding is not UTF-8',
+ function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ setreg('e', {'\171'}, 'c')
+ nvim_command('qall')
+ reset()
+ eq({{'\171'}, 'v'}, getreg('e'))
+ end)
+
+ it('dumps and loads history 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
+ setreg('e', {'\171'}, 'c')
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ eq({{'«'}, 'v'}, getreg('e'))
+ end)
+
+ it('dumps and loads history correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ setreg('e', {'«'}, 'c')
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ eq({{'\171'}, 'v'}, getreg('e'))
+ end)
end)
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index c0b94b102e..0ffa524238 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -81,4 +81,59 @@ describe('ShaDa support code', function()
nvim_command('rviminfo')
eq(0, nvim_eval('exists("g:str_var")'))
end)
+
+ it('dumps and loads variables correctly when &encoding is not UTF-8',
+ function()
+ set_additional_cmd('set encoding=latin1')
+ reset()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim('set_var', 'STRVAR', '\171')
+ nvim('set_var', 'LSTVAR', {'\171'})
+ nvim('set_var', 'DCTVAR', {['\171']='\171'})
+ nvim('set_var', 'NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
+ {a='Test'}}})
+ nvim_command('qall')
+ reset()
+ eq('\171', nvim('get_var', 'STRVAR'))
+ eq({'\171'}, nvim('get_var', 'LSTVAR'))
+ eq({['\171']='\171'}, nvim('get_var', 'DCTVAR'))
+ eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
+ nvim('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
+ nvim('set_var', 'STRVAR', '\171')
+ nvim('set_var', 'LSTVAR', {'\171'})
+ nvim('set_var', 'DCTVAR', {['\171']='\171'})
+ nvim('set_var', 'NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
+ {a='Test'}}})
+ set_additional_cmd('')
+ nvim_command('qall')
+ reset()
+ eq('«', nvim('get_var', 'STRVAR'))
+ eq({'«'}, nvim('get_var', 'LSTVAR'))
+ eq({['«']='«'}, nvim('get_var', 'DCTVAR'))
+ eq({['«']={{'«'}, {['«']='«'}, {a='Test'}}}, nvim('get_var', 'NESTEDVAR'))
+ end)
+
+ it('dumps and loads variables correctly when &encoding /= UTF-8 when loading',
+ function()
+ -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
+ nvim('set_var', 'STRVAR', '«')
+ nvim('set_var', 'LSTVAR', {'«'})
+ nvim('set_var', 'DCTVAR', {['«']='«'})
+ nvim('set_var', 'NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
+ set_additional_cmd('set encoding=latin1')
+ nvim_command('qall')
+ reset()
+ eq('\171', nvim('get_var', 'STRVAR'))
+ eq({'\171'}, nvim('get_var', 'LSTVAR'))
+ eq({['\171']='\171'}, nvim('get_var', 'DCTVAR'))
+ eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
+ nvim('get_var', 'NESTEDVAR'))
+ end)
end)