summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-11 22:55:26 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-11 22:55:26 +0100
commita703aaee4d6230ed81469ef0cb37f331bf255136 (patch)
tree85856c4ad9ff95994f036046eb9a7597289be422
parent8e6a31df81113bbf0e4bb5324a74dc5f6c62a490 (diff)
patch 8.0.1387: wordcount test is old stylev8.0.1387
Problem: Wordcount test is old style. Solution: Change into a new style test. (Yegappan Lakshmanan, closes #2434)
-rw-r--r--src/Makefile2
-rw-r--r--src/testdir/Make_all.mak4
-rw-r--r--src/testdir/Make_ming.mak2
-rw-r--r--src/testdir/Make_vms.mms8
-rw-r--r--src/testdir/test_wordcount.in126
-rw-r--r--src/testdir/test_wordcount.ok34
-rw-r--r--src/testdir/test_wordcount.vim108
-rw-r--r--src/version.c2
8 files changed, 115 insertions, 171 deletions
diff --git a/src/Makefile b/src/Makefile
index 2a66a02de4..1235752450 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2101,7 +2101,6 @@ run_message_test: $(MESSAGE_TEST_TARGET)
# 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 \
@@ -2296,6 +2295,7 @@ test_arglist \
test_window_cmd \
test_window_id \
test_windows_home \
+ test_wordcount \
test_writefile \
test_alot_latin \
test_alot_utf8 \
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 5d5fccf109..932f2c43a5 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -31,8 +31,7 @@ SCRIPTS_ALL = \
test95.out \
test99.out \
test108.out \
- test_eval.out \
- test_wordcount.out
+ test_eval.out
# Tests that run on most systems, but not on Amiga.
@@ -183,6 +182,7 @@ NEW_TESTS = test_arabic.res \
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 \
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
index a05ae322cb..d66d6678c8 100644
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -63,7 +63,7 @@ win32: fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests
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
+ dotest.in
clean:
-@if exist *.out $(DEL) *.out
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
index 7491e8d658..e8b1db3840 100644
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -81,13 +81,7 @@ SCRIPT = test1.out test3.out \
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
+ test_eval.out
# Known problems:
# test17: ?
diff --git a/src/testdir/test_wordcount.in b/src/testdir/test_wordcount.in
deleted file mode 100644
index 867277302d..0000000000
--- a/src/testdir/test_wordcount.in
+++ /dev/null
@@ -1,126 +0,0 @@
-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:
diff --git a/src/testdir/test_wordcount.ok b/src/testdir/test_wordcount.ok
deleted file mode 100644
index 4bc8a9390f..0000000000
--- a/src/testdir/test_wordcount.ok
+++ /dev/null
@@ -1,34 +0,0 @@
-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}]
diff --git a/src/testdir/test_wordcount.vim b/src/testdir/test_wordcount.vim
new file mode 100644
index 0000000000..75c4e4bffa
--- /dev/null
+++ b/src/testdir/test_wordcount.vim
@@ -0,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 <expr> <F2> 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\<F2>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$\<F2>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$\<F2>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
diff --git a/src/version.c b/src/version.c
index e96e672e7d..2f9957af8d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1387,
+/**/
1386,
/**/
1385,