diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/039_visual_block_mode_commands_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/045_folding_spec.lua | 139 | ||||
-rw-r--r-- | test/functional/legacy/eval_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/glob2regpat_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/quickfix_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/legacy/textobjects_spec.lua | 61 | ||||
-rw-r--r-- | test/functional/legacy/utf8_spec.lua | 23 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 9 | ||||
-rw-r--r-- | test/unit/strings_spec.lua | 1 |
10 files changed, 228 insertions, 16 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 16a4423535..c0099e44c4 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -43,7 +43,7 @@ describe('server -> client', function() stop() end - local function on_request(method, args) + local function on_request() -- No need to evaluate the args, we are only interested in -- a response that contains an array with an empty string. return {1, 2, '', 3, 'asdf'} diff --git a/test/functional/legacy/039_visual_block_mode_commands_spec.lua b/test/functional/legacy/039_visual_block_mode_commands_spec.lua index 55db9169fa..6e1879035b 100644 --- a/test/functional/legacy/039_visual_block_mode_commands_spec.lua +++ b/test/functional/legacy/039_visual_block_mode_commands_spec.lua @@ -5,7 +5,7 @@ local helpers = require('test.functional.helpers') local nvim, eq = helpers.meths, helpers.eq local insert, feed = helpers.insert, helpers.feed local clear, expect = helpers.clear, helpers.expect -local source, execute = helpers.source, helpers.execute +local execute = helpers.execute describe('Visual block mode', function() diff --git a/test/functional/legacy/045_folding_spec.lua b/test/functional/legacy/045_folding_spec.lua new file mode 100644 index 0000000000..04b623ff3b --- /dev/null +++ b/test/functional/legacy/045_folding_spec.lua @@ -0,0 +1,139 @@ +-- Tests for folding. + +local helpers = require('test.functional.helpers') +local feed, insert, clear, execute, expect = + helpers.feed, helpers.insert, helpers.clear, helpers.execute, helpers.expect + +describe('folding', function() + before_each(clear) + + it('is working', function() + insert([[ + 1 aa + 2 bb + 3 cc + 4 dd {{{ + 5 ee {{{ }}} + 6 ff }}} + 7 gg + 8 hh + 9 ii + a jj + b kk + last]]) + + -- Basic test if a fold can be created, opened, moving to the end and + -- closed. + execute('/^1') + feed('zf2j') + execute('call append("$", "manual " . getline(foldclosed(".")))') + feed('zo') + execute('call append("$", foldclosed("."))') + feed(']z') + execute('call append("$", getline("."))') + feed('zc') + execute('call append("$", getline(foldclosed(".")))') + -- Test folding with markers. + execute('set fdm=marker fdl=1 fdc=3') + execute('/^5') + execute('call append("$", "marker " . foldlevel("."))') + feed('[z') + execute('call append("$", foldlevel("."))') + feed('jo{{ <esc>r{jj') + execute('call append("$", foldlevel("."))') + feed('kYpj') + execute('call append("$", foldlevel("."))') + -- Test folding with indent. + execute('set fdm=indent sw=2') + execute('/^2 b') + feed('i <esc>jI <esc>') + execute('call append("$", "indent " . foldlevel("."))') + feed('k') + execute('call append("$", foldlevel("."))') + -- Test syntax folding. + execute('set fdm=syntax fdl=0') + execute('syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3') + execute('syn region Fd1 start="ee" end="ff" fold contained') + execute('syn region Fd2 start="gg" end="hh" fold contained') + execute('syn region Fd3 start="commentstart" end="commentend" fold contained') + feed('Gzk') + execute('call append("$", "folding " . getline("."))') + feed('k') + execute('call append("$", getline("."))') + feed('jAcommentstart <esc>Acommentend<esc>') + execute('set fdl=1') + feed('3j') + execute('call append("$", getline("."))') + execute('set fdl=0') + feed('zO<C-L>j') + execute('call append("$", getline("."))') + -- Test expression folding. + execute('fun Flvl()') + execute(' let l = getline(v:lnum)') + execute(' if l =~ "bb$"') + execute(' return 2') + execute(' elseif l =~ "gg$"') + execute(' return "s1"') + execute(' elseif l =~ "ii$"') + execute(' return ">2"') + execute(' elseif l =~ "kk$"') + execute(' return "0"') + execute(' endif') + execute(' return "="') + execute('endfun') + execute('set fdm=expr fde=Flvl()') + execute('/bb$') + execute('call append("$", "expr " . foldlevel("."))') + execute('/hh$') + execute('call append("$", foldlevel("."))') + execute('/ii$') + execute('call append("$", foldlevel("."))') + execute('/kk$') + execute('call append("$", foldlevel("."))') + execute('0,/^last/delete') + execute('delfun Flvl') + + -- Assert buffer contents. + expect([[ + manual 1 aa + -1 + 3 cc + 1 aa + marker 2 + 1 + 1 + 0 + indent 2 + 1 + folding 9 ii + 3 cc + 7 gg + 8 hh + expr 2 + 1 + 2 + 0]]) + end) + + it('can open after :move', function() + insert([[ + Test fdm=indent and :move bug END + line2 + Test fdm=indent START + line3 + line4]]) + + execute('set noai nosta') + execute('set fdm=indent') + execute('1m1') + feed('2jzc') + execute('m0') + + expect([[ + Test fdm=indent START + line3 + line4 + Test fdm=indent and :move bug END + line2]]) + end) +end) diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua index 05cd73dbd4..1c81b47ed6 100644 --- a/test/functional/legacy/eval_spec.lua +++ b/test/functional/legacy/eval_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers') local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect -local eq, eval, wait, write_file = helpers.eq, helpers.eval, helpers.wait, helpers.write_file +local eq, eval, write_file = helpers.eq, helpers.eval, helpers.write_file local function has_clipboard() clear() diff --git a/test/functional/legacy/glob2regpat_spec.lua b/test/functional/legacy/glob2regpat_spec.lua index 357128bcb6..0492143616 100644 --- a/test/functional/legacy/glob2regpat_spec.lua +++ b/test/functional/legacy/glob2regpat_spec.lua @@ -1,7 +1,7 @@ -- Tests for signs local helpers = require('test.functional.helpers') -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, execute = helpers.clear, helpers.execute local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval describe('glob2regpat()', function() diff --git a/test/functional/legacy/quickfix_spec.lua b/test/functional/legacy/quickfix_spec.lua index 7a9958b949..88f86815b3 100644 --- a/test/functional/legacy/quickfix_spec.lua +++ b/test/functional/legacy/quickfix_spec.lua @@ -1,8 +1,7 @@ -- Test for the quickfix commands. local helpers = require('test.functional.helpers') -local insert, source = helpers.insert, helpers.source -local clear, expect = helpers.clear, helpers.expect +local source, clear = helpers.source, helpers.clear describe('helpgrep', function() before_each(clear) diff --git a/test/functional/legacy/textobjects_spec.lua b/test/functional/legacy/textobjects_spec.lua new file mode 100644 index 0000000000..1e8e0b0bcb --- /dev/null +++ b/test/functional/legacy/textobjects_spec.lua @@ -0,0 +1,61 @@ +local helpers = require('test.functional.helpers') +local call = helpers.call +local clear = helpers.clear +local execute = helpers.execute +local expect = helpers.expect +local source = helpers.source + +describe('Text object', function() + before_each(function() + clear() + execute('set shada=') + source([[ + function SelectionOut(data) + new + call setline(1, a:data) + call setreg('"', '') + normal! ggfrmavi)y + $put =getreg('\"') + call setreg('"', '') + normal! `afbmavi)y + $put =getreg('\"') + call setreg('"', '') + normal! `afgmavi)y + $put =getreg('\"') + endfunction + ]]) + end) + + it('Test for vi) without cpo-M', function() + execute('set cpo-=M') + call('SelectionOut', '(red \\(blue) green)') + + expect([[ + (red \(blue) green) + red \(blue + red \(blue + ]]) + end) + + it('Test for vi) with cpo-M #1', function() + execute('set cpo+=M') + call('SelectionOut', '(red \\(blue) green)') + + expect([[ + (red \(blue) green) + red \(blue) green + blue + red \(blue) green]]) + end) + + it('Test for vi) with cpo-M #2', function() + execute('set cpo+=M') + call('SelectionOut', '(red (blue\\) green)') + + expect([[ + (red (blue\) green) + red (blue\) green + blue\ + red (blue\) green]]) + end) +end) diff --git a/test/functional/legacy/utf8_spec.lua b/test/functional/legacy/utf8_spec.lua index ef717042d0..c16b1c45f4 100644 --- a/test/functional/legacy/utf8_spec.lua +++ b/test/functional/legacy/utf8_spec.lua @@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local execute, expect = helpers.execute, helpers.expect +local eq, eval = helpers.eq, helpers.eval describe('utf8', function() setup(clear) @@ -27,4 +28,26 @@ describe('utf8', function() xあああ bxbb]]) end) + + it('strchars()', function() + eq(1, eval('strchars("a")')) + eq(1, eval('strchars("a", 0)')) + eq(1, eval('strchars("a", 1)')) + + eq(3, eval('strchars("あいa")')) + eq(3, eval('strchars("あいa", 0)')) + eq(3, eval('strchars("あいa", 1)')) + + eq(2, eval('strchars("A\\u20dd")')) + eq(2, eval('strchars("A\\u20dd", 0)')) + eq(1, eval('strchars("A\\u20dd", 1)')) + + eq(3, eval('strchars("A\\u20dd\\u20dd")')) + eq(3, eval('strchars("A\\u20dd\\u20dd", 0)')) + eq(1, eval('strchars("A\\u20dd\\u20dd", 1)')) + + eq(1, eval('strchars("\\u20dd")')) + eq(1, eval('strchars("\\u20dd", 0)')) + eq(1, eval('strchars("\\u20dd", 1)')) + end) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index f9b112e464..6a89b0983d 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -14,15 +14,6 @@ describe('color scheme compatibility', function() request('vim_set_option', 't_Co', '88') eq('88', request('vim_eval', '&t_Co')) end) - - it('emulates gui_running when a rgb UI is attached', function() - eq(0, request('vim_eval', 'has("gui_running")')) - local screen = Screen.new() - screen:attach() - eq(1, request('vim_eval', 'has("gui_running")')) - screen:detach() - eq(0, request('vim_eval', 'has("gui_running")')) - end) end) diff --git a/test/unit/strings_spec.lua b/test/unit/strings_spec.lua index b310ccb541..e935d2af6a 100644 --- a/test/unit/strings_spec.lua +++ b/test/unit/strings_spec.lua @@ -1,7 +1,6 @@ local helpers = require("test.unit.helpers") local cimport = helpers.cimport -local internalize = helpers.internalize local eq = helpers.eq local ffi = helpers.ffi local to_cstr = helpers.to_cstr |