diff options
author | ZyX <kp-pav@yandex.ru> | 2017-04-09 00:12:26 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-04-09 03:24:08 +0300 |
commit | 65fb622000af8e3dbb65480e1581758ecf4ba3e2 (patch) | |
tree | 7d83429d3762b1f0a44d04eb8fc780eedc0ec049 /test/functional/legacy/wordcount_spec.lua | |
parent | 9158cc171f46ebae0a0d3d1721aa5b7d829bcba5 (diff) | |
download | rneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.tar.gz rneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.tar.bz2 rneovim-65fb622000af8e3dbb65480e1581758ecf4ba3e2.zip |
functests: Replace execute with either command or feed_command
Hope this will make people using feed_command less likely: this hides bugs.
Already found at least two:
1. msgpackparse() will show internal error: hash_add() in case of duplicate
keys, though it will still work correctly. Currently silenced.
2. ttimeoutlen was spelled incorrectly, resulting in option not being set when
expected. Test was still functioning somehow though. Currently fixed.
Diffstat (limited to 'test/functional/legacy/wordcount_spec.lua')
-rw-r--r-- | test/functional/legacy/wordcount_spec.lua | 87 |
1 files changed, 46 insertions, 41 deletions
diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua index 171ec3de92..192298284f 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,15 @@ describe('wordcount', function() before_each(clear) it('is working', function() - execute('set selection=inclusive') - execute('fileformat=unix') - execute('fileformats=unix') + command('set selection=inclusive') + command('fileformat=unix') + command('fileformats=unix') insert([=[ RESULT test:]=]) + wait() - execute('new') + command('new') source([=[ function DoRecordWin(...) wincmd k @@ -59,7 +61,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 +69,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 +77,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 +95,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 +117,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 +125,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 +142,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 +159,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}] |