From d41322fafb153720d7a5506f5022c46879afb2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=BCrgin?= <676c7473@gmail.com> Date: Sun, 22 Mar 2015 23:27:01 +0100 Subject: [PATCH] tests: Migrate legacy tests 92 and 93 #2261 --- src/nvim/testdir/Makefile | 1 - src/nvim/testdir/test92.in | 48 --------- src/nvim/testdir/test92.ok | 26 ----- src/nvim/testdir/test93.in | 48 --------- src/nvim/testdir/test93.ok | 26 ----- .../092_mksession_cursor_cols_utf8_spec.lua | 98 +++++++++++++++++++ .../093_mksession_cursor_cols_latin1_spec.lua | 95 ++++++++++++++++++ 7 files changed, 193 insertions(+), 149 deletions(-) delete mode 100644 src/nvim/testdir/test92.in delete mode 100644 src/nvim/testdir/test92.ok delete mode 100644 src/nvim/testdir/test93.in delete mode 100644 src/nvim/testdir/test93.ok create mode 100644 test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua create mode 100644 test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 70e6f8ee4c..be76206bfc 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -27,7 +27,6 @@ SCRIPTS := test_autoformat_join.out \ test76.out test78.out test79.out test80.out \ test82.out test83.out test85.out \ test86.out test87.out test88.out \ - test92.out test93.out \ test96.out test99.out \ test_listlbr.out \ test_breakindent.out diff --git a/src/nvim/testdir/test92.in b/src/nvim/testdir/test92.in deleted file mode 100644 index 9593aec4c7..0000000000 --- a/src/nvim/testdir/test92.in +++ /dev/null @@ -1,48 +0,0 @@ -vim: set ft=vim fenc=utf-8: - -Tests if :mksession saves cursor columns correctly in presence of tab and -multibyte characters when fileencoding=utf-8. - -STARTTEST -:so mbyte.vim -:if !has('mksession') -: e! test.ok -: wq! test.out -:endif -:set sessionoptions=buffers splitbelow fileencoding=utf-8 -/^start: -:vsplit -j16|:split -j16|:split -j16|:split -j8|:split -j8|:split -j16|:split -j16|:split -j16|:wincmd l -/^start: -:set nowrap -j16|3zl:split -j016|3zl:split -j016|3zl:split -j08|3zl:split -j08|3zl:split -j016|3zl:split -j016|3zl:split -j016|3zl:split -:mksession! test.out -:new test.out -:v/\(^ *normal! 0\|^ *exe 'normal!\)/d -:w! test.out -:qa! -ENDTEST - -start: -no multibyte chAracter - one leaDing tab - four leadinG spaces -two consecutive tabs -two tabs in one line -one … multibyteCharacter -a “b” two multiByte characters -“c”1€ three mulTibyte characters diff --git a/src/nvim/testdir/test92.ok b/src/nvim/testdir/test92.ok deleted file mode 100644 index cca5ec487c..0000000000 --- a/src/nvim/testdir/test92.ok +++ /dev/null @@ -1,26 +0,0 @@ -normal! 016| -normal! 016| -normal! 016| -normal! 08| -normal! 08| -normal! 016| -normal! 016| -normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 8 . '|' - normal! 08| - exe 'normal! ' . s:c . '|zs' . 8 . '|' - normal! 08| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| diff --git a/src/nvim/testdir/test93.in b/src/nvim/testdir/test93.in deleted file mode 100644 index 877838ce1b..0000000000 --- a/src/nvim/testdir/test93.in +++ /dev/null @@ -1,48 +0,0 @@ -vim: set ft=vim fenc=latin1: - -Tests if :mksession saves cursor columns correctly in presence of tab and -multibyte characters when fileencoding=latin1. - -STARTTEST -:so mbyte.vim -:if !has('mksession') -: e! test.ok -: wq! test.out -:endif -:set sessionoptions=buffers splitbelow fileencoding=latin1 -/^start: -:vsplit -j16|:split -j16|:split -j16|:split -j8|:split -j8|:split -j16|:split -j16|:split -j16|:wincmd l -/^start: -:set nowrap -j16|3zl:split -j016|3zl:split -j016|3zl:split -j08|3zl:split -j08|3zl:split -j016|3zl:split -j016|3zl:split -j016|3zl:split -:mksession! test.out -:new test.out -:v/\(^ *normal! 0\|^ *exe 'normal!\)/d -:w! test.out -:qa! -ENDTEST - -start: -no multibyte chAracter - one leaDing tab - four leadinG spaces -two consecutive tabs -two tabs in one line -one multibyteCharacter -a two multiByte characters -A three mulTibyte characters diff --git a/src/nvim/testdir/test93.ok b/src/nvim/testdir/test93.ok deleted file mode 100644 index cca5ec487c..0000000000 --- a/src/nvim/testdir/test93.ok +++ /dev/null @@ -1,26 +0,0 @@ -normal! 016| -normal! 016| -normal! 016| -normal! 08| -normal! 08| -normal! 016| -normal! 016| -normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 8 . '|' - normal! 08| - exe 'normal! ' . s:c . '|zs' . 8 . '|' - normal! 08| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| - exe 'normal! ' . s:c . '|zs' . 16 . '|' - normal! 016| diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua new file mode 100644 index 0000000000..e0cc39dc40 --- /dev/null +++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua @@ -0,0 +1,98 @@ +-- Tests if :mksession saves cursor columns correctly in presence of tab and +-- multibyte characters when fileencoding=utf-8. +-- +-- Same as legacy test 93 but using UTF-8 file encoding. + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('store cursor position in session file in UTF-8', function() + setup(clear) + + teardown(function() + os.remove('test.in') + os.remove('test.out') + end) + + it('is working', function() + insert([[ + start: + no multibyte chAracter + one leaDing tab + four leadinG spaces + two consecutive tabs + two tabs in one line + one … multibyteCharacter + a “b” two multiByte characters + “c”1€ three mulTibyte characters]]) + -- This test requires the buffer to correspond to a file on disk, here named + -- "test.in", because otherwise :mksession won't write out the cursor column + -- info needed for verification. + execute('write! test.in') + + execute('set sessionoptions=buffers splitbelow fileencoding=utf-8') + + -- Move the cursor through the buffer lines and position it with "|". Using + -- :split after every normal mode command is a trick to have multiple + -- cursors on the screen that can all be stored in the session file. + execute('/^start:') + execute('vsplit') + feed('j16|:split') + feed('j16|:split') + feed('j16|:split') + feed('j8|:split') + feed('j8|:split') + feed('j16|:split') + feed('j16|:split') + feed('j16|') + + -- Again move the cursor through the buffer and position it with "|". This + -- time also perform a horizontal scroll at every step. + execute('wincmd l') + execute('/^start:') + execute('set nowrap') + feed('j16|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + feed('j08|3zl:split') + feed('j08|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + + -- Create the session file, read it back in, and prepare for verification. + execute('mksession! test.out') + execute('new test.out') + execute([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) + + -- Assert buffer contents. + expect([[ + normal! 016| + normal! 016| + normal! 016| + normal! 08| + normal! 08| + normal! 016| + normal! 016| + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 8 . '|' + normal! 08| + exe 'normal! ' . s:c . '|zs' . 8 . '|' + normal! 08| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016|]]) + end) +end) diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua new file mode 100644 index 0000000000..659e716721 --- /dev/null +++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -0,0 +1,95 @@ +-- Tests if :mksession saves cursor columns correctly in presence of tab and +-- multibyte characters when fileencoding=latin1. +-- +-- Same as legacy test 92 but using Latin-1 file encoding. + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('store cursor position in session file in Latin-1', function() + setup(clear) + + teardown(function() + os.remove('test.in') + os.remove('test.out') + end) + + it('is working', function() + insert([[ + start: + no multibyte chAracter + one leaDing tab + four leadinG spaces + two consecutive tabs + two tabs in one line + one multibyteCharacter + a two multiByte characters + A three mulTibyte characters]]) + -- Must write buffer to disk for :mksession. See the comments in + -- "092_mksession_cursor_cols_utf8_spec.lua". + execute('write! test.in') + + execute('set sessionoptions=buffers splitbelow fileencoding=latin1') + + -- Move the cursor through the buffer lines and position it with "|". + execute('/^start:') + execute('vsplit') + feed('j16|:split') + feed('j16|:split') + feed('j16|:split') + feed('j8|:split') + feed('j8|:split') + feed('j16|:split') + feed('j16|:split') + feed('j16|') + + -- Again move the cursor through the buffer and position it with "|". This + -- time also perform a horizontal scroll at every step. + execute('wincmd l') + execute('/^start:') + execute('set nowrap') + feed('j16|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + feed('j08|3zl:split') + feed('j08|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + feed('j016|3zl:split') + + -- Create the session file, read it back in, and prepare for verification. + execute('mksession! test.out') + execute('new test.out') + execute([[v/\(^ *normal! 0\|^ *exe 'normal!\)/d]]) + + -- Assert buffer contents. + expect([[ + normal! 016| + normal! 016| + normal! 016| + normal! 08| + normal! 08| + normal! 016| + normal! 016| + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 8 . '|' + normal! 08| + exe 'normal! ' . s:c . '|zs' . 8 . '|' + normal! 08| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016| + exe 'normal! ' . s:c . '|zs' . 16 . '|' + normal! 016|]]) + end) +end)