1
0
forked from aniani/vim

patch 8.2.0014: test69 and test95 are old style

Problem:    Test69 and test95 are old style.
Solution:   Convert to new style tests. (Yegappan Lakshmanan, closes #5365)
This commit is contained in:
Bram Moolenaar
2019-12-16 22:43:31 +01:00
parent ddef129160
commit afc13bd827
10 changed files with 568 additions and 622 deletions

View File

@@ -509,3 +509,426 @@ func Test_crash_github_issue_5095()
augroup END
augroup! testing
endfunc
" Test for formatting multi-byte text with 'fo=t'
func Test_tw_2_fo_t()
new
let t =<< trim END
{
abc
}
END
call setline(1, t)
call cursor(2, 1)
set tw=2 fo=t
let t =<< trim END
abc
END
exe "normal gqgqjgqgq"
exe "normal o\n" . join(t, "\n")
let expected =<< trim END
{
abc
abc
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo&
bwipe!
endfunc
" Test for formatting multi-byte text with 'fo=tm' and 'tw=1'
func Test_tw_1_fo_tm()
new
let t =<< trim END
{
a
a
}
END
call setline(1, t)
call cursor(2, 1)
set tw=1 fo=tm
let t =<< trim END
a
a
END
exe "normal gqgqjgqgqjgqgqjgqgqjgqgq"
exe "normal o\n" . join(t, "\n")
let expected =<< trim END
{
a
a
a
a
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo&
bwipe!
endfunc
" Test for formatting multi-byte text with 'fo=tm' and 'tw=2'
func Test_tw_2_fo_tm()
new
let t =<< trim END
{
a
a
a
ab
abc
ab c
ab
}
END
call setline(1, t)
call cursor(2, 1)
set tw=2 fo=tm
let t =<< trim END
a
a
a
ab
abc
ab c
ab
END
exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
exe "normal o\n" . join(t, "\n")
let expected =<< trim END
{
a
a
a
ab
abc
ab
c
ab
a
a
a
ab
abc
ab
c
ab
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo&
bwipe!
endfunc
" Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'autoindent'.
func Test_tw_2_fo_tm_ai()
new
let t =<< trim END
{
a
}
END
call setline(1, t)
call cursor(2, 1)
set ai tw=2 fo=tm
let t =<< trim END
a
END
exe "normal gqgqjgqgq"
exe "normal o\n" . join(t, "\n")
let expected =<< trim END
{
a
a
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo& ai&
bwipe!
endfunc
" Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'noai'.
func Test_tw_2_fo_tm_noai()
new
let t =<< trim END
{
a
}
END
call setline(1, t)
call cursor(2, 1)
set noai tw=2 fo=tm
exe "normal gqgqjgqgqo\n \n a"
let expected =<< trim END
{
a
a
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo& ai&
bwipe!
endfunc
func Test_tw_2_fo_cqm_com()
new
let t =<< trim END
{
a
a
a
}
END
call setline(1, t)
call cursor(2, 1)
set tw=2 fo=cqm comments=n:
exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
let t =<< trim END
a
a
a
END
exe "normal o\n" . join(t, "\n")
let expected =<< trim END
{
a
a
a
a
a
a
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo& comments&
bwipe!
endfunc
func Test_tw_2_fo_tm_replace()
new
let t =<< trim END
{
}
END
call setline(1, t)
call cursor(2, 1)
set tw=2 fo=tm
exe "normal Ra"
let expected =<< trim END
{
a
}
END
call assert_equal(expected, getline(1, '$'))
set tw& fo&
bwipe!
endfunc
" Test for 'matchpairs' with multibyte chars
func Test_mps()
new
let t =<< trim END
{
two three four
}
END
call setline(1, t)
call cursor(2, 1)
exe "set mps+=\u2018:\u2019"
normal d%
let expected =<< trim END
{
four
}
END
call assert_equal(expected, getline(1, '$'))
set mps&
bwipe!
endfunc
" Test for ra on multi-byte characters
func Test_ra_multibyte()
new
let t =<< trim END
ra test
bb
b
END
call setline(1, t)
call cursor(1, 1)
normal jVjra
let expected =<< trim END
ra test
aaaa
aaa
END
call assert_equal(expected, getline(1, '$'))
bwipe!
endfunc
" Test for 'whichwrap' with multi-byte character
func Test_whichwrap()
new
let t =<< trim END
á
x
END
call setline(1, t)
call cursor(2, 1)
set whichwrap+=h
normal dh
set whichwrap-=h
let expected =<< trim END
áx
END
call assert_equal(expected, getline(1, '$'))
bwipe!
endfunc
func Test_substitute()
call assert_equal('aaaa', substitute('', '\zs', 'a', 'g'))
endfunc
" vim: shiftwidth=2 sts=2 expandtab