From 622a3ae8ea7e1761f31eaea99e22b5453a286c56 Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Thu, 9 Jul 2015 15:38:56 +0200 Subject: tests: Migrate legacy test 69. --- .../legacy/069_multi_byte_formatting_spec.lua | 339 +++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 test/functional/legacy/069_multi_byte_formatting_spec.lua (limited to 'test/functional') diff --git a/test/functional/legacy/069_multi_byte_formatting_spec.lua b/test/functional/legacy/069_multi_byte_formatting_spec.lua new file mode 100644 index 0000000000..5ca429a787 --- /dev/null +++ b/test/functional/legacy/069_multi_byte_formatting_spec.lua @@ -0,0 +1,339 @@ +-- Test for multi-byte text formatting. +-- Also test, that 'mps' with multibyte chars works. +-- And test "ra" on multi-byte characters. +-- Also test byteidx() and byteidxcomp() + +local helpers = require('test.functional.helpers') +local feed, insert = helpers.feed, helpers.insert +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('multi byte text', function() + before_each(clear) + + it('formatting with "set fo=t"', function() + insert([[ + { + XYZ + abc XYZ + }]]) + execute('/^{/+1') + execute('set tw=2 fo=t') + feed('gqgqjgqgqo') + feed('XYZ') + feed('abc XYZ') + expect([[ + { + XYZ + abc + XYZ + + XYZ + abc + XYZ + }]]) + end) + + it('formatting with "set fo=tm"', function() + insert([[ + { + X + Xa + X a + XY + X Y + }]]) + execute('/^{/+1') + execute('set tw=1 fo=tm') + feed('gqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('X a') + feed('XY') + feed('X Y') + expect([[ + { + X + X + a + X + a + X + Y + X + Y + + X + X + a + X + a + X + Y + X + Y + }]]) + end) + + it('formatting with "set fo=tm" (part 2)', function() + insert([[ + { + X + Xa + X a + XY + X Y + aX + abX + abcX + abX c + abXY + }]]) + execute('/^{/+1') + execute('set tw=2 fo=tm') + feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('X a') + feed('XY') + feed('X Y') + feed('aX') + feed('abX') + feed('abcX') + feed('abX c') + feed('abXY') + expect([[ + { + X + X + a + X + a + X + Y + X + Y + a + X + ab + X + abc + X + ab + X + c + ab + X + Y + + X + X + a + X + a + X + Y + X + Y + a + X + ab + X + abc + X + ab + X + c + ab + X + Y + }]]) + end) + + it('formatting with "set ai fo=tm"', function() + insert([[ + { + X + Xa + }]]) + execute('/^{/+1') + execute('set ai tw=2 fo=tm') + feed('gqgqjgqgqo') + feed('X') + feed('Xa') + expect([[ + { + X + X + a + + X + X + a + }]]) + end) + + it('formatting with "set ai fo=tm" (part 2)', function() + insert([[ + { + X + Xa + }]]) + execute('/^{/+1') + execute('set noai tw=2 fo=tm') + feed('gqgqjgqgqo') + -- Literal spaces will be trimmed from the by feed(). + feed('') + feed('Xa') + expect([[ + { + X + X + a + + X + X + a + }]]) + end) + + it('formatting with "set fo=cqm" and multi byte comments', function() + insert([[ + { + X + Xa + XaY + XY + XYZ + X Y + X YZ + XX + XXa + XXY + }]]) + execute('/^{/+1') + execute('set tw=2 fo=cqm comments=n:X') + feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('XaY') + feed('XY') + feed('XYZ') + feed('X Y') + feed('X YZ') + feed('XX') + feed('XXa') + feed('XXY') + expect([[ + { + X + Xa + Xa + XY + XY + XY + XZ + X Y + X Y + X Z + XX + XXa + XXY + + X + Xa + Xa + XY + XY + XY + XZ + X Y + X Y + X Z + XX + XXa + XXY + }]]) + end) + + it('formatting in replace mode', function() + insert([[ + { + + }]]) + execute('/^{/+1') + execute('set tw=2 fo=tm') + feed('RXa') + expect([[ + { + X + a + }]]) + end) + + it("as values of 'mps'", function() + insert([[ + { + ‘ two three ’ four + }]]) + execute('/^{/+1') + execute('set mps+=‘:’') + feed('d%') + expect([[ + { + four + }]]) + end) + + it('can be replaced with r', function() + insert([[ + abba + aab]]) + feed('gg0Vjra') + expect([[ + aaaa + aaa]]) + end) + + it("doesn't interfere with 'whichwrap'", function() + insert([[ + á + x]]) + execute('set whichwrap+=h') + execute('/^x') + feed('dh') + expect([[ + áx]]) + end) + + it('can be querried with byteidx() and byteidxcomp()', function() + insert([[ + byteidx + byteidxcomp]]) + -- One char of two bytes. + execute("let a = '.é.'") + -- Normal e with composing char. + execute("let b = '.é.'") + execute('/^byteidx') + execute('put =string([byteidx(a, 0), byteidx(a, 1), byteidx(a, 2), byteidx(a, 3), byteidx(a, 4)])') + execute('put =string([byteidx(b, 0), byteidx(b, 1), byteidx(b, 2), byteidx(b, 3), byteidx(b, 4)])') + execute('/^byteidxcomp') + execute('put =string([byteidxcomp(a, 0), byteidxcomp(a, 1), byteidxcomp(a, 2), byteidxcomp(a, 3), byteidxcomp(a, 4)])') + execute("let b = '.é.'") + execute('put =string([byteidxcomp(b, 0), byteidxcomp(b, 1), byteidxcomp(b, 2), byteidxcomp(b, 3), byteidxcomp(b, 4), byteidxcomp(b, 5)])') + expect([=[ + byteidx + [0, 1, 3, 4, -1] + [0, 1, 4, 5, -1] + byteidxcomp + [0, 1, 3, 4, -1] + [0, 1, 2, 4, 5, -1]]=]) + end) + + it('correctly interact with the \zs pattern', function() + insert('substitute') + execute([[let y = substitute('123', '\zs', 'a', 'g') | put =y]]) + expect([[ + substitute + a1a2a3a]]) + end) +end) -- cgit From b4c172d612a3c8d936ed8e33c2ab4c5f7cbec39a Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Fri, 10 Jul 2015 15:01:57 +0200 Subject: tests: Modernize migrated legacy test 69. --- .../legacy/069_multi_byte_formatting_spec.lua | 339 -------------------- .../legacy/069_multibyte_formatting_spec.lua | 340 +++++++++++++++++++++ 2 files changed, 340 insertions(+), 339 deletions(-) delete mode 100644 test/functional/legacy/069_multi_byte_formatting_spec.lua create mode 100644 test/functional/legacy/069_multibyte_formatting_spec.lua (limited to 'test/functional') diff --git a/test/functional/legacy/069_multi_byte_formatting_spec.lua b/test/functional/legacy/069_multi_byte_formatting_spec.lua deleted file mode 100644 index 5ca429a787..0000000000 --- a/test/functional/legacy/069_multi_byte_formatting_spec.lua +++ /dev/null @@ -1,339 +0,0 @@ --- Test for multi-byte text formatting. --- Also test, that 'mps' with multibyte chars works. --- And test "ra" on multi-byte characters. --- Also test byteidx() and byteidxcomp() - -local helpers = require('test.functional.helpers') -local feed, insert = helpers.feed, helpers.insert -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect - -describe('multi byte text', function() - before_each(clear) - - it('formatting with "set fo=t"', function() - insert([[ - { - XYZ - abc XYZ - }]]) - execute('/^{/+1') - execute('set tw=2 fo=t') - feed('gqgqjgqgqo') - feed('XYZ') - feed('abc XYZ') - expect([[ - { - XYZ - abc - XYZ - - XYZ - abc - XYZ - }]]) - end) - - it('formatting with "set fo=tm"', function() - insert([[ - { - X - Xa - X a - XY - X Y - }]]) - execute('/^{/+1') - execute('set tw=1 fo=tm') - feed('gqgqjgqgqjgqgqjgqgqjgqgqo') - feed('X') - feed('Xa') - feed('X a') - feed('XY') - feed('X Y') - expect([[ - { - X - X - a - X - a - X - Y - X - Y - - X - X - a - X - a - X - Y - X - Y - }]]) - end) - - it('formatting with "set fo=tm" (part 2)', function() - insert([[ - { - X - Xa - X a - XY - X Y - aX - abX - abcX - abX c - abXY - }]]) - execute('/^{/+1') - execute('set tw=2 fo=tm') - feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') - feed('X') - feed('Xa') - feed('X a') - feed('XY') - feed('X Y') - feed('aX') - feed('abX') - feed('abcX') - feed('abX c') - feed('abXY') - expect([[ - { - X - X - a - X - a - X - Y - X - Y - a - X - ab - X - abc - X - ab - X - c - ab - X - Y - - X - X - a - X - a - X - Y - X - Y - a - X - ab - X - abc - X - ab - X - c - ab - X - Y - }]]) - end) - - it('formatting with "set ai fo=tm"', function() - insert([[ - { - X - Xa - }]]) - execute('/^{/+1') - execute('set ai tw=2 fo=tm') - feed('gqgqjgqgqo') - feed('X') - feed('Xa') - expect([[ - { - X - X - a - - X - X - a - }]]) - end) - - it('formatting with "set ai fo=tm" (part 2)', function() - insert([[ - { - X - Xa - }]]) - execute('/^{/+1') - execute('set noai tw=2 fo=tm') - feed('gqgqjgqgqo') - -- Literal spaces will be trimmed from the by feed(). - feed('') - feed('Xa') - expect([[ - { - X - X - a - - X - X - a - }]]) - end) - - it('formatting with "set fo=cqm" and multi byte comments', function() - insert([[ - { - X - Xa - XaY - XY - XYZ - X Y - X YZ - XX - XXa - XXY - }]]) - execute('/^{/+1') - execute('set tw=2 fo=cqm comments=n:X') - feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') - feed('X') - feed('Xa') - feed('XaY') - feed('XY') - feed('XYZ') - feed('X Y') - feed('X YZ') - feed('XX') - feed('XXa') - feed('XXY') - expect([[ - { - X - Xa - Xa - XY - XY - XY - XZ - X Y - X Y - X Z - XX - XXa - XXY - - X - Xa - Xa - XY - XY - XY - XZ - X Y - X Y - X Z - XX - XXa - XXY - }]]) - end) - - it('formatting in replace mode', function() - insert([[ - { - - }]]) - execute('/^{/+1') - execute('set tw=2 fo=tm') - feed('RXa') - expect([[ - { - X - a - }]]) - end) - - it("as values of 'mps'", function() - insert([[ - { - ‘ two three ’ four - }]]) - execute('/^{/+1') - execute('set mps+=‘:’') - feed('d%') - expect([[ - { - four - }]]) - end) - - it('can be replaced with r', function() - insert([[ - abba - aab]]) - feed('gg0Vjra') - expect([[ - aaaa - aaa]]) - end) - - it("doesn't interfere with 'whichwrap'", function() - insert([[ - á - x]]) - execute('set whichwrap+=h') - execute('/^x') - feed('dh') - expect([[ - áx]]) - end) - - it('can be querried with byteidx() and byteidxcomp()', function() - insert([[ - byteidx - byteidxcomp]]) - -- One char of two bytes. - execute("let a = '.é.'") - -- Normal e with composing char. - execute("let b = '.é.'") - execute('/^byteidx') - execute('put =string([byteidx(a, 0), byteidx(a, 1), byteidx(a, 2), byteidx(a, 3), byteidx(a, 4)])') - execute('put =string([byteidx(b, 0), byteidx(b, 1), byteidx(b, 2), byteidx(b, 3), byteidx(b, 4)])') - execute('/^byteidxcomp') - execute('put =string([byteidxcomp(a, 0), byteidxcomp(a, 1), byteidxcomp(a, 2), byteidxcomp(a, 3), byteidxcomp(a, 4)])') - execute("let b = '.é.'") - execute('put =string([byteidxcomp(b, 0), byteidxcomp(b, 1), byteidxcomp(b, 2), byteidxcomp(b, 3), byteidxcomp(b, 4), byteidxcomp(b, 5)])') - expect([=[ - byteidx - [0, 1, 3, 4, -1] - [0, 1, 4, 5, -1] - byteidxcomp - [0, 1, 3, 4, -1] - [0, 1, 2, 4, 5, -1]]=]) - end) - - it('correctly interact with the \zs pattern', function() - insert('substitute') - execute([[let y = substitute('123', '\zs', 'a', 'g') | put =y]]) - expect([[ - substitute - a1a2a3a]]) - end) -end) diff --git a/test/functional/legacy/069_multibyte_formatting_spec.lua b/test/functional/legacy/069_multibyte_formatting_spec.lua new file mode 100644 index 0000000000..6edcd8b7f2 --- /dev/null +++ b/test/functional/legacy/069_multibyte_formatting_spec.lua @@ -0,0 +1,340 @@ +-- Test for multibyte text formatting. +-- Also test, that 'mps' with multibyte chars works. +-- And test "ra" on multibyte characters. +-- Also test byteidx() and byteidxcomp() + +local helpers = require('test.functional.helpers')(after_each) +local feed, insert, eq, eval, clear, execute, expect = helpers.feed, + helpers.insert, helpers.eq, helpers.eval, helpers.clear, helpers.execute, + helpers.expect + +describe('multibyte text', function() + before_each(clear) + + it('formatting with "set fo=t"', function() + insert([[ + { + XYZ + abc XYZ + }]]) + execute('/^{/+1') + execute('set tw=2 fo=t') + feed('gqgqjgqgqo') + feed('XYZ') + feed('abc XYZ') + expect([[ + { + XYZ + abc + XYZ + + XYZ + abc + XYZ + }]]) + end) + + it('formatting with "set fo=tm"', function() + insert([[ + { + X + Xa + X a + XY + X Y + }]]) + execute('/^{/+1') + execute('set tw=1 fo=tm') + feed('gqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('X a') + feed('XY') + feed('X Y') + expect([[ + { + X + X + a + X + a + X + Y + X + Y + + X + X + a + X + a + X + Y + X + Y + }]]) + end) + + it('formatting with "set fo=tm" (part 2)', function() + insert([[ + { + X + Xa + X a + XY + X Y + aX + abX + abcX + abX c + abXY + }]]) + execute('/^{/+1') + execute('set tw=2 fo=tm') + feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('X a') + feed('XY') + feed('X Y') + feed('aX') + feed('abX') + feed('abcX') + feed('abX c') + feed('abXY') + expect([[ + { + X + X + a + X + a + X + Y + X + Y + a + X + ab + X + abc + X + ab + X + c + ab + X + Y + + X + X + a + X + a + X + Y + X + Y + a + X + ab + X + abc + X + ab + X + c + ab + X + Y + }]]) + end) + + it('formatting with "set ai fo=tm"', function() + insert([[ + { + X + Xa + }]]) + execute('/^{/+1') + execute('set ai tw=2 fo=tm') + feed('gqgqjgqgqo') + feed('X') + feed('Xa') + expect([[ + { + X + X + a + + X + X + a + }]]) + end) + + it('formatting with "set ai fo=tm" (part 2)', function() + insert([[ + { + X + Xa + }]]) + execute('/^{/+1') + execute('set noai tw=2 fo=tm') + feed('gqgqjgqgqo') + -- Literal spaces will be trimmed from the by feed(). + feed('') + feed('Xa') + expect([[ + { + X + X + a + + X + X + a + }]]) + end) + + it('formatting with "set fo=cqm" and multibyte comments', function() + insert([[ + { + X + Xa + XaY + XY + XYZ + X Y + X YZ + XX + XXa + XXY + }]]) + execute('/^{/+1') + execute('set tw=2 fo=cqm comments=n:X') + feed('gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo') + feed('X') + feed('Xa') + feed('XaY') + feed('XY') + feed('XYZ') + feed('X Y') + feed('X YZ') + feed('XX') + feed('XXa') + feed('XXY') + expect([[ + { + X + Xa + Xa + XY + XY + XY + XZ + X Y + X Y + X Z + XX + XXa + XXY + + X + Xa + Xa + XY + XY + XY + XZ + X Y + X Y + X Z + XX + XXa + XXY + }]]) + end) + + it('formatting in replace mode', function() + insert([[ + { + + }]]) + execute('/^{/+1') + execute('set tw=2 fo=tm') + feed('RXa') + expect([[ + { + X + a + }]]) + end) + + it("as values of 'mps'", function() + insert([[ + { + ‘ two three ’ four + }]]) + execute('/^{/+1') + execute('set mps+=‘:’') + feed('d%') + expect([[ + { + four + }]]) + end) + + it('can be replaced with r', function() + insert([[ + abba + aab]]) + feed('gg0Vjra') + expect([[ + aaaa + aaa]]) + end) + + it("doesn't interfere with 'whichwrap'", function() + insert([[ + á + x]]) + execute('set whichwrap+=h') + execute('/^x') + feed('dh') + expect([[ + áx]]) + end) + + it('can be queried with byteidx() and byteidxcomp()', function() + -- One char of two bytes. + execute("let a = '.é.'") + -- Normal e with composing char. + execute("let b = '.é.'") + eq(0, eval('byteidx(a, 0)')) + eq(1, eval('byteidx(a, 1)')) + eq(3, eval('byteidx(a, 2)')) + eq(4, eval('byteidx(a, 3)')) + eq(-1, eval('byteidx(a, 4)')) + eq(0, eval('byteidx(b, 0)')) + eq(1, eval('byteidx(b, 1)')) + eq(4, eval('byteidx(b, 2)')) + eq(5, eval('byteidx(b, 3)')) + eq(-1, eval('byteidx(b, 4)')) + eq(0, eval('byteidxcomp(a, 0)')) + eq(1, eval('byteidxcomp(a, 1)')) + eq(3, eval('byteidxcomp(a, 2)')) + eq(4, eval('byteidxcomp(a, 3)')) + eq(-1, eval('byteidxcomp(a, 4)')) + eq(0, eval('byteidxcomp(b, 0)')) + eq(1, eval('byteidxcomp(b, 1)')) + eq(2, eval('byteidxcomp(b, 2)')) + eq(4, eval('byteidxcomp(b, 3)')) + eq(5, eval('byteidxcomp(b, 4)')) + eq(-1, eval('byteidxcomp(b, 5)')) + end) + + it('correctly interact with the \zs pattern', function() + eq('a1a2a3a', eval([[substitute('123', '\zs', 'a', 'g')]])) + end) +end) -- cgit