To: vim_dev@googlegroups.com Subject: Patch 8.0.1387 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1387 Problem: Wordcount test is old style. Solution: Change into a new style test. (Yegappan Lakshmanan, closes #2434) Files: src/Makefile, src/testdir/Make_all.mak, src/testdir/Make_ming.mak, src/testdir/Make_vms.mms, src/testdir/test_wordcount.in, src/testdir/test_wordcount.ok, src/testdir/test_wordcount.vim *** ../vim-8.0.1386/src/Makefile 2017-12-07 22:11:01.098438694 +0100 --- src/Makefile 2017-12-11 22:48:12.407051793 +0100 *************** *** 2101,2107 **** # These do not depend on the executable, compile it when needed. test1 \ test_eval \ - test_wordcount \ test3 test11 test14 test15 test17 \ test29 test30 test36 test37 test39 \ test42 test44 test48 test49 \ --- 2105,2110 ---- *************** *** 2296,2301 **** --- 2299,2305 ---- test_window_cmd \ test_window_id \ test_windows_home \ + test_wordcount \ test_writefile \ test_alot_latin \ test_alot_utf8 \ *** ../vim-8.0.1386/src/testdir/Make_all.mak 2017-12-07 22:11:01.098438694 +0100 --- src/testdir/Make_all.mak 2017-12-11 22:41:51.881770755 +0100 *************** *** 31,38 **** test95.out \ test99.out \ test108.out \ ! test_eval.out \ ! test_wordcount.out # Tests that run on most systems, but not on Amiga. --- 31,37 ---- test95.out \ test99.out \ test108.out \ ! test_eval.out # Tests that run on most systems, but not on Amiga. *************** *** 183,188 **** --- 182,188 ---- test_winbuf_close.res \ test_window_id.res \ test_windows_home.res \ + test_wordcount.res \ test_writefile.res \ test_alot_latin.res \ test_alot_utf8.res \ *** ../vim-8.0.1386/src/testdir/Make_ming.mak 2017-11-16 21:52:07.651021800 +0100 --- src/testdir/Make_ming.mak 2017-12-11 22:41:51.881770755 +0100 *************** *** 63,69 **** fixff: -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=dos|upd" +q *.in *.ok -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=unix|upd" +q \ ! dotest.in test_wordcount.ok clean: -@if exist *.out $(DEL) *.out --- 63,69 ---- fixff: -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=dos|upd" +q *.in *.ok -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=unix|upd" +q \ ! dotest.in clean: -@if exist *.out $(DEL) *.out *** ../vim-8.0.1386/src/testdir/Make_vms.mms 2017-11-16 21:52:07.651021800 +0100 --- src/testdir/Make_vms.mms 2017-12-11 22:41:51.881770755 +0100 *************** *** 81,93 **** test64.out test69.out \ test72.out test77a.out test88.out \ test94.out test95.out test99.out test108.out \ ! test_autocmd_option.out \ ! test_breakindent.out \ ! test_eval.out \ ! test_listlbr.out \ ! test_listlbr_utf8.out \ ! test_utf8.out \ ! test_wordcount.out # Known problems: # test17: ? --- 81,87 ---- test64.out test69.out \ test72.out test77a.out test88.out \ test94.out test95.out test99.out test108.out \ ! test_eval.out # Known problems: # test17: ? *** ../vim-8.0.1386/src/testdir/test_wordcount.in 2016-01-04 12:33:29.000000000 +0100 --- src/testdir/test_wordcount.in 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,126 **** - Test for wordcount() function - - STARTTEST - :so small.vim - :so mbyte.vim - :set enc=utf8 - :set selection=inclusive fileformat=unix fileformats=unix - :new - :fu DoRecordWin(...) - : wincmd k - : if exists("a:1") - : call cursor(a:1) - : endif - : let result=[] - : call add(result, g:test) - : call add(result, getline(1, '$')) - : call add(result, wordcount()) - : wincmd j - : return result - :endfu - :fu PutInWindow(args) - : wincmd k - : %d _ - : call append(1, a:args) - : wincmd j - :endfu - :fu Log() - : $put ='----' - : $put =remove(g:log,0) - : $put =string(g:log) - :endfu - :fu! STL() - : if mode() =~? 'V' - : let g:visual_stat=wordcount() - : endif - : return string(wordcount()) - :endfu - :let g:test="Test 1: empty window" - :let log=DoRecordWin() - :call Log() - :" - :let g:test="Test 2: some words, cursor at start" - :call PutInWindow('one two three') - :let log=DoRecordWin([1,1,0]) - :call Log() - :" - :let g:test="Test 3: some words, cursor at end" - :call PutInWindow('one two three') - :let log=DoRecordWin([2,99,0]) - :call Log() - :" - :let g:test="Test 4: some words, cursor at end, ve=all" - :set ve=all - :call PutInWindow('one two three') - :let log=DoRecordWin([2,99,0]) - :call Log() - :set ve= - :" - :let g:test="Test 5: several lines with words" - :call PutInWindow(['one two three', 'one two three', 'one two three']) - :let log=DoRecordWin([4,99,0]) - :call Log() - :" - :let g:test="Test 6: one line with BOM set" - :call PutInWindow('one two three') - :wincmd k - :set bomb - :w! Xtest - :wincmd j - :let log=DoRecordWin([2,99,0]) - :call Log() - :wincmd k - :set nobomb - :w! - :wincmd j - :" - :let g:test="Test 7: one line with multibyte words" - :call PutInWindow(['Äne M¤ne Müh']) - :let log=DoRecordWin([2,99,0]) - :call Log() - :" - :let g:test="Test 8: several lines with multibyte words" - :call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!']) - :let log=DoRecordWin([3,99,0]) - :call Log() - :" - :let g:test="Test 9: visual mode, complete buffer" - :call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!']) - :wincmd k - :set ls=2 stl=%{STL()} - :" start visual mode quickly and select complete buffer - :0 - V2jy - :set stl= ls=1 - :let log=DoRecordWin([3,99,0]) - :let log[2]=g:visual_stat - :call Log() - :" - :let g:test="Test 10: visual mode (empty)" - :call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!']) - :wincmd k - :set ls=2 stl=%{STL()} - :" start visual mode quickly and select complete buffer - :0 - v$y - :set stl= ls=1 - :let log=DoRecordWin([3,99,0]) - :let log[2]=g:visual_stat - :call Log() - :" - :let g:test="Test 11: visual mode, single line" - :call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!']) - :wincmd k - :set ls=2 stl=%{STL()} - :" start visual mode quickly and select complete buffer - :2 - 0v$y - :set stl= ls=1 - :let log=DoRecordWin([3,99,0]) - :let log[2]=g:visual_stat - :call Log() - :" - :/^RESULT test/,$w! test.out - :qa! - ENDTEST - RESULT test: --- 0 ---- *** ../vim-8.0.1386/src/testdir/test_wordcount.ok 2016-01-03 22:42:07.000000000 +0100 --- src/testdir/test_wordcount.ok 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,34 **** - RESULT test: - ---- - Test 1: empty window - [[''], {'chars': 0, 'cursor_chars': 0, 'words': 0, 'cursor_words': 0, 'bytes': 0, 'cursor_bytes': 0}] - ---- - Test 2: some words, cursor at start - [['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}] - ---- - Test 3: some words, cursor at end - [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}] - ---- - Test 4: some words, cursor at end, ve=all - [['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}] - ---- - Test 5: several lines with words - [['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}] - ---- - Test 6: one line with BOM set - [['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}] - ---- - Test 7: one line with multibyte words - [['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}] - ---- - Test 8: several lines with multibyte words - [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}] - ---- - Test 9: visual mode, complete buffer - [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}] - ---- - Test 10: visual mode (empty) - [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}] - ---- - Test 11: visual mode, single line - [['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}] --- 0 ---- *** ../vim-8.0.1386/src/testdir/test_wordcount.vim 2017-12-11 22:54:42.308425201 +0100 --- src/testdir/test_wordcount.vim 2017-12-11 22:41:51.881770755 +0100 *************** *** 0 **** --- 1,108 ---- + " Test for wordcount() function + + if !has('multi_byte') + finish + endif + + func Test_wordcount() + let save_enc = &enc + set encoding=utf-8 + set selection=inclusive fileformat=unix fileformats=unix + + new + + " Test 1: empty window + call assert_equal({'chars': 0, 'cursor_chars': 0, 'words': 0, 'cursor_words': 0, + \ 'bytes': 0, 'cursor_bytes': 0}, wordcount()) + + " Test 2: some words, cursor at start + call append(1, 'one two three') + call cursor([1, 1, 0]) + call assert_equal({'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, + \ 'bytes': 15, 'cursor_bytes': 1}, wordcount()) + + " Test 3: some words, cursor at end + %d _ + call append(1, 'one two three') + call cursor([2, 99, 0]) + call assert_equal({'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, + \ 'bytes': 15, 'cursor_bytes': 14}, wordcount()) + + " Test 4: some words, cursor at end, ve=all + set ve=all + %d _ + call append(1, 'one two three') + call cursor([2, 99, 0]) + call assert_equal({'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, + \ 'bytes': 15, 'cursor_bytes': 15}, wordcount()) + set ve= + + " Test 5: several lines with words + %d _ + call append(1, ['one two three', 'one two three', 'one two three']) + call cursor([4, 99, 0]) + call assert_equal({'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, + \ 'bytes': 43, 'cursor_bytes': 42}, wordcount()) + + " Test 6: one line with BOM set + %d _ + call append(1, 'one two three') + set bomb + w! Xtest + call cursor([2, 99, 0]) + call assert_equal({'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, + \ 'bytes': 18, 'cursor_bytes': 14}, wordcount()) + set nobomb + w! + call delete('Xtest') + + " Test 7: one line with multibyte words + %d _ + call append(1, ['Äne M¤ne Müh']) + call cursor([2, 99, 0]) + call assert_equal({'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, + \ 'bytes': 17, 'cursor_bytes': 16}, wordcount()) + + " Test 8: several lines with multibyte words + %d _ + call append(1, ['Äne M¤ne Müh', 'und raus bist dü!']) + call cursor([3, 99, 0]) + call assert_equal({'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, + \ 'bytes': 36, 'cursor_bytes': 35}, wordcount()) + + " Visual map to capture wordcount() in visual mode + vnoremap execute("let g:visual_stat = wordcount()") + + " Test 9: visual mode, complete buffer + let g:visual_stat = {} + %d _ + call append(1, ['Äne M¤ne Müh', 'und raus bist dü!']) + " start visual mode and select the complete buffer + 0 + exe "normal V2j\y" + call assert_equal({'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, + \ 'visual_words': 7, 'visual_bytes': 36}, g:visual_stat) + + " Test 10: visual mode (empty) + %d _ + call append(1, ['Äne M¤ne Müh', 'und raus bist dü!']) + " start visual mode and select the complete buffer + 0 + exe "normal v$\y" + call assert_equal({'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, + \ 'visual_words': 0, 'visual_bytes': 1}, g:visual_stat) + + " Test 11: visual mode, single line + %d _ + call append(1, ['Äne M¤ne Müh', 'und raus bist dü!']) + " start visual mode and select the complete buffer + 2 + exe "normal 0v$\y" + call assert_equal({'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, + \ 'visual_words': 3, 'visual_bytes': 16}, g:visual_stat) + + set selection& fileformat& fileformats& + let &enc = save_enc + enew! + close + endfunc *** ../vim-8.0.1386/src/version.c 2017-12-10 21:06:17.739851817 +0100 --- src/version.c 2017-12-11 22:42:26.021569976 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1387, /**/ -- The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///