diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2016-11-05 18:12:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-05 18:12:14 +0100 |
commit | 9147331e212e8d0fff0f30344007faffd42609ee (patch) | |
tree | 6d1853a72b94ce19ba0cc163c664a9a206da0091 /test/functional/shada/variables_spec.lua | |
parent | 32d9c19e294f38a6adae6e055fc606fc3fd33f2f (diff) | |
parent | 4ab3fe8eaadb5456eeafc49df2fb0ecf71d836cc (diff) | |
download | rneovim-9147331e212e8d0fff0f30344007faffd42609ee.tar.gz rneovim-9147331e212e8d0fff0f30344007faffd42609ee.tar.bz2 rneovim-9147331e212e8d0fff0f30344007faffd42609ee.zip |
Merge pull request #2905 from bfredl/utf8
Only allow encoding=utf-8 and simplify multibyte code
Diffstat (limited to 'test/functional/shada/variables_spec.lua')
-rw-r--r-- | test/functional/shada/variables_spec.lua | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua index 40101baf8f..15502f0b71 100644 --- a/test/functional/shada/variables_spec.lua +++ b/test/functional/shada/variables_spec.lua @@ -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) |