Mercurial > vim
diff src/testdir/test_textformat.vim @ 18906:bb87c5c1e29b v8.2.0014
patch 8.2.0014: test69 and test95 are old style
Commit: https://github.com/vim/vim/commit/afc13bd8271819c7871ff2ae2cfebb22190a0d39
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 16 22:43:31 2019 +0100
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 https://github.com/vim/vim/issues/5365)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Dec 2019 22:45:04 +0100 |
parents | 50c0a9fb07ae |
children | e8fe65da4198 |
line wrap: on
line diff
--- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -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 + { + XYZ + abc XYZ + } + END + call setline(1, t) + call cursor(2, 1) + + set tw=2 fo=t + let t =<< trim END + XYZ + abc XYZ + END + exe "normal gqgqjgqgq" + exe "normal o\n" . join(t, "\n") + + let expected =<< trim END + { + XYZ + abc + XYZ + + XYZ + abc + XYZ + } + 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 + { + X + Xa + X a + XY + X Y + } + END + call setline(1, t) + call cursor(2, 1) + + set tw=1 fo=tm + let t =<< trim END + X + Xa + X a + XY + X Y + END + exe "normal gqgqjgqgqjgqgqjgqgqjgqgq" + exe "normal o\n" . join(t, "\n") + + let expected =<< trim END + { + X + X + a + X + a + X + Y + X + Y + + X + X + a + X + a + X + Y + X + Y + } + 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 + { + X + Xa + X a + XY + X Y + aX + abX + abcX + abX c + abXY + } + END + call setline(1, t) + call cursor(2, 1) + + set tw=2 fo=tm + let t =<< trim END + X + Xa + X a + XY + X Y + aX + abX + abcX + abX c + abXY + END + exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq" + exe "normal o\n" . join(t, "\n") + + let expected =<< trim END + { + 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 + 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 + { + X + Xa + } + END + call setline(1, t) + call cursor(2, 1) + + set ai tw=2 fo=tm + let t =<< trim END + X + Xa + END + exe "normal gqgqjgqgq" + exe "normal o\n" . join(t, "\n") + + let expected =<< trim END + { + X + X + a + + X + X + 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 + { + X + Xa + } + END + call setline(1, t) + call cursor(2, 1) + + set noai tw=2 fo=tm + exe "normal gqgqjgqgqo\n X\n Xa" + + let expected =<< trim END + { + X + X + a + + X + X + 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 + { + X + Xa + XaY + XY + XYZ + X Y + X YZ + XX + XXa + XXY + } + END + call setline(1, t) + call cursor(2, 1) + + set tw=2 fo=cqm comments=n:X + exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq" + let t =<< trim END + X + Xa + XaY + XY + XYZ + X Y + X YZ + XX + XXa + XXY + END + exe "normal o\n" . join(t, "\n") + + let expected =<< trim END + { + 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 + 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 RXa" + + let expected =<< trim END + { + X + 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 + abba + aab + 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('a1a2a3a', substitute('123', '\zs', 'a', 'g')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab