Mercurial > vim
comparison src/testdir/test_textformat.vim @ 19852:12518b40c161 v8.2.0482
patch 8.2.0482: channel and sandbox code not sufficiently tested
Commit: https://github.com/vim/vim/commit/ca68ae13114619df3e4c195b41ad0575516f5ff6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 30 19:32:53 2020 +0200
patch 8.2.0482: channel and sandbox code not sufficiently tested
Problem: Channel and sandbox code not sufficiently tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5855)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 30 Mar 2020 19:45:05 +0200 |
parents | 1b02482e6a61 |
children | 031184ace7c5 |
comparison
equal
deleted
inserted
replaced
19851:e259e7903c55 | 19852:12518b40c161 |
---|---|
949 call assert_equal(expected, getline(1, '$')) | 949 call assert_equal(expected, getline(1, '$')) |
950 | 950 |
951 bwipe! | 951 bwipe! |
952 endfunc | 952 endfunc |
953 | 953 |
954 func Test_substitute() | 954 " Test for the 'f' flag in 'comments' (only the first line has the comment |
955 call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) | 955 " string) |
956 func Test_firstline_comment() | |
957 new | |
958 setlocal comments=f:- fo+=ro | |
959 exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>" | |
960 call assert_equal(['A', '- B', ' C', ' D'], getline(1, '$')) | |
961 %d | |
962 setlocal comments=:- | |
963 exe "normal i- B\nD\<C-C>ggoC\<C-C>ggOA\<C-C>" | |
964 call assert_equal(['- A', '- B', '- C', '- D'], getline(1, '$')) | |
965 %bw! | |
966 endfunc | |
967 | |
968 " Test for the 'r' flag in 'comments' (right align comment) | |
969 func Test_comment_rightalign() | |
970 new | |
971 setlocal comments=sr:/***,m:**,ex-2:******/ fo+=ro | |
972 exe "normal i=\<C-C>o\t /***\nD\n/" | |
973 exe "normal 2GOA\<C-C>joB\<C-C>jOC\<C-C>joE\<C-C>GOF\<C-C>joG" | |
974 let expected =<< trim END | |
975 = | |
976 A | |
977 /*** | |
978 ** B | |
979 ** C | |
980 ** D | |
981 ** E | |
982 ** F | |
983 ******/ | |
984 G | |
985 END | |
986 call assert_equal(expected, getline(1, '$')) | |
987 %bw! | |
988 endfunc | |
989 | |
990 " Test for the 'b' flag in 'comments' | |
991 func Test_comment_blank() | |
992 new | |
993 setlocal comments=b:* fo+=ro | |
994 exe "normal i* E\nF\n\<BS>G\nH\<C-C>ggOC\<C-C>O\<BS>B\<C-C>OA\<C-C>2joD" | |
995 let expected =<< trim END | |
996 A | |
997 *B | |
998 * C | |
999 * D | |
1000 * E | |
1001 * F | |
1002 *G | |
1003 H | |
1004 END | |
1005 call assert_equal(expected, getline(1, '$')) | |
1006 %bw! | |
1007 endfunc | |
1008 | |
1009 " Test for the 'n' flag in comments | |
1010 func Test_comment_nested() | |
1011 new | |
1012 setlocal comments=n:> fo+=ro | |
1013 exe "normal i> B\nD\<C-C>ggOA\<C-C>joC\<C-C>Go\<BS>>>> F\nH" | |
1014 exe "normal 5GOE\<C-C>6GoG" | |
1015 let expected =<< trim END | |
1016 > A | |
1017 > B | |
1018 > C | |
1019 > D | |
1020 >>>> E | |
1021 >>>> F | |
1022 >>>> G | |
1023 >>>> H | |
1024 END | |
1025 call assert_equal(expected, getline(1, '$')) | |
1026 %bw! | |
1027 endfunc | |
1028 | |
1029 " Test for 'a' and 'w' flags in 'formatoptions' | |
1030 func Test_fo_a_w() | |
1031 new | |
1032 setlocal fo+=aw tw=10 | |
1033 call feedkeys("iabc abc a abc\<Esc>k0weade", 'xt') | |
1034 call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) | |
1035 %bw! | |
956 endfunc | 1036 endfunc |
957 | 1037 |
958 " vim: shiftwidth=2 sts=2 expandtab | 1038 " vim: shiftwidth=2 sts=2 expandtab |