Mercurial > vim
comparison src/testdir/test_textformat.vim @ 19906:031184ace7c5 v8.2.0509
patch 8.2.0509: various code is not properly tested.
Commit: https://github.com/vim/vim/commit/cde0ff39da2459b16007fef701ebaa449fb6fe9d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 4 14:00:39 2020 +0200
patch 8.2.0509: various code is not properly tested.
Problem: various code is not properly tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5871)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 04 Apr 2020 14:15:05 +0200 |
parents | 12518b40c161 |
children | a4bd28e2cf1d |
comparison
equal
deleted
inserted
replaced
19905:a1a00030eedc | 19906:031184ace7c5 |
---|---|
1024 END | 1024 END |
1025 call assert_equal(expected, getline(1, '$')) | 1025 call assert_equal(expected, getline(1, '$')) |
1026 %bw! | 1026 %bw! |
1027 endfunc | 1027 endfunc |
1028 | 1028 |
1029 " Test for a space character in 'comments' setting | |
1030 func Test_comment_space() | |
1031 new | |
1032 setlocal comments=b:\ > fo+=ro | |
1033 exe "normal i> B\nD\<C-C>ggOA\<C-C>joC" | |
1034 exe "normal Go > F\nH\<C-C>kOE\<C-C>joG" | |
1035 let expected =<< trim END | |
1036 A | |
1037 > B | |
1038 C | |
1039 D | |
1040 > E | |
1041 > F | |
1042 > G | |
1043 > H | |
1044 END | |
1045 call assert_equal(expected, getline(1, '$')) | |
1046 %bw! | |
1047 endfunc | |
1048 | |
1049 " Test for the 'O' flag in 'comments' | |
1050 func Test_comment_O() | |
1051 new | |
1052 setlocal comments=Ob:* fo+=ro | |
1053 exe "normal i* B\nD\<C-C>kOA\<C-C>joC" | |
1054 let expected =<< trim END | |
1055 A | |
1056 * B | |
1057 * C | |
1058 * D | |
1059 END | |
1060 call assert_equal(expected, getline(1, '$')) | |
1061 %bw! | |
1062 endfunc | |
1063 | |
1029 " Test for 'a' and 'w' flags in 'formatoptions' | 1064 " Test for 'a' and 'w' flags in 'formatoptions' |
1030 func Test_fo_a_w() | 1065 func Test_fo_a_w() |
1031 new | 1066 new |
1032 setlocal fo+=aw tw=10 | 1067 setlocal fo+=aw tw=10 |
1033 call feedkeys("iabc abc a abc\<Esc>k0weade", 'xt') | 1068 call feedkeys("iabc abc a abc\<Esc>k0weade", 'xt') |
1034 call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) | 1069 call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) |
1035 %bw! | 1070 %bw! |
1036 endfunc | 1071 endfunc |
1037 | 1072 |
1073 " Test for 'j' flag in 'formatoptions' | |
1074 func Test_fo_j() | |
1075 new | |
1076 setlocal fo+=j comments=:// | |
1077 call setline(1, ['i++; // comment1', ' // comment2']) | |
1078 normal J | |
1079 call assert_equal('i++; // comment1 comment2', getline(1)) | |
1080 setlocal fo-=j | |
1081 call setline(1, ['i++; // comment1', ' // comment2']) | |
1082 normal J | |
1083 call assert_equal('i++; // comment1 // comment2', getline(1)) | |
1084 " Test with nested comments | |
1085 setlocal fo+=j comments=n:>,n:) | |
1086 call setline(1, ['i++; > ) > ) comment1', ' > ) comment2']) | |
1087 normal J | |
1088 call assert_equal('i++; > ) > ) comment1 comment2', getline(1)) | |
1089 %bw! | |
1090 endfunc | |
1091 | |
1038 " vim: shiftwidth=2 sts=2 expandtab | 1092 " vim: shiftwidth=2 sts=2 expandtab |