diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2015-09-14 13:10:51 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2016-11-05 14:49:24 +0100 |
commit | b3ece5c81c3c50cfd3fc0df165460be4ffd97723 (patch) | |
tree | dff0a08d38d3bde598139a08a3db302586c604dc /test/functional/shada | |
parent | 18f56c8e90ca0d3a78924289e6ad9c9a74af4604 (diff) | |
download | rneovim-b3ece5c81c3c50cfd3fc0df165460be4ffd97723.tar.gz rneovim-b3ece5c81c3c50cfd3fc0df165460be4ffd97723.tar.bz2 rneovim-b3ece5c81c3c50cfd3fc0df165460be4ffd97723.zip |
encoding: update tests
Change shada reencoding tests to check for
correct handling of UTF-8 and binary strings.
Delete enc=latin1 json tests.
Diffstat (limited to 'test/functional/shada')
-rw-r--r-- | test/functional/shada/history_spec.lua | 129 | ||||
-rw-r--r-- | test/functional/shada/registers_spec.lua | 24 | ||||
-rw-r--r-- | test/functional/shada/variables_spec.lua | 50 |
3 files changed, 34 insertions, 169 deletions
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua index 22e653b1d6..c4be9e563d 100644 --- a/test/functional/shada/history_spec.lua +++ b/test/functional/shada/history_spec.lua @@ -4,9 +4,7 @@ local nvim_command, funcs, meths, nvim_feed, eq = helpers.command, helpers.funcs, helpers.meths, helpers.feed, 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 +local reset, clear = shada_helpers.reset, shada_helpers.clear describe('ShaDa support code', function() before_each(reset) @@ -173,158 +171,57 @@ describe('ShaDa support code', function() eq('goo', funcs.getline(1)) end) - it('dumps and loads history correctly when &encoding is not UTF-8', function() - set_additional_cmd('set encoding=latin1') + it('dumps and loads history with UTF-8 characters', function() 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"', funcs.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 "«"', funcs.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"', funcs.histget(':', -1)) + eq('echo "«"', funcs.histget(':', -1)) end) - it('dumps and loads replacement correctly when &encoding is not UTF-8', + it('dumps and loads replacement with UTF-8 characters', 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('substitute/./«/ge') nvim_command('qall!') reset() funcs.setline('.', {'.'}) nvim_command('&') - eq('\171', funcs.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() - funcs.setline('.', {'.'}) - nvim_command('&') eq('«', funcs.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() - funcs.setline('.', {'.'}) - nvim_command('&') - eq('\171', funcs.getline('.')) - end) - - it('dumps and loads substitute pattern correctly when &encoding is not UTF-8', + it('dumps and loads substitute pattern with UTF-8 characters', 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('substitute/«/./ge') nvim_command('qall!') reset() - funcs.setline('.', {'\171«'}) - nvim_command('&') - eq('.«', funcs.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() funcs.setline('.', {'«\171'}) nvim_command('&') eq('.\171', funcs.getline('.')) end) - it('dumps&loads s/pattern correctly when &encoding /= UTF-8 when loading', + it('dumps and loads search pattern with UTF-8 characters', 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() - funcs.setline('.', {'\171«'}) - nvim_command('&') - eq('.«', funcs.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('silent! /«/') nvim_command('set shada+=/0') nvim_command('qall!') reset() funcs.setline('.', {'\171«'}) nvim_command('~&') - eq('«', funcs.getline('.')) - eq('', funcs.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 shada+=/0') - set_additional_cmd('') - nvim_command('qall') - reset() - funcs.setline('.', {'«\171'}) - nvim_command('~&') eq('\171', funcs.getline('.')) eq('', funcs.histget('/', -1)) end) - it('dumps&loads /pattern correctly when &encoding /= UTF-8 when loading', + it('dumps and loads search pattern with 8-bit single-byte', function() -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1 - nvim_command('silent! /«/') + nvim_command('silent! /\171/') nvim_command('set shada+=/0') - set_additional_cmd('set encoding=latin1') - nvim_command('qall') + nvim_command('qall!') reset() funcs.setline('.', {'\171«'}) nvim_command('~&') eq('«', funcs.getline('.')) eq('', funcs.histget('/', -1)) end) + end) diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua index f1c587c640..fc812f799c 100644 --- a/test/functional/shada/registers_spec.lua +++ b/test/functional/shada/registers_spec.lua @@ -128,36 +128,24 @@ describe('ShaDa support code', function() eq({{}, ''}, getreg('h')) end) - it('dumps and loads register correctly when &encoding is not UTF-8', + it('dumps and loads register correctly with utf-8 contents', function() - set_additional_cmd('set encoding=latin1') reset() - -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1 - setreg('e', {'\171'}, 'c') + setreg('e', {'«'}, 'c') nvim_command('qall') reset() - eq({{'\171'}, 'v'}, getreg('e')) + eq({{'«'}, 'v'}, getreg('e')) end) - it('dumps and loads history correctly when &encoding /= UTF-8 when dumping', + it('dumps and loads history correctly with 8-bit single-byte', function() - set_additional_cmd('set encoding=latin1') reset() -- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1 - setreg('e', {'\171'}, 'c') + setreg('e', {'\171«'}, 'c') set_additional_cmd('') nvim_command('qall') reset() - eq({{'«'}, 'v'}, getreg('e')) + eq({{'\171«'}, '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 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) |