diff options
Diffstat (limited to 'test')
30 files changed, 706 insertions, 84 deletions
diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index 0f59bbea7b..c782107714 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -3,7 +3,6 @@ local helpers = require('test.functional.helpers') local clear, nvim, tabpage, curtab, eq, ok = helpers.clear, helpers.nvim, helpers.tabpage, helpers.curtab, helpers.eq, helpers.ok -local wait = helpers.wait local curtabmeths = helpers.curtabmeths local funcs = helpers.funcs diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 389badb423..20de6d0072 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1,6 +1,7 @@ -- Sanity checks for vim_* API calls via msgpack-rpc local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') +local NIL = helpers.NIL local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local os_name = helpers.os_name diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua index 0e46aa5641..c26ceeaedc 100644 --- a/test/functional/autocmd/textyankpost_spec.lua +++ b/test/functional/autocmd/textyankpost_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers') -local clear, eval, eq, insert = helpers.clear, helpers.eval, helpers.eq, helpers.insert +local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq local feed, execute, expect, command = helpers.feed, helpers.execute, helpers.expect, helpers.command local curbufmeths, funcs, neq = helpers.curbufmeths, helpers.funcs, helpers.neq diff --git a/test/functional/eval/json_functions_spec.lua b/test/functional/eval/json_functions_spec.lua index 1cece78ce1..b32688a9d2 100644 --- a/test/functional/eval/json_functions_spec.lua +++ b/test/functional/eval/json_functions_spec.lua @@ -7,6 +7,7 @@ local eval = helpers.eval local execute = helpers.execute local exc_exec = helpers.exc_exec local redir_exec = helpers.redir_exec +local NIL = helpers.NIL describe('json_decode() function', function() local restart = function(cmd) diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua index 6ab4e6a7d7..2526483830 100644 --- a/test/functional/eval/special_vars_spec.lua +++ b/test/functional/eval/special_vars_spec.lua @@ -1,12 +1,12 @@ local helpers = require('test.functional.helpers') local exc_exec = helpers.exc_exec local execute = helpers.execute -local meths = helpers.meths local funcs = helpers.funcs -local meths = helpers.meths local clear = helpers.clear local eval = helpers.eval local eq = helpers.eq +local meths = helpers.meths +local NIL = helpers.NIL describe('Special values', function() before_each(clear) diff --git a/test/functional/eval/string_spec.lua b/test/functional/eval/string_spec.lua index 0fd7587edb..abda2c59cb 100644 --- a/test/functional/eval/string_spec.lua +++ b/test/functional/eval/string_spec.lua @@ -8,6 +8,7 @@ local exc_exec = helpers.exc_exec local redir_exec = helpers.redir_exec local funcs = helpers.funcs local write_file = helpers.write_file +local NIL = helpers.NIL describe('string() function', function() before_each(clear) diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua new file mode 100644 index 0000000000..2d5ab8e8c8 --- /dev/null +++ b/test/functional/ex_cmds/append_spec.lua @@ -0,0 +1,54 @@ +local helpers = require('test.functional.helpers') + +local eq = helpers.eq +local feed = helpers.feed +local clear = helpers.clear +local funcs = helpers.funcs +local command = helpers.command +local curbufmeths = helpers.curbufmeths + +before_each(function() + clear() + curbufmeths.set_lines(0, 1, true, { 'foo', 'bar', 'baz' }) +end) + +local buffer_contents = function() + return curbufmeths.get_lines(0, -1, false) +end + +local cmdtest = function(cmd, prep, ret1) + describe(':' .. cmd, function() + it(cmd .. 's' .. prep .. ' the current line by default', function() + command(cmd .. '\nabc\ndef\n') + eq(ret1, buffer_contents()) + end) + -- Used to crash because this invokes history processing which uses + -- hist_char2type which after fdb68e35e4c729c7ed097d8ade1da29e5b3f4b31 + -- crashed. + it(cmd .. 's' .. prep .. ' the current line by default when feeding', + function() + feed(':' .. cmd .. '\nabc\ndef\n.\n') + eq(ret1, buffer_contents()) + end) + -- This used to crash since that commit as well. + it('opens empty cmdline window', function() + local hisline = '" Some comment to be stored in history' + feed(':' .. hisline .. '<CR>') + feed(':' .. cmd .. '<CR>abc<CR>def<C-f>') + eq({ 'def' }, buffer_contents()) + eq(hisline, funcs.histget(':', -2)) + eq(cmd, funcs.histget(':')) + -- Test that command-line window was launched + eq('nofile', curbufmeths.get_option('buftype')) + eq('n', funcs.mode(1)) + feed('<CR>') + eq('c', funcs.mode(1)) + feed('.<CR>') + eq('n', funcs.mode(1)) + eq(ret1, buffer_contents()) + end) + end) +end +cmdtest('insert', ' before', { 'abc', 'def', 'foo', 'bar', 'baz' }) +cmdtest('append', ' after', { 'foo', 'abc', 'def', 'bar', 'baz' }) +cmdtest('change', '', { 'abc', 'def', 'bar', 'baz' }) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index f5cce65104..69467632a4 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers') local execute, eq, clear, eval, exc_exec = helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.exc_exec - +local lfs = require('lfs') -- These directories will be created for testing local directories = { @@ -16,13 +16,13 @@ local directories = { local cwd = function() return eval('getcwd( )') end -- effective working dir local wcwd = function() return eval('getcwd( 0 )') end -- window dir local tcwd = function() return eval('getcwd(-1, 0)') end -- tab dir -local gcwd = function() return eval('getcwd(-1, -1)') end -- global dir +--local gcwd = function() return eval('getcwd(-1, -1)') end -- global dir -- Same, except these tell us if there is a working directory at all -local lwd = function() return eval('haslocaldir( )') end -- effective working dir +--local lwd = function() return eval('haslocaldir( )') end -- effective working dir local wlwd = function() return eval('haslocaldir( 0 )') end -- window dir local tlwd = function() return eval('haslocaldir(-1, 0)') end -- tab dir -local glwd = function() return eval('haslocaldir(-1, -1)') end -- global dir +--local glwd = function() return eval('haslocaldir(-1, -1)') end -- global dir -- Test both the `cd` and `chdir` variants for _, cmd in ipairs {'cd', 'chdir'} do @@ -53,7 +53,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Change tab-local working directory and verify it is different - execute('t' .. cmd .. ' ' .. directories[1]) + execute('silent t' .. cmd .. ' ' .. directories[1]) eq(globalDir .. '/' .. directories[1], cwd()) eq(cwd(), tcwd()) -- working directory maches tab directory eq(1, tlwd()) @@ -65,7 +65,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(1, tlwd()) -- Still tab-local working directory eq(0, wlwd()) -- Still no window-local working directory eq(globalDir .. '/' .. directories[1], cwd()) - execute('l' .. cmd .. ' ../' .. directories[2]) + execute('silent l' .. cmd .. ' ../' .. directories[2]) eq(globalDir .. '/' .. directories[2], cwd()) eq(globalDir .. '/' .. directories[1], tcwd()) eq(1, wlwd()) @@ -83,7 +83,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Verify global changes don't affect local ones - execute('' .. cmd .. ' ' .. directories[3]) + execute('silent ' .. cmd .. ' ' .. directories[3]) eq(globalDir .. '/' .. directories[3], cwd()) execute('tabnext') eq(globalDir .. '/' .. directories[1], cwd()) @@ -91,7 +91,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Still no window-local directory in this window -- Unless the global change happened in a tab with local directory - execute('' .. cmd .. ' ..') + execute('silent ' .. cmd .. ' ..') eq(globalDir, cwd() ) eq(0 , tlwd()) eq(0 , wlwd()) @@ -111,37 +111,41 @@ end -- Test legal parameters for 'getcwd' and 'haslocaldir' for _, cmd in ipairs {'getcwd', 'haslocaldir'} do describe(cmd..'()', function() + before_each(function() + clear() + end) + -- Test invalid argument types - local expected = 'Vim(call):E474: Invalid argument' + local err474 = 'Vim(call):E474: Invalid argument' it('fails on string', function() - eq(expected, exc_exec('call ' .. cmd .. '("some string")')) + eq(err474, exc_exec('call ' .. cmd .. '("some string")')) end) it('fails on float', function() - eq(expected, exc_exec('call ' .. cmd .. '(1.0)')) + eq(err474, exc_exec('call ' .. cmd .. '(1.0)')) end) it('fails on list', function() - eq(expected, exc_exec('call ' .. cmd .. '([1, 2])')) + eq(err474, exc_exec('call ' .. cmd .. '([1, 2])')) end) it('fails on dictionary', function() - eq(expected, exc_exec('call ' .. cmd .. '({"key": "value"})')) + eq(err474, exc_exec('call ' .. cmd .. '({"key": "value"})')) end) it('fails on funcref', function() - eq(expected, exc_exec('call ' .. cmd .. '(function("tr"))')) + eq(err474, exc_exec('call ' .. cmd .. '(function("tr"))')) end) -- Test invalid numbers it('fails on number less than -1', function() - eq(expected, exc_exec('call ' .. cmd .. '(-2)')) + eq(err474, exc_exec('call ' .. cmd .. '(-2)')) end) - local expected = 'Vim(call):E5001: Higher scope cannot be -1 if lower scope is >= 0.' + local err5001 = 'Vim(call):E5001: Higher scope cannot be -1 if lower scope is >= 0.' it('fails on -1 if previous arg is >=0', function() - eq(expected, exc_exec('call ' .. cmd .. '(0, -1)')) + eq(err5001, exc_exec('call ' .. cmd .. '(0, -1)')) end) -- Test wrong number of arguments - local expected = 'Vim(call):E118: Too many arguments for function: ' .. cmd + local err118 = 'Vim(call):E118: Too many arguments for function: ' .. cmd it('fails to parse more than one argument', function() - eq(expected, exc_exec('call ' .. cmd .. '(0, 0, 0)')) + eq(err118, exc_exec('call ' .. cmd .. '(0, 0, 0)')) end) end) end diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua new file mode 100644 index 0000000000..d90b297ca8 --- /dev/null +++ b/test/functional/ex_cmds/write_spec.lua @@ -0,0 +1,38 @@ +-- Specs for :write + +local helpers = require('test.functional.helpers') +local eq, eval, clear, write_file, execute, source = + helpers.eq, helpers.eval, helpers.clear, helpers.write_file, + helpers.execute, helpers.source + +describe(':write', function() + it('&backupcopy=auto preserves symlinks', function() + clear('set backupcopy=auto') + os.remove('test_bkc_file.txt') + os.remove('test_bkc_link.txt') + write_file('test_bkc_file.txt', 'content0') + execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + source([[ + edit test_bkc_link.txt + call setline(1, ['content1']) + write + ]]) + eq(eval("['content1']"), eval("readfile('test_bkc_file.txt')")) + eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')")) + end) + + it('&backupcopy=no replaces symlink with new file', function() + clear('set backupcopy=no') + os.remove('test_bkc_file.txt') + os.remove('test_bkc_link.txt') + write_file('test_bkc_file.txt', 'content0') + execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + source([[ + edit test_bkc_link.txt + call setline(1, ['content1']) + write + ]]) + eq(eval("['content0']"), eval("readfile('test_bkc_file.txt')")) + eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')")) + end) +end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index a382641cff..6ccadda72d 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,5 +1,4 @@ require('coxpcall') -NIL = require('mpack').NIL local lfs = require('lfs') local assert = require('luassert') local ChildProcessStream = require('nvim.child_process_stream') @@ -10,6 +9,8 @@ local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.', '--embed'} +local mpack = require('mpack') + -- Formulate a path to the directory containing nvim. We use this to -- help run test executables. It helps to keep the tests working, even -- when the build is not in the default location. @@ -452,4 +453,5 @@ return { curbufmeths = curbufmeths, curwinmeths = curwinmeths, curtabmeths = curtabmeths, + NIL = mpack.NIL } diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua index 1359b45228..2a4c0149fa 100644 --- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua +++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua @@ -31,7 +31,8 @@ local function run_test_with_regexpengine(regexpengine) h AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ j 0123❤x - k combinations]]) + k combinations + l ä ö ü ᾱ̆́]]) execute('set re=' .. regexpengine) @@ -85,6 +86,11 @@ local function run_test_with_regexpengine(regexpengine) execute([[let @w=':%s#comb[i]nations#œ̄ṣ́m̥̄ᾱ̆́#g']]) execute('@w') + -- Line l. Ex command ":s/ \?/ /g" should NOT split multi-byte characters + -- into bytes (fixed by vim-7.3.192). + execute([[/^l]]) + execute([[s/ \?/ /g]]) + -- Additional tests. Test matchstr() with multi-byte characters. feed('G') execute([[put =matchstr(\"אבגד\", \".\", 0, 2)]]) -- ב @@ -123,6 +129,7 @@ local function run_test_with_regexpengine(regexpengine) i aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑ j 012❤ k œ̄ṣ́m̥̄ᾱ̆́ + l ä ö ü ᾱ̆́ ב בג א diff --git a/test/functional/legacy/057_sort_spec.lua b/test/functional/legacy/057_sort_spec.lua index 7eed31e292..36062ded3a 100644 --- a/test/functional/legacy/057_sort_spec.lua +++ b/test/functional/legacy/057_sort_spec.lua @@ -668,4 +668,22 @@ describe(':sort', function() b0b101100 b0b111000]]) end) + + it('float', function() + insert([[ + 1.234 + 0.88 + 123.456 + 1.15e-6 + -1.1e3 + -1.01e3]]) + execute([[sort f]]) + expect([[ + -1.1e3 + -1.01e3 + 1.15e-6 + 0.88 + 1.234 + 123.456]]) + end) end) diff --git a/test/functional/legacy/backspace_opt_spec.lua b/test/functional/legacy/backspace_opt_spec.lua new file mode 100644 index 0000000000..b40019a410 --- /dev/null +++ b/test/functional/legacy/backspace_opt_spec.lua @@ -0,0 +1,67 @@ +local helpers = require('test.functional.helpers') +local call, clear = helpers.call, helpers.clear +local source, eq, nvim = helpers.source, helpers.eq, helpers.meths + +describe("test 'backspace' settings", function() + before_each(function() + clear() + + source([[ + func Exec(expr) + let str='' + try + exec a:expr + catch /.*/ + let str=v:exception + endtry + return str + endfunc + + func Test_backspace_option() + set backspace= + call assert_equal('', &backspace) + set backspace=indent + call assert_equal('indent', &backspace) + set backspace=eol + call assert_equal('eol', &backspace) + set backspace=start + call assert_equal('start', &backspace) + " Add the value + set backspace= + set backspace=indent + call assert_equal('indent', &backspace) + set backspace+=eol + call assert_equal('indent,eol', &backspace) + set backspace+=start + call assert_equal('indent,eol,start', &backspace) + " Delete the value + set backspace-=indent + call assert_equal('eol,start', &backspace) + set backspace-=start + call assert_equal('eol', &backspace) + set backspace-=eol + call assert_equal('', &backspace) + " Check the error + call assert_equal(0, match(Exec('set backspace=ABC'), '.*E474')) + call assert_equal(0, match(Exec('set backspace+=def'), '.*E474')) + " NOTE: Vim doesn't check following error... + "call assert_equal(0, match(Exec('set backspace-=ghi'), '.*E474')) + + " Check backwards compatibility with version 5.4 and earlier + set backspace=0 + call assert_equal('0', &backspace) + set backspace=1 + call assert_equal('1', &backspace) + set backspace=2 + call assert_equal('2', &backspace) + call assert_false(match(Exec('set backspace=3'), '.*E474')) + call assert_false(match(Exec('set backspace=10'), '.*E474')) + endfunc + ]]) + end) + + it('works', function() + call('Test_backspace_option') + eq({}, nvim.get_vvar('errors')) + end) +end) diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua new file mode 100644 index 0000000000..9083911021 --- /dev/null +++ b/test/functional/legacy/function_sort_spec.lua @@ -0,0 +1,29 @@ +local helpers = require('test.functional.helpers') +local clear = helpers.clear +local eq = helpers.eq +local eval = helpers.eval + +describe('sort', function() + before_each(clear) + + it('numbers compared as strings', function() + eq({1, 2, 3}, eval('sort([3, 2, 1])')) + eq({13, 28, 3}, eval('sort([3, 28, 13])')) + end) + + it('numbers compared as numeric', function() + eq({1, 2, 3}, eval("sort([3, 2, 1], 'n')")) + eq({3, 13, 28}, eval("sort([3, 28, 13], 'n')")) + -- Strings are not sorted. + eq({'13', '28', '3'}, eval("sort(['13', '28', '3'], 'n')")) + end) + + it('numbers compared as numbers', function() + eq({3, 13, 28}, eval("sort([13, 28, 3], 'N')")) + eq({'3', '13', '28'}, eval("sort(['13', '28', '3'], 'N')")) + end) + + it('numbers compared as float', function() + eq({0.28, 3, 13.5}, eval("sort([13.5, 0.28, 3], 'f')")) + end) +end) diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua new file mode 100644 index 0000000000..1c9b1ccee6 --- /dev/null +++ b/test/functional/legacy/searchpos_spec.lua @@ -0,0 +1,35 @@ +local helpers = require('test.functional.helpers') +local call = helpers.call +local clear = helpers.clear +local execute = helpers.execute +local eq = helpers.eq +local eval = helpers.eval +local insert = helpers.insert + +describe('searchpos', function() + before_each(clear) + + it('is working', function() + insert([[ + 1a3 + 123xyz]]) + + call('cursor', 1, 1) + eq({1, 1, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) + call('cursor', 1, 2) + eq({2, 1, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) + + execute('set cpo-=c') + call('cursor', 1, 2) + eq({1, 2, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) + call('cursor', 1, 3) + eq({1, 3, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]])) + + -- Now with \zs, first match is in column 0, "a" is matched. + call('cursor', 1, 3) + eq({2, 4, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')]])) + -- With z flag start at cursor column, don't see the "a". + call('cursor', 1, 3) + eq({2, 4, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')]])) + end) +end) diff --git a/test/functional/legacy/tagcase_spec.lua b/test/functional/legacy/tagcase_spec.lua new file mode 100644 index 0000000000..9a8c6fbe42 --- /dev/null +++ b/test/functional/legacy/tagcase_spec.lua @@ -0,0 +1,150 @@ +local helpers = require('test.functional.helpers') +local clear = helpers.clear +local eq = helpers.eq +local eval = helpers.eval +local exc_exec = helpers.exc_exec +local expect = helpers.expect +local insert = helpers.insert +local source = helpers.source +local write_file = helpers.write_file + +describe("'tagcase' option", function() + setup(function() + write_file('Xtags', [[ + Bar Xtext 3 + Foo Xtext 2 + foo Xtext 4]]) + end) + + before_each(function() + clear() + source([[ + lang mess C + set tags=Xtags]]) + end) + + teardown(function() + os.remove('Xtags') + end) + + it('should have correct default values', function() + source([[ + set ic& + setg tc& + setl tc& + ]]) + + eq(0, eval('&ic')) + eq('followic', eval('&g:tc')) + eq('followic', eval('&l:tc')) + eq('followic', eval('&tc')) + end) + + it('should accept <empty> only for setlocal', function() + -- Verify that the local setting accepts <empty> but that the global setting + -- does not. The first of these (setting the local value to <empty>) should + -- succeed; the other two should fail. + eq(0, exc_exec('setl tc=')) + eq('Vim(setglobal):E474: Invalid argument: tc=', exc_exec('setg tc=')) + eq('Vim(set):E474: Invalid argument: tc=', exc_exec('set tc=')) + end) + + it("should work with 'ignorecase' correctly in all combinations", function() + -- Verify that the correct number of matching tags is found for all values of + -- 'ignorecase' and global and local values 'tagcase', in all combinations. + insert([[ + + Foo + Bar + foo + + end text]]) + + source([[ + for &ic in [0, 1] + for &g:tc in ["followic", "ignore", "match"] + for &l:tc in ["", "followic", "ignore", "match"] + call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc) + call append('$', len(taglist("^foo$"))) + call append('$', len(taglist("^Foo$"))) + endfor + endfor + endfor + + 1,/^end text$/d]]) + + expect([[ + ic=0 g:tc=followic l:tc= tc=followic + 1 + 1 + ic=0 g:tc=followic l:tc=followic tc=followic + 1 + 1 + ic=0 g:tc=followic l:tc=ignore tc=ignore + 2 + 2 + ic=0 g:tc=followic l:tc=match tc=match + 1 + 1 + ic=0 g:tc=ignore l:tc= tc=ignore + 2 + 2 + ic=0 g:tc=ignore l:tc=followic tc=followic + 1 + 1 + ic=0 g:tc=ignore l:tc=ignore tc=ignore + 2 + 2 + ic=0 g:tc=ignore l:tc=match tc=match + 1 + 1 + ic=0 g:tc=match l:tc= tc=match + 1 + 1 + ic=0 g:tc=match l:tc=followic tc=followic + 1 + 1 + ic=0 g:tc=match l:tc=ignore tc=ignore + 2 + 2 + ic=0 g:tc=match l:tc=match tc=match + 1 + 1 + ic=1 g:tc=followic l:tc= tc=followic + 2 + 2 + ic=1 g:tc=followic l:tc=followic tc=followic + 2 + 2 + ic=1 g:tc=followic l:tc=ignore tc=ignore + 2 + 2 + ic=1 g:tc=followic l:tc=match tc=match + 1 + 1 + ic=1 g:tc=ignore l:tc= tc=ignore + 2 + 2 + ic=1 g:tc=ignore l:tc=followic tc=followic + 2 + 2 + ic=1 g:tc=ignore l:tc=ignore tc=ignore + 2 + 2 + ic=1 g:tc=ignore l:tc=match tc=match + 1 + 1 + ic=1 g:tc=match l:tc= tc=match + 1 + 1 + ic=1 g:tc=match l:tc=followic tc=followic + 2 + 2 + ic=1 g:tc=match l:tc=ignore tc=ignore + 2 + 2 + ic=1 g:tc=match l:tc=match tc=match + 1 + 1]]) + end) +end) diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 7f0892ee3a..d4c3267997 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -1,8 +1,7 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local clear, feed = helpers.clear, helpers.feed -local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq -local execute, source, expect = helpers.execute, helpers.source, helpers.expect +local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq +local execute = helpers.execute local function init_session(...) local args = { helpers.nvim_prog, '-i', 'NONE', '--embed', diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua index 04a64d2943..4455ef663f 100644 --- a/test/functional/options/shortmess_spec.lua +++ b/test/functional/options/shortmess_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local clear, execute = helpers.clear, helpers.execute describe("'shortmess'", function() local screen diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua new file mode 100644 index 0000000000..d8c1f2d392 --- /dev/null +++ b/test/functional/plugin/matchparen_spec.lua @@ -0,0 +1,36 @@ +local helpers = require('test.functional.helpers') +local Screen = require('test.functional.ui.screen') +local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute + +describe('matchparen', function() + local screen + + before_each(function() + clear() + screen = Screen.new(20,5) + screen:attach() + screen:set_default_attr_ignore( {{bold=true, foreground=Screen.colors.Blue}} ) + end) + + it('uses correct column after i_<Up>. Vim patch 7.4.1296', function() + execute('set noai nosi nocin') + execute('runtime plugin/matchparen.vim') + feed('ivoid f_test()<cr>') + feed('{<cr>') + feed('}') + + -- critical part: up + cr should result in an empty line inbetween the + -- brackets... if the bug is there, the empty line will be before the '{' + feed('<up>') + feed('<cr>') + + screen:expect([[ + void f_test() | + { | + ^ | + } | + {1:-- INSERT --} | + ]], {[1] = {bold = true}}) + + end) +end) diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua index 246b26188f..60ba88e55b 100644 --- a/test/functional/plugin/msgpack_spec.lua +++ b/test/functional/plugin/msgpack_spec.lua @@ -3,6 +3,7 @@ local meths = helpers.meths local eq, nvim_eval, nvim_command, exc_exec = helpers.eq, helpers.eval, helpers.command, helpers.exc_exec local ok = helpers.ok +local NIL = helpers.NIL local plugin_helpers = require('test.functional.plugin.helpers') local reset = plugin_helpers.reset diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 6a89b0983d..4b0173fa89 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1,5 +1,6 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') +local os = require('os') local clear, feed = helpers.clear, helpers.feed local execute, request, eq = helpers.execute, helpers.request, helpers.eq @@ -16,6 +17,73 @@ describe('color scheme compatibility', function() end) end) +describe('manual syntax highlight', function() + -- When using manual syntax highlighting, it should be preserved even when + -- switching buffers... bug did only occur without :set hidden + -- Ref: vim patch 7.4.1236 + local screen + + before_each(function() + clear() + screen = Screen.new(20,5) + screen:attach() + --ignore highligting of ~-lines + screen:set_default_attr_ignore( {{bold=true, foreground=Screen.colors.Blue}} ) + --syntax highlight for vimcscripts "echo" + screen:set_default_attr_ids( {[1] = {bold=true, foreground=Screen.colors.Brown}} ) + end) + + after_each(function() + screen:detach() + os.remove('Xtest-functional-ui-highlight.tmp.vim') + end) + + -- test with "set hidden" even if the bug did not occur this way + it("works with buffer switch and 'hidden'", function() + execute('e tmp1.vim') + execute('e Xtest-functional-ui-highlight.tmp.vim') + execute('filetype on') + execute('syntax manual') + execute('set ft=vim') + execute('set syntax=ON') + feed('iecho 1<esc>0') + + execute('set hidden') + execute('w') + execute('bn') + execute('bp') + screen:expect([[ + {1:^echo} 1 | + ~ | + ~ | + ~ | + <f 1 --100%-- col 1 | + ]]) + end) + + it("works with buffer switch and 'nohidden'", function() + execute('e tmp1.vim') + execute('e Xtest-functional-ui-highlight.tmp.vim') + execute('filetype on') + execute('syntax manual') + execute('set ft=vim') + execute('set syntax=ON') + feed('iecho 1<esc>0') + + execute('set nohidden') + execute('w') + execute('bn') + execute('bp') + screen:expect([[ + {1:^echo} 1 | + ~ | + ~ | + ~ | + <ht.tmp.vim" 1L, 7C | + ]]) + end) +end) + describe('Default highlight groups', function() -- Test the default attributes for highlight groups shown by the :highlight @@ -38,6 +106,7 @@ describe('Default highlight groups', function() after_each(function() screen:detach() end) + it('window status bar', function() screen:set_default_attr_ids({ [1] = {reverse = true, bold = true}, -- StatusLine diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index da9d6a0cd2..d0d791308b 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -426,4 +426,35 @@ describe('Mouse input', function() | ]]) end) + + it('horizontal scrolling', function() + feed("<esc>:set nowrap<cr>") + + feed("a <esc>20Ab<esc>") + screen:expect([[ + | + | + bbbbbbbbbbbbbbb^b | + ~ | + | + ]]) + + feed("<ScrollWheelLeft><0,0>") + screen:expect([[ + | + | + n bbbbbbbbbbbbbbbbbbb^b | + ~ | + | + ]]) + + feed("^<ScrollWheelRight><0,0>") + screen:expect([[ + g | + | + ^t and selection bbbbbbbbb| + ~ | + | + ]]) + end) end) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index de2f3e469d..c57d4abcbf 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute +local funcs = helpers.funcs describe("'wildmode'", function() local screen @@ -30,3 +31,34 @@ describe("'wildmode'", function() end) end) end) + +describe('command line completion', function() + local screen + + before_each(function() + clear() + screen = Screen.new(40, 5) + screen:attach() + screen:set_default_attr_ignore({{bold=true, foreground=Screen.colors.Blue}}) + end) + + after_each(function() + os.remove('Xtest-functional-viml-compl-dir') + end) + + it('lists directories with empty PATH', function() + local tmp = funcs.tempname() + execute('e '.. tmp) + execute('cd %:h') + execute("call mkdir('Xtest-functional-viml-compl-dir')") + execute('let $PATH=""') + feed(':!<tab><bs>') + screen:expect([[ + | + ~ | + ~ | + ~ | + :!Xtest-functional-viml-compl-dir^ | + ]]) + end) +end) diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 322d777ab6..0271540fe3 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -1,8 +1,8 @@ - local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq +local insert = helpers.insert local execute, source, expect = helpers.execute, helpers.source, helpers.expect describe('completion', function() @@ -714,6 +714,52 @@ describe('completion', function() {3:-- Keyword completion (^N^P) }{4:match 2 of 2} | ]]) end) + + describe('from the commandline window', function() + it('is cleared after CTRL-C', function () + feed('q:') + feed('ifoo faa fee f') + screen:expect([[ + | + {8:[No Name] }| + :foo faa fee f^ | + :~ | + :~ | + :~ | + {9:[Command Line] }| + {3:-- INSERT --} | + ]], {[3] = {bold = true}, + [4] = {bold = true, foreground = Screen.colors.SeaGreen}, + [8] = {reverse = true}, + [9] = {bold = true, reverse = true}}) + feed('<c-x><c-n>') + screen:expect([[ + | + {8:[No Name] }| + :foo faa fee foo^ | + :~ {2: foo } | + :~ {1: faa } | + :~ {1: fee } | + {9:[Command Line] }| + {3:-- Keyword Local completion (^N^P) }{4:match 1 of 3} | + ]],{[1] = {background = Screen.colors.LightMagenta}, + [2] = {background = Screen.colors.Grey}, + [3] = {bold = true}, + [4] = {bold = true, foreground = Screen.colors.SeaGreen}, + [8] = {reverse = true}, + [9] = {bold = true, reverse = true}}) + feed('<c-c>') + screen:expect([[ + | + {8:[No Name] }| + :foo faa fee foo | + :~ | + :~ | + :~ | + {9:[Command Line] }| + :foo faa fee foo^ | + ]], {[8] = {reverse = true}, [9] = {bold = true, reverse = true}}) + end) + end) end) - diff --git a/test/unit/eval/helpers.lua b/test/unit/eval/helpers.lua index da2f5626ff..2367f03e0d 100644 --- a/test/unit/eval/helpers.lua +++ b/test/unit/eval/helpers.lua @@ -12,7 +12,7 @@ local null_list = {[true]='NULL list'} local type_key = {[true]='type key'} local list_type = {[true]='list type'} -local list = function(...) +local function list(...) local ret = ffi.gc(eval.list_alloc(), eval.list_unref) eq(0, ret.lv_refcount) ret.lv_refcount = 1 @@ -47,7 +47,7 @@ local lst2tbl = function(l) while li ~= nil do local typ = li.li_tv.v_type if typ == eval.VAR_STRING then - str = li.li_tv.vval.v_string + local str = li.li_tv.vval.v_string if str == nil then ret[#ret + 1] = null_string else diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 9b9c1fef0f..426ae2d9e0 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -140,6 +140,7 @@ do local time = cimport('./src/nvim/os/time.h') time.time_init() main.early_init() + main.event_init() end -- C constants. diff --git a/test/unit/mbyte_spec.lua b/test/unit/mbyte_spec.lua index e1b401c76d..9b2415a93f 100644 --- a/test/unit/mbyte_spec.lua +++ b/test/unit/mbyte_spec.lua @@ -3,7 +3,6 @@ local helpers = require("test.unit.helpers") local ffi = helpers.ffi local eq = helpers.eq -local globals = helpers.cimport("./src/nvim/globals.h") local mbyte = helpers.cimport("./src/nvim/mbyte.h") describe('mbyte', function() @@ -17,7 +16,7 @@ describe('mbyte', function() -- Convert from bytes to string local function to_string(bytes) - s = {} + local s = {} for i = 1, #bytes do s[i] = string.char(bytes[i]) end @@ -59,20 +58,20 @@ describe('mbyte', function() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x7f}), pcc, 2)) eq(0, pcc[0]) -- No combining characters - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x80}), pcc, 2)) eq(0, pcc[0]) -- No UTF-8 sequence - local pcc = to_intp() + pcc = to_intp() eq(0x00c2, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x7f}), pcc, 2)) eq(0, pcc[0]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80}), pcc, 2)) eq(0, pcc[0]) -- No UTF-8 sequence - local pcc = to_intp() + pcc = to_intp() eq(0x00c2, mbyte.utfc_ptr2char_len(to_string({0xc2, 0xc0}), pcc, 2)) eq(0, pcc[0]) end) @@ -84,27 +83,27 @@ describe('mbyte', function() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x80, 0x80}), pcc, 3)) eq(0, pcc[0]) -- No combining character - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xc2, 0x80}), pcc, 3)) eq(0, pcc[0]) -- Combining character is U+0300 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80}), pcc, 3)) eq(0x0300, pcc[0]) eq(0x0000, pcc[1]) -- No UTF-8 sequence - local pcc = to_intp() + pcc = to_intp() eq(0x00c2, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x7f, 0xcc}), pcc, 3)) eq(0, pcc[0]) -- Incomplete combining character - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc}), pcc, 3)) eq(0, pcc[0]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x20d0, mbyte.utfc_ptr2char_len(to_string({0xe2, 0x83, 0x90}), pcc, 3)) eq(0, pcc[0]) end) @@ -116,32 +115,32 @@ describe('mbyte', function() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x7f, 0xcc, 0x80}), pcc, 4)) eq(0, pcc[0]) -- No second UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xc2, 0xcc, 0x80}), pcc, 4)) eq(0, pcc[0]) -- Combining character U+0300 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80, 0xcc}), pcc, 4)) eq(0x0300, pcc[0]) eq(0x0000, pcc[1]) -- No UTF-8 sequence - local pcc = to_intp() + pcc = to_intp() eq(0x00c2, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x7f, 0xcc, 0x80}), pcc, 4)) eq(0, pcc[0]) -- No following UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc, 0xcc}), pcc, 4)) eq(0, pcc[0]) -- Combining character U+0301 - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc, 0x81}), pcc, 4)) eq(0x0301, pcc[0]) eq(0x0000, pcc[1]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x100000, mbyte.utfc_ptr2char_len(to_string({0xf4, 0x80, 0x80, 0x80}), pcc, 4)) eq(0, pcc[0]) end) @@ -153,31 +152,31 @@ describe('mbyte', function() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0x7f, 0xcc, 0x80, 0x80}), pcc, 5)) eq(0, pcc[0]) -- No second UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xc2, 0xcc, 0x80, 0x80}), pcc, 5)) eq(0, pcc[0]) -- Combining character U+0300 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80, 0xcc}), pcc, 5)) eq(0x0300, pcc[0]) eq(0x0000, pcc[1]) -- Combining characters U+0300 and U+0301 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80, 0xcc, 0x81}), pcc, 5)) eq(0x0300, pcc[0]) eq(0x0301, pcc[1]) eq(0x0000, pcc[2]) -- Combining characters U+0300, U+0301, U+0302 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82}), pcc, 7)) eq(0x0300, pcc[0]) eq(0x0301, pcc[1]) eq(0x0302, pcc[2]) eq(0x0000, pcc[3]) -- Combining characters U+0300, U+0301, U+0302, U+0303 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string({0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83}), pcc, 9)) eq(0x0300, pcc[0]) eq(0x0301, pcc[1]) @@ -185,7 +184,7 @@ describe('mbyte', function() eq(0x0303, pcc[3]) eq(0x0000, pcc[4]) -- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string( {0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84}), pcc, 11)) eq(0x0300, pcc[0]) @@ -196,7 +195,7 @@ describe('mbyte', function() eq(0x0000, pcc[5]) -- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304, -- U+0305 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string( {0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84, 0xcc, 0x85}), pcc, 13)) eq(0x0300, pcc[0]) @@ -209,7 +208,7 @@ describe('mbyte', function() -- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304, -- U+0305, U+0306, but only save six (= MAX_MCO). - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string( {0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84, 0xcc, 0x85, 0xcc, 0x86}), pcc, 15)) eq(0x0300, pcc[0]) @@ -221,7 +220,7 @@ describe('mbyte', function() eq(0x0001, pcc[6]) -- Only three following combining characters U+0300, U+0301, U+0302 - local pcc = to_intp() + pcc = to_intp() eq(0x007f, mbyte.utfc_ptr2char_len(to_string( {0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xc2, 0x80, 0xcc, 0x84, 0xcc, 0x85}), pcc, 13)) eq(0x0300, pcc[0]) @@ -231,40 +230,40 @@ describe('mbyte', function() -- No UTF-8 sequence - local pcc = to_intp() + pcc = to_intp() eq(0x00c2, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x7f, 0xcc, 0x80, 0x80}), pcc, 5)) eq(0, pcc[0]) -- No following UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc, 0xcc, 0x80}), pcc, 5)) eq(0, pcc[0]) -- Combining character U+0301 - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc, 0x81, 0x7f}), pcc, 5)) eq(0x0301, pcc[0]) eq(0x0000, pcc[1]) -- Combining character U+0301 - local pcc = to_intp() + pcc = to_intp() eq(0x0080, mbyte.utfc_ptr2char_len(to_string({0xc2, 0x80, 0xcc, 0x81, 0xcc}), pcc, 5)) eq(0x0301, pcc[0]) eq(0x0000, pcc[1]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x100000, mbyte.utfc_ptr2char_len(to_string({0xf4, 0x80, 0x80, 0x80, 0x7f}), pcc, 5)) eq(0, pcc[0]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x100000, mbyte.utfc_ptr2char_len(to_string({0xf4, 0x80, 0x80, 0x80, 0x80}), pcc, 5)) eq(0, pcc[0]) -- One UTF-8 character - local pcc = to_intp() + pcc = to_intp() eq(0x100000, mbyte.utfc_ptr2char_len(to_string({0xf4, 0x80, 0x80, 0x80, 0xcc}), pcc, 5)) eq(0, pcc[0]) -- Combining characters U+1AB0 and U+0301 - local pcc = to_intp() + pcc = to_intp() eq(0x100000, mbyte.utfc_ptr2char_len(to_string( {0xf4, 0x80, 0x80, 0x80, 0xe1, 0xaa, 0xb0, 0xcc, 0x81}), pcc, 9)) eq(0x1ab0, pcc[0]) diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 2f393d353d..71b5e7f576 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -148,7 +148,7 @@ describe('fs function', function() local function os_can_exe(name) local buf = ffi.new('char *[1]') buf[0] = NULL - local ok = fs.os_can_exe(to_cstr(name), buf) + local ok = fs.os_can_exe(to_cstr(name), buf, true) -- When os_can_exe returns true, it must set the path. -- When it returns false, the path must be NULL. diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua index 6d1a9f3589..93103e4e8c 100644 --- a/test/unit/os/shell_spec.lua +++ b/test/unit/os/shell_spec.lua @@ -11,7 +11,7 @@ if allowed_os[jit.os] ~= true then end local helpers = require('test.unit.helpers') -local shell = helpers.cimport( +local cimported = helpers.cimport( './src/nvim/os/shell.h', './src/nvim/option_defs.h', './src/nvim/main.h', @@ -25,18 +25,17 @@ local NULL = ffi.cast('void *', 0) describe('shell functions', function() setup(function() - shell.event_init() -- os_system() can't work when the p_sh and p_shcf variables are unset - shell.p_sh = to_cstr('/bin/bash') - shell.p_shcf = to_cstr('-c') + cimported.p_sh = to_cstr('/bin/bash') + cimported.p_shcf = to_cstr('-c') end) teardown(function() - shell.event_teardown() + cimported.event_teardown() end) local function shell_build_argv(cmd, extra_args) - local res = shell.shell_build_argv( + local res = cimported.shell_build_argv( cmd and to_cstr(cmd), extra_args and to_cstr(extra_args)) local argc = 0 @@ -45,10 +44,10 @@ describe('shell functions', function() -- crash. while res[argc] ~= nil do ret[#ret + 1] = ffi.string(res[argc]) - shell.xfree(res[argc]) + cimported.xfree(res[argc]) argc = argc + 1 end - shell.xfree(res) + cimported.xfree(res) return ret end @@ -59,8 +58,8 @@ describe('shell functions', function() local nread = ffi.new('size_t[1]') local argv = ffi.cast('char**', - shell.shell_build_argv(to_cstr(cmd), nil)) - local status = shell.os_system(argv, input_or, input_len, output, nread) + cimported.shell_build_argv(to_cstr(cmd), nil)) + local status = cimported.os_system(argv, input_or, input_len, output, nread) return status, intern(output[0], nread[0]) end @@ -97,13 +96,13 @@ describe('shell functions', function() local saved_opts = {} setup(function() - saved_opts.p_sh = shell.p_sh - saved_opts.p_shcf = shell.p_shcf + saved_opts.p_sh = cimported.p_sh + saved_opts.p_shcf = cimported.p_shcf end) teardown(function() - shell.p_sh = saved_opts.p_sh - shell.p_shcf = saved_opts.p_shcf + cimported.p_sh = saved_opts.p_sh + cimported.p_shcf = saved_opts.p_shcf end) it('works with NULL arguments', function() @@ -123,8 +122,8 @@ describe('shell functions', function() end) it('splits and unquotes &shell and &shellcmdflag', function() - shell.p_sh = to_cstr('/Program" "Files/zsh -f') - shell.p_shcf = to_cstr('-x -o "sh word split" "-"c') + cimported.p_sh = to_cstr('/Program" "Files/zsh -f') + cimported.p_shcf = to_cstr('-x -o "sh word split" "-"c') eq({'/Program Files/zsh', '-f', 'ghi jkl', '-x', '-o', 'sh word split', diff --git a/test/unit/tempfile_spec.lua b/test/unit/tempfile_spec.lua index b3e84db132..7975d11aed 100644 --- a/test/unit/tempfile_spec.lua +++ b/test/unit/tempfile_spec.lua @@ -5,6 +5,9 @@ local os = helpers.cimport './src/nvim/os/os.h' local tempfile = helpers.cimport './src/nvim/fileio.h' describe('tempfile related functions', function() + before_each(function() + tempfile.vim_deltempdir() + end) after_each(function() tempfile.vim_deltempdir() end) |