aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/wordcount_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/wordcount_spec.lua')
-rw-r--r--test/functional/legacy/wordcount_spec.lua85
1 files changed, 44 insertions, 41 deletions
diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua
index 171ec3de92..5412903866 100644
--- a/test/functional/legacy/wordcount_spec.lua
+++ b/test/functional/legacy/wordcount_spec.lua
@@ -2,8 +2,9 @@
local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute = helpers.clear, helpers.execute
+local clear, command = helpers.clear, helpers.command
local eq, eval = helpers.eq, helpers.eval
+local wait = helpers.wait
if helpers.pending_win32(pending) then return end
@@ -11,14 +12,13 @@ describe('wordcount', function()
before_each(clear)
it('is working', function()
- execute('set selection=inclusive')
- execute('fileformat=unix')
- execute('fileformats=unix')
+ command('set selection=inclusive fileformat=unix fileformats=unix')
insert([=[
RESULT test:]=])
+ wait()
- execute('new')
+ command('new')
source([=[
function DoRecordWin(...)
wincmd k
@@ -59,7 +59,7 @@ describe('wordcount', function()
)
-- Test 2: some words, cursor at start
- execute([[call PutInWindow('one two three')]])
+ command([[call PutInWindow('one two three')]])
eq(eval('DoRecordWin([1, 1, 0])'),
eval([=[
[['', 'one two three'], {'chars': 15, 'cursor_chars': 1, 'words': 3, 'cursor_words': 0, 'bytes': 15, 'cursor_bytes': 1}]
@@ -67,7 +67,7 @@ describe('wordcount', function()
)
-- Test 3: some words, cursor at end
- execute([[call PutInWindow('one two three')]])
+ command([[call PutInWindow('one two three')]])
eq(eval('DoRecordWin([2, 99, 0])'),
eval([=[
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 14}]
@@ -75,17 +75,17 @@ describe('wordcount', function()
)
-- Test 4: some words, cursor at end, ve=all
- execute('set ve=all')
- execute([[call PutInWindow('one two three')]])
+ command('set ve=all')
+ command([[call PutInWindow('one two three')]])
eq(eval('DoRecordWin([2,99,0])'),
eval([=[
[['', 'one two three'], {'chars': 15, 'cursor_chars': 15, 'words': 3, 'cursor_words': 3, 'bytes': 15, 'cursor_bytes': 15}]
]=])
)
- execute('set ve=')
+ command('set ve=')
-- Test 5: several lines with words
- execute([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=])
+ command([=[call PutInWindow(['one two three', 'one two three', 'one two three'])]=])
eq(eval('DoRecordWin([4,99,0])'),
eval([=[
[['', 'one two three', 'one two three', 'one two three'], {'chars': 43, 'cursor_chars': 42, 'words': 9, 'cursor_words': 9, 'bytes': 43, 'cursor_bytes': 42}]
@@ -93,21 +93,21 @@ describe('wordcount', function()
)
-- Test 6: one line with BOM set
- execute([[call PutInWindow('one two three')]])
- execute('wincmd k')
- execute('set bomb')
- execute('wincmd j')
+ command([[call PutInWindow('one two three')]])
+ command('wincmd k')
+ command('set bomb')
+ command('wincmd j')
eq(eval('DoRecordWin([2,99,0])'),
eval([=[
[['', 'one two three'], {'chars': 15, 'cursor_chars': 14, 'words': 3, 'cursor_words': 3, 'bytes': 18, 'cursor_bytes': 14}]
]=])
)
- execute('wincmd k')
- execute('set nobomb')
- execute('wincmd j')
+ command('wincmd k')
+ command('set nobomb')
+ command('wincmd j')
-- Test 7: one line with multibyte words
- execute([=[call PutInWindow(['Äne M¤ne Müh'])]=])
+ command([=[call PutInWindow(['Äne M¤ne Müh'])]=])
eq(eval('DoRecordWin([2,99,0])'),
eval([=[
[['', 'Äne M¤ne Müh'], {'chars': 14, 'cursor_chars': 13, 'words': 3, 'cursor_words': 3, 'bytes': 17, 'cursor_bytes': 16}]
@@ -115,7 +115,7 @@ describe('wordcount', function()
)
-- Test 8: several lines with multibyte words
- execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
eq(eval('DoRecordWin([3,99,0])'),
eval([=[
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'cursor_chars': 31, 'words': 7, 'cursor_words': 7, 'bytes': 36, 'cursor_bytes': 35}]
@@ -123,15 +123,16 @@ describe('wordcount', function()
)
-- Test 9: visual mode, complete buffer
- execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
- execute('wincmd k')
- execute('set ls=2 stl=%{STL()}')
+ command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ command('wincmd k')
+ command('set ls=2 stl=%{STL()}')
-- -- Start visual mode quickly and select complete buffer.
- execute('0')
+ command('0')
feed('V2jy<cr>')
- execute('set stl= ls=1')
- execute('let log=DoRecordWin([3,99,0])')
- execute('let log[1]=g:visual_stat')
+ wait()
+ command('set stl= ls=1')
+ command('let log=DoRecordWin([3,99,0])')
+ command('let log[1]=g:visual_stat')
eq(eval('log'),
eval([=[
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 32, 'visual_words': 7, 'visual_bytes': 36}]
@@ -139,15 +140,16 @@ describe('wordcount', function()
)
-- Test 10: visual mode (empty)
- execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
- execute('wincmd k')
- execute('set ls=2 stl=%{STL()}')
+ command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ command('wincmd k')
+ command('set ls=2 stl=%{STL()}')
-- Start visual mode quickly and select complete buffer.
- execute('0')
+ command('0')
feed('v$y<cr>')
- execute('set stl= ls=1')
- execute('let log=DoRecordWin([3,99,0])')
- execute('let log[1]=g:visual_stat')
+ wait()
+ command('set stl= ls=1')
+ command('let log=DoRecordWin([3,99,0])')
+ command('let log[1]=g:visual_stat')
eq(eval('log'),
eval([=[
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 1, 'visual_words': 0, 'visual_bytes': 1}]
@@ -155,15 +157,16 @@ describe('wordcount', function()
)
-- Test 11: visual mode, single line
- execute([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
- execute('wincmd k')
- execute('set ls=2 stl=%{STL()}')
+ command([=[call PutInWindow(['Äne M¤ne Müh', 'und raus bist dü!'])]=])
+ command('wincmd k')
+ command('set ls=2 stl=%{STL()}')
-- Start visual mode quickly and select complete buffer.
- execute('2')
+ command('2')
feed('0v$y<cr>')
- execute('set stl= ls=1')
- execute('let log=DoRecordWin([3,99,0])')
- execute('let log[1]=g:visual_stat')
+ wait()
+ command('set stl= ls=1')
+ command('let log=DoRecordWin([3,99,0])')
+ command('let log[1]=g:visual_stat')
eq(eval('log'),
eval([=[
[['', 'Äne M¤ne Müh', 'und raus bist dü!'], {'chars': 32, 'words': 7, 'bytes': 36, 'visual_chars': 13, 'visual_words': 3, 'visual_bytes': 16}]