mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
tests: Migrate legacy test 69.
This commit is contained in:
parent
176f223ea3
commit
622a3ae8ea
@ -28,7 +28,6 @@ SCRIPTS := \
|
||||
test53.out \
|
||||
test55.out \
|
||||
test64.out \
|
||||
test69.out \
|
||||
test73.out \
|
||||
test79.out \
|
||||
test_listlbr.out \
|
||||
|
@ -1,191 +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()
|
||||
|
||||
STARTTEST
|
||||
:
|
||||
ENDTEST
|
||||
|
||||
Results of test69:
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set tw=2 fo=t
|
||||
gqgqjgqgqo
|
||||
XYZ
|
||||
abc XYZ
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
XYZ
|
||||
abc XYZ
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set tw=1 fo=tm
|
||||
gqgqjgqgqjgqgqjgqgqjgqgqo
|
||||
X
|
||||
Xa
|
||||
X a
|
||||
XY
|
||||
X Y
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
X
|
||||
Xa
|
||||
X a
|
||||
XY
|
||||
X Y
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set tw=2 fo=tm
|
||||
gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
|
||||
X
|
||||
Xa
|
||||
X a
|
||||
XY
|
||||
X Y
|
||||
aX
|
||||
abX
|
||||
abcX
|
||||
abX c
|
||||
abXY
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
X
|
||||
Xa
|
||||
X a
|
||||
XY
|
||||
X Y
|
||||
aX
|
||||
abX
|
||||
abcX
|
||||
abX c
|
||||
abXY
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set ai tw=2 fo=tm
|
||||
gqgqjgqgqo
|
||||
X
|
||||
Xa
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
X
|
||||
Xa
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set noai tw=2 fo=tm
|
||||
gqgqjgqgqo
|
||||
X
|
||||
Xa
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
X
|
||||
Xa
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set tw=2 fo=cqm comments=n:X
|
||||
gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
|
||||
X
|
||||
Xa
|
||||
XaY
|
||||
XY
|
||||
XYZ
|
||||
X Y
|
||||
X YZ
|
||||
XX
|
||||
XXa
|
||||
XXY
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
X
|
||||
Xa
|
||||
XaY
|
||||
XY
|
||||
XYZ
|
||||
X Y
|
||||
X YZ
|
||||
XX
|
||||
XXa
|
||||
XXY
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set tw=2 fo=tm
|
||||
RXa
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
STARTTEST
|
||||
/^{/+1
|
||||
:set mps+=u2018:u2019
|
||||
d%
|
||||
ENDTEST
|
||||
|
||||
{
|
||||
‘ two three ’ four
|
||||
}
|
||||
STARTTEST
|
||||
/^ra test
|
||||
jVjra
|
||||
ENDTEST
|
||||
|
||||
ra test
|
||||
abba
|
||||
aab
|
||||
|
||||
STARTTEST
|
||||
:set whichwrap+=h
|
||||
/^x
|
||||
dh
|
||||
:set whichwrap-=h
|
||||
ENDTEST
|
||||
|
||||
á
|
||||
x
|
||||
|
||||
STARTTEST
|
||||
:let a = '.é.' " one char of two bytes
|
||||
:let b = '.é.' " normal e with composing char
|
||||
/^byteidx
|
||||
:put =string([byteidx(a, 0), byteidx(a, 1), byteidx(a, 2), byteidx(a, 3), byteidx(a, 4)])
|
||||
:put =string([byteidx(b, 0), byteidx(b, 1), byteidx(b, 2), byteidx(b, 3), byteidx(b, 4)])
|
||||
/^byteidxcomp
|
||||
:put =string([byteidxcomp(a, 0), byteidxcomp(a, 1), byteidxcomp(a, 2), byteidxcomp(a, 3), byteidxcomp(a, 4)])
|
||||
:let b = '.é.'
|
||||
:put =string([byteidxcomp(b, 0), byteidxcomp(b, 1), byteidxcomp(b, 2), byteidxcomp(b, 3), byteidxcomp(b, 4), byteidxcomp(b, 5)])
|
||||
ENDTEST
|
||||
|
||||
byteidx
|
||||
byteidxcomp
|
||||
|
||||
STARTTEST
|
||||
/^substitute
|
||||
:let y = substitute('123', '\zs', 'a', 'g') | put =y
|
||||
ENDTEST
|
||||
|
||||
substitute
|
||||
|
||||
STARTTEST
|
||||
:g/^STARTTEST/.,/^ENDTEST/d
|
||||
:1;/^Results/,$wq! test.out
|
||||
ENDTEST
|
@ -1,166 +0,0 @@
|
||||
Results of test69:
|
||||
|
||||
|
||||
{
|
||||
XYZ
|
||||
abc
|
||||
XYZ
|
||||
|
||||
XYZ
|
||||
abc
|
||||
XYZ
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
X
|
||||
X
|
||||
a
|
||||
X
|
||||
a
|
||||
X
|
||||
Y
|
||||
X
|
||||
Y
|
||||
|
||||
X
|
||||
X
|
||||
a
|
||||
X
|
||||
a
|
||||
X
|
||||
Y
|
||||
X
|
||||
Y
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
X
|
||||
X
|
||||
a
|
||||
|
||||
X
|
||||
X
|
||||
a
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
X
|
||||
X
|
||||
a
|
||||
|
||||
X
|
||||
X
|
||||
a
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
X
|
||||
a
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
four
|
||||
}
|
||||
|
||||
ra test
|
||||
aaaa
|
||||
aaa
|
||||
|
||||
|
||||
áx
|
||||
|
||||
|
||||
byteidx
|
||||
[0, 1, 3, 4, -1]
|
||||
[0, 1, 4, 5, -1]
|
||||
byteidxcomp
|
||||
[0, 1, 3, 4, -1]
|
||||
[0, 1, 2, 4, 5, -1]
|
||||
|
||||
|
||||
substitute
|
||||
a1a2a3a
|
||||
|
339
test/functional/legacy/069_multi_byte_formatting_spec.lua
Normal file
339
test/functional/legacy/069_multi_byte_formatting_spec.lua
Normal file
@ -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<cr>')
|
||||
feed('XYZ<cr>')
|
||||
feed('abc XYZ<esc><esc>')
|
||||
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<cr>')
|
||||
feed('X<cr>')
|
||||
feed('Xa<cr>')
|
||||
feed('X a<cr>')
|
||||
feed('XY<cr>')
|
||||
feed('X Y<esc><esc>')
|
||||
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<cr>')
|
||||
feed('X<cr>')
|
||||
feed('Xa<cr>')
|
||||
feed('X a<cr>')
|
||||
feed('XY<cr>')
|
||||
feed('X Y<cr>')
|
||||
feed('aX<cr>')
|
||||
feed('abX<cr>')
|
||||
feed('abcX<cr>')
|
||||
feed('abX c<cr>')
|
||||
feed('abXY<esc><esc>')
|
||||
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<cr>')
|
||||
feed('X<cr>')
|
||||
feed('Xa<esc>')
|
||||
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<cr>')
|
||||
-- Literal spaces will be trimmed from the by feed().
|
||||
feed('<space><space>X<cr>')
|
||||
feed('<space><space>Xa<esc>')
|
||||
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<cr>')
|
||||
feed('X<cr>')
|
||||
feed('Xa<cr>')
|
||||
feed('XaY<cr>')
|
||||
feed('XY<cr>')
|
||||
feed('XYZ<cr>')
|
||||
feed('X Y<cr>')
|
||||
feed('X YZ<cr>')
|
||||
feed('XX<cr>')
|
||||
feed('XXa<cr>')
|
||||
feed('XXY<esc><esc>')
|
||||
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<esc>')
|
||||
expect([[
|
||||
{
|
||||
X
|
||||
a
|
||||
}]])
|
||||
end)
|
||||
|
||||
it("as values of 'mps'", function()
|
||||
insert([[
|
||||
{
|
||||
‘ two three ’ four
|
||||
}]])
|
||||
execute('/^{/+1')
|
||||
execute('set mps+=‘:’')
|
||||
feed('d%<cr>')
|
||||
expect([[
|
||||
{
|
||||
four
|
||||
}]])
|
||||
end)
|
||||
|
||||
it('can be replaced with r', function()
|
||||
insert([[
|
||||
abba
|
||||
aab]])
|
||||
feed('gg0Vjra<cr>')
|
||||
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)
|
Loading…
Reference in New Issue
Block a user