aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/eval/timer_spec.lua15
-rw-r--r--test/functional/ex_cmds/drop_spec.lua80
-rw-r--r--test/functional/helpers.lua13
-rw-r--r--test/functional/legacy/expand_spec.lua15
-rw-r--r--test/functional/legacy/packadd_spec.lua350
-rw-r--r--test/functional/options/autochdir_spec.lua18
-rw-r--r--test/functional/options/defaults_spec.lua6
-rw-r--r--test/functional/terminal/tui_spec.lua69
-rw-r--r--test/functional/viml/lang_spec.lua4
-rw-r--r--test/unit/os/fs_spec.lua29
-rw-r--r--test/unit/tempfile_spec.lua2
11 files changed, 575 insertions, 26 deletions
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua
index a31e942cdf..2f83edb9e4 100644
--- a/test/functional/eval/timer_spec.lua
+++ b/test/functional/eval/timer_spec.lua
@@ -22,6 +22,14 @@ describe('timers', function()
eq(1,eval("g:val"))
end)
+ it('works one-shot when repeat=0', function()
+ execute("call timer_start(50, 'MyHandler', {'repeat': 0})")
+ eq(0,eval("g:val"))
+ run(nil, nil, nil, 200)
+ eq(1,eval("g:val"))
+ end)
+
+
it('works with repeat two', function()
execute("call timer_start(50, 'MyHandler', {'repeat': 2})")
eq(0,eval("g:val"))
@@ -37,6 +45,13 @@ describe('timers', function()
eq(2,eval("g:val"))
end)
+ it('works with zero timeout', function()
+ -- timer_start does still not invoke the callback immediately
+ eq(0,eval("[timer_start(0, 'MyHandler', {'repeat': 1000}), g:val][1]"))
+ run(nil, nil, nil, 300)
+ eq(1000,eval("g:val"))
+ end)
+
it('can be started during sleep', function()
nvim_async("command", "sleep 10")
-- this also tests that remote requests works during sleep
diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua
new file mode 100644
index 0000000000..16b194dd7d
--- /dev/null
+++ b/test/functional/ex_cmds/drop_spec.lua
@@ -0,0 +1,80 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
+
+describe(":drop", function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(35, 10)
+ screen:attach()
+ screen:set_default_attr_ignore({{bold=true, foreground=Screen.colors.Blue}})
+ screen:set_default_attr_ids({
+ [1] = {bold = true, reverse = true},
+ [2] = {reverse = true},
+ [3] = {bold = true},
+ })
+ execute("set laststatus=2")
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it("works like :e when called with only one window open", function()
+ execute("drop tmp1.vim")
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ {1:tmp1.vim }|
+ "tmp1.vim" [New File] |
+ ]])
+ end)
+
+ it("switches to an open window showing the buffer", function()
+ execute("edit tmp1")
+ execute("vsplit")
+ execute("edit tmp2")
+ execute("drop tmp1")
+ screen:expect([[
+ {2:|}^ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ {2:tmp2 }{1:tmp1 }|
+ :drop tmp1 |
+ ]])
+ end)
+
+ it("splits off a new window when a buffer can't be abandoned", function()
+ execute("edit tmp1")
+ execute("vsplit")
+ execute("edit tmp2")
+ feed("iABC<esc>")
+ execute("drop tmp3")
+ screen:expect([[
+ ^ {2:|} |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ {1:tmp3 }{2:|}~ |
+ ABC {2:|}~ |
+ ~ {2:|}~ |
+ ~ {2:|}~ |
+ {2:tmp2 [+] tmp1 }|
+ "tmp3" [New File] |
+ ]])
+ end)
+
+end)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 6e750b31a9..02109d0889 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -300,14 +300,18 @@ local function curbuf(method, ...)
end
local function wait()
+ -- Execute 'vim_eval' (a deferred function) to block
+ -- until all pending input is processed.
session:request('vim_eval', '1')
end
+-- sleeps the test runner (_not_ the nvim instance)
+local function sleep(timeout)
+ run(nil, nil, nil, timeout)
+end
+
local function curbuf_contents()
- -- Before inspecting the buffer, execute 'vim_eval' to wait until all
- -- previously sent keys are processed(vim_eval is a deferred function, and
- -- only processed after all input)
- wait()
+ wait() -- Before inspecting the buffer, process all input.
return table.concat(curbuf('get_lines', 0, -1, true), '\n')
end
@@ -441,6 +445,7 @@ return function(after_each)
curtab = curtab,
curbuf_contents = curbuf_contents,
wait = wait,
+ sleep = sleep,
set_session = set_session,
write_file = write_file,
os_name = os_name,
diff --git a/test/functional/legacy/expand_spec.lua b/test/functional/legacy/expand_spec.lua
index 5a2d46706a..7bf6fb67dc 100644
--- a/test/functional/legacy/expand_spec.lua
+++ b/test/functional/legacy/expand_spec.lua
@@ -39,12 +39,17 @@ describe('expand file name', function()
next Xdir?/*/file
call assert_equal('Xdir3/Xdir4/file', expand('%'))
- next! Xdir?/*/nofile
- call assert_equal('Xdir?/*/nofile', expand('%'))
+ if has('unix')
+ next! Xdir?/*/nofile
+ call assert_equal('Xdir?/*/nofile', expand('%'))
+ endif
+ " Edit another file, on MS-Windows the swap file would be in use and can't
+ " be deleted
+ edit foo
- call delete('Xdir1', 'rf')
- call delete('Xdir2', 'rf')
- call delete('Xdir3', 'rf')
+ call assert_equal(0, delete('Xdir1', 'rf'))
+ call assert_equal(0, delete('Xdir2', 'rf'))
+ call assert_equal(0, delete('Xdir3', 'rf'))
endfunc
func Test_with_tilde()
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
new file mode 100644
index 0000000000..b2ed39f288
--- /dev/null
+++ b/test/functional/legacy/packadd_spec.lua
@@ -0,0 +1,350 @@
+-- Tests for 'packpath' and :packadd
+
+local helpers = require('test.functional.helpers')(after_each)
+local clear, source, execute = helpers.clear, helpers.source, helpers.execute
+local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
+local feed = helpers.feed
+
+local function expected_empty()
+ eq({}, nvim.get_vvar('errors'))
+end
+
+describe('packadd', function()
+ before_each(function()
+ clear()
+
+ source([=[
+ func SetUp()
+ let s:topdir = expand('%:p:h') . '/Xdir'
+ exe 'set packpath=' . s:topdir
+ let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
+ endfunc
+
+ func TearDown()
+ call delete(s:topdir, 'rf')
+ endfunc
+
+ func Test_packadd()
+ call mkdir(s:plugdir . '/plugin', 'p')
+ call mkdir(s:plugdir . '/ftdetect', 'p')
+ call mkdir(s:plugdir . '/after', 'p')
+ set rtp&
+ let rtp = &rtp
+ filetype on
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 42')
+ wq
+
+ exe 'split ' . s:plugdir . '/ftdetect/test.vim'
+ call setline(1, 'let g:ftdetect_works = 17')
+ wq
+
+ packadd mytest
+
+ call assert_true(42, g:plugin_works)
+ call assert_true(17, g:ftdetect_works)
+ call assert_true(len(&rtp) > len(rtp))
+ call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
+ call assert_true(&rtp =~ (s:plugdir . '/after$'))
+
+ " Check exception
+ call assert_fails("packadd directorynotfound", 'E919:')
+ call assert_fails("packadd", 'E471:')
+ endfunc
+
+ func Test_packadd_noload()
+ call mkdir(s:plugdir . '/plugin', 'p')
+ call mkdir(s:plugdir . '/syntax', 'p')
+ set rtp&
+ let rtp = &rtp
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 42')
+ wq
+ let g:plugin_works = 0
+
+ packadd! mytest
+
+ call assert_true(len(&rtp) > len(rtp))
+ call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
+ call assert_equal(0, g:plugin_works)
+
+ " check the path is not added twice
+ let new_rtp = &rtp
+ packadd! mytest
+ call assert_equal(new_rtp, &rtp)
+ endfunc
+
+ func Test_packloadall()
+ " plugin foo with an autoload directory
+ let fooplugindir = &packpath . '/pack/mine/start/foo/plugin'
+ call mkdir(fooplugindir, 'p')
+ call writefile(['let g:plugin_foo_number = 1234',
+ \ 'let g:plugin_foo_auto = bbb#value',
+ \ 'let g:plugin_extra_auto = extra#value'], fooplugindir . '/bar.vim')
+ let fooautodir = &packpath . '/pack/mine/start/foo/autoload'
+ call mkdir(fooautodir, 'p')
+ call writefile(['let bar#value = 77'], fooautodir . '/bar.vim')
+
+ " plugin aaa with an autoload directory
+ let aaaplugindir = &packpath . '/pack/mine/start/aaa/plugin'
+ call mkdir(aaaplugindir, 'p')
+ call writefile(['let g:plugin_aaa_number = 333',
+ \ 'let g:plugin_aaa_auto = bar#value'], aaaplugindir . '/bbb.vim')
+ let aaaautodir = &packpath . '/pack/mine/start/aaa/autoload'
+ call mkdir(aaaautodir, 'p')
+ call writefile(['let bbb#value = 55'], aaaautodir . '/bbb.vim')
+
+ " plugin extra with only an autoload directory
+ let extraautodir = &packpath . '/pack/mine/start/extra/autoload'
+ call mkdir(extraautodir, 'p')
+ call writefile(['let extra#value = 99'], extraautodir . '/extra.vim')
+
+ packloadall
+ call assert_equal(1234, g:plugin_foo_number)
+ call assert_equal(55, g:plugin_foo_auto)
+ call assert_equal(99, g:plugin_extra_auto)
+ call assert_equal(333, g:plugin_aaa_number)
+ call assert_equal(77, g:plugin_aaa_auto)
+
+ " only works once
+ call writefile(['let g:plugin_bar_number = 4321'],
+ \ fooplugindir . '/bar2.vim')
+ packloadall
+ call assert_false(exists('g:plugin_bar_number'))
+
+ " works when ! used
+ packloadall!
+ call assert_equal(4321, g:plugin_bar_number)
+ endfunc
+
+ func Test_helptags()
+ let docdir1 = &packpath . '/pack/mine/start/foo/doc'
+ let docdir2 = &packpath . '/pack/mine/start/bar/doc'
+ call mkdir(docdir1, 'p')
+ call mkdir(docdir2, 'p')
+ call writefile(['look here: *look-here*'], docdir1 . '/bar.txt')
+ call writefile(['look away: *look-away*'], docdir2 . '/foo.txt')
+ exe 'set rtp=' . &packpath . '/pack/mine/start/foo,' . &packpath . '/pack/mine/start/bar'
+
+ helptags ALL
+
+ let tags1 = readfile(docdir1 . '/tags')
+ call assert_true(tags1[0] =~ 'look-here')
+ let tags2 = readfile(docdir2 . '/tags')
+ call assert_true(tags2[0] =~ 'look-away')
+ endfunc
+
+ func Test_colorscheme()
+ let colordirrun = &packpath . '/runtime/colors'
+ let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+ let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+ call mkdir(colordirrun, 'p')
+ call mkdir(colordirstart, 'p')
+ call mkdir(colordiropt, 'p')
+ call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+ call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+ call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ colorscheme one
+ call assert_equal(1, g:found_one)
+ colorscheme two
+ call assert_equal(1, g:found_two)
+ colorscheme three
+ call assert_equal(1, g:found_three)
+ endfunc
+
+ func Test_runtime()
+ let rundir = &packpath . '/runtime/extra'
+ let startdir = &packpath . '/pack/mine/start/foo/extra'
+ let optdir = &packpath . '/pack/mine/opt/bar/extra'
+ call mkdir(rundir, 'p')
+ call mkdir(startdir, 'p')
+ call mkdir(optdir, 'p')
+ call writefile(['let g:sequence .= "run"'], rundir . '/bar.vim')
+ call writefile(['let g:sequence .= "start"'], startdir . '/bar.vim')
+ call writefile(['let g:sequence .= "foostart"'], startdir . '/foo.vim')
+ call writefile(['let g:sequence .= "opt"'], optdir . '/bar.vim')
+ call writefile(['let g:sequence .= "xxxopt"'], optdir . '/xxx.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ let g:sequence = ''
+ runtime extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime START extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime OPT extra/bar.vim
+ call assert_equal('opt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime! PACK extra/bar.vim
+ call assert_equal('startopt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+
+ let g:sequence = ''
+ runtime ALL extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime ALL extra/foo.vim
+ call assert_equal('foostart', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/bar.vim
+ call assert_equal('runstartopt', g:sequence)
+ endfunc
+ ]=])
+ call('SetUp')
+ end)
+
+ after_each(function()
+ call('TearDown')
+ end)
+
+ it('is working', function()
+ call('Test_packadd')
+ expected_empty()
+ end)
+
+ it('works with packadd!', function()
+ call('Test_packadd_noload')
+ expected_empty()
+ end)
+
+ it('works with :packloadall', function()
+ call('Test_packloadall')
+ expected_empty()
+ end)
+
+ it('works with helptags', function()
+ call('Test_helptags')
+ expected_empty()
+ end)
+
+ it('works with colorschemes', function()
+ call('Test_colorscheme')
+ expected_empty()
+ end)
+
+ it('works with :runtime [what]', function()
+ call('Test_runtime')
+ expected_empty()
+ end)
+
+ describe('command line completion', function()
+ local Screen = require('test.functional.ui.screen')
+ local screen
+
+ before_each(function()
+ screen = Screen.new(30, 5)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [1] = {
+ foreground = Screen.colors.Black,
+ background = Screen.colors.Yellow,
+ },
+ [2] = {bold = true, reverse = true}
+ })
+ local NonText = Screen.colors.Blue
+ screen:set_default_attr_ignore({{}, {bold=true, foreground=NonText}})
+
+ execute([[let optdir1 = &packpath . '/pack/mine/opt']])
+ execute([[let optdir2 = &packpath . '/pack/candidate/opt']])
+ execute([[call mkdir(optdir1 . '/pluginA', 'p')]])
+ execute([[call mkdir(optdir1 . '/pluginC', 'p')]])
+ execute([[call mkdir(optdir2 . '/pluginB', 'p')]])
+ execute([[call mkdir(optdir2 . '/pluginC', 'p')]])
+ end)
+
+ it('works', function()
+ feed(':packadd <Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {1:pluginA}{2: pluginB pluginC }|
+ :packadd pluginA^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:pluginA }{1:pluginB}{2: pluginC }|
+ :packadd pluginB^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:pluginA pluginB }{1:pluginC}{2: }|
+ :packadd pluginC^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:pluginA pluginB pluginC }|
+ :packadd ^ |
+ ]=])
+ end)
+
+ it('works for colorschemes', function()
+ source([[
+ let colordirrun = &packpath . '/runtime/colors'
+ let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+ let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+ call mkdir(colordirrun, 'p')
+ call mkdir(colordirstart, 'p')
+ call mkdir(colordiropt, 'p')
+ call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+ call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+ call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+ exe 'set rtp=' . &packpath . '/runtime']])
+
+ feed(':colorscheme <Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {1:one}{2: three two }|
+ :colorscheme one^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:one }{1:three}{2: two }|
+ :colorscheme three^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:one three }{1:two}{2: }|
+ :colorscheme two^ |
+ ]=])
+ feed('<Tab>')
+ screen:expect([=[
+ |
+ ~ |
+ ~ |
+ {2:one three two }|
+ :colorscheme ^ |
+ ]=])
+ end)
+ end)
+end)
diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua
new file mode 100644
index 0000000000..0e293761ad
--- /dev/null
+++ b/test/functional/options/autochdir_spec.lua
@@ -0,0 +1,18 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local eq = helpers.eq
+local getcwd = helpers.funcs.getcwd
+
+describe("'autochdir'", function()
+ it('given on the shell gets processed properly', function()
+ local targetdir = 'test/functional/fixtures'
+
+ -- By default 'autochdir' is off, thus getcwd() returns the repo root.
+ clear(targetdir..'/tty-test.c')
+ local rootdir = getcwd()
+
+ -- With 'autochdir' on, we should get the directory of tty-test.c.
+ clear('--cmd', 'set autochdir', targetdir..'/tty-test.c')
+ eq(rootdir..'/'..targetdir, getcwd())
+ end)
+end)
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index ed978cd17e..a36939b0bd 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
+local eval, eq = helpers.eval, helpers.eq
local execute = helpers.execute
local function init_session(...)
@@ -15,10 +15,6 @@ local function init_session(...)
end
describe('startup defaults', function()
- before_each(function()
- clear()
- end)
-
describe(':filetype', function()
local function expect_filetype(expected)
local screen = Screen.new(48, 4)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 91789d6575..e6586c7892 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -301,3 +301,72 @@ describe('tui focus event handling', function()
]])
end)
end)
+
+-- These tests require `thelpers` because --headless/--embed
+-- does not initialize the TUI.
+describe("tui 't_Co' (terminal colors)", function()
+ local screen
+ local is_linux = (helpers.eval("system('uname') =~? 'linux'") == 1)
+
+ local function assert_term_colors(term, colorterm, maxcolors)
+ helpers.clear({env={TERM=term}, args={}})
+ -- This is ugly because :term/termopen() forces TERM=xterm-256color.
+ -- TODO: Revisit this after jobstart/termopen accept `env` dict.
+ screen = thelpers.screen_setup(0, string.format(
+ [=[['sh', '-c', 'TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=],
+ term,
+ (colorterm ~= nil and "COLORTERM="..colorterm or ""),
+ helpers.nvim_prog))
+
+ thelpers.feed_data(":echo &t_Co\n")
+ screen:expect(string.format([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ %-3s |
+ -- TERMINAL -- |
+ ]], tostring(maxcolors and maxcolors or "")))
+ end
+
+ it("unknown TERM sets empty 't_Co'", function()
+ assert_term_colors("yet-another-term", nil, nil)
+ end)
+
+ it("unknown TERM with COLORTERM=screen-256color uses 256 colors", function()
+ assert_term_colors("yet-another-term", "screen-256color", 256)
+ end)
+
+ it("TERM=linux uses 8 colors", function()
+ if is_linux then
+ assert_term_colors("linux", nil, 8)
+ else
+ pending()
+ end
+ end)
+
+ it("TERM=screen uses 8 colors", function()
+ if is_linux then
+ assert_term_colors("screen", nil, 8)
+ else
+ pending()
+ end
+ end)
+
+ it("TERM=screen COLORTERM=screen-256color uses 256 colors", function()
+ assert_term_colors("screen", "screen-256color", 256)
+ end)
+
+ it("TERM=yet-another-term COLORTERM=screen-256color uses 256 colors", function()
+ assert_term_colors("screen", "screen-256color", 256)
+ end)
+
+ it("TERM=xterm uses 256 colors", function()
+ assert_term_colors("xterm", nil, 256)
+ end)
+
+ it("TERM=xterm-256color uses 256 colors", function()
+ assert_term_colors("xterm-256color", nil, 256)
+ end)
+end)
diff --git a/test/functional/viml/lang_spec.lua b/test/functional/viml/lang_spec.lua
index 240fe58402..a27e18f695 100644
--- a/test/functional/viml/lang_spec.lua
+++ b/test/functional/viml/lang_spec.lua
@@ -2,10 +2,10 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local execute, source = helpers.execute, helpers.source
-describe('turkish', function()
+describe('viml', function()
before_each(clear)
- it('applies locale to \'i\' in `<SID>` comparison', function()
+ it('parses `<SID>` with turkish locale', function()
execute('lang ctype tr_TR.UTF-8')
if string.find(eval('v:errmsg'), '^E197: ') then
pending("Locale tr_TR.UTF-8 not supported")
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index cc10b0cfa4..7e7eddb6fc 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -75,6 +75,8 @@ describe('fs function', function()
io.open('unit-test-directory/test_2.file', 'w').close()
lfs.link('test.file', 'unit-test-directory/test_link.file', true)
+
+ lfs.link('non_existing_file.file', 'unit-test-directory/test_broken_link.file', true)
-- Since the tests are executed, they are called by an executable. We use
-- that executable for several asserts.
absolute_executable = arg[0]
@@ -88,6 +90,7 @@ describe('fs function', function()
os.remove('unit-test-directory/test_2.file')
os.remove('unit-test-directory/test_link.file')
os.remove('unit-test-directory/test_hlink.file')
+ os.remove('unit-test-directory/test_broken_link.file')
lfs.rmdir('unit-test-directory')
end)
@@ -363,8 +366,8 @@ describe('fs function', function()
end)
describe('file operations', function()
- local function os_file_exists(filename)
- return fs.os_file_exists((to_cstr(filename)))
+ local function os_path_exists(filename)
+ return fs.os_path_exists((to_cstr(filename)))
end
local function os_rename(path, new_path)
return fs.os_rename((to_cstr(path)), (to_cstr(new_path)))
@@ -421,13 +424,21 @@ describe('fs function', function()
return fs.os_write(fd, data, data and #data or 0)
end
- describe('os_file_exists', function()
+ describe('os_path_exists', function()
it('returns false when given a non-existing file', function()
- eq(false, (os_file_exists('non-existing-file')))
+ eq(false, (os_path_exists('non-existing-file')))
end)
it('returns true when given an existing file', function()
- eq(true, (os_file_exists('unit-test-directory/test.file')))
+ eq(true, (os_path_exists('unit-test-directory/test.file')))
+ end)
+
+ it('returns false when given a broken symlink', function()
+ eq(false, (os_path_exists('unit-test-directory/test_broken_link.file')))
+ end)
+
+ it('returns true when given a directory', function()
+ eq(true, (os_path_exists('unit-test-directory')))
end)
end)
@@ -437,8 +448,8 @@ describe('fs function', function()
it('can rename file if destination file does not exist', function()
eq(OK, (os_rename(test, not_exist)))
- eq(false, (os_file_exists(test)))
- eq(true, (os_file_exists(not_exist)))
+ eq(false, (os_path_exists(test)))
+ eq(true, (os_path_exists(not_exist)))
eq(OK, (os_rename(not_exist, test))) -- restore test file
end)
@@ -454,8 +465,8 @@ describe('fs function', function()
file:close()
eq(OK, (os_rename(other, test)))
- eq(false, (os_file_exists(other)))
- eq(true, (os_file_exists(test)))
+ eq(false, (os_path_exists(other)))
+ eq(true, (os_path_exists(test)))
file = io.open(test, 'r')
eq('other', (file:read('*all')))
file:close()
diff --git a/test/unit/tempfile_spec.lua b/test/unit/tempfile_spec.lua
index 7975d11aed..cf0d78b7a7 100644
--- a/test/unit/tempfile_spec.lua
+++ b/test/unit/tempfile_spec.lua
@@ -43,7 +43,7 @@ describe('tempfile related functions', function()
it('generate name of non-existing file', function()
local file = vim_tempname()
assert.truthy(file)
- assert.False(os.os_file_exists(file))
+ assert.False(os.os_path_exists(file))
end)
it('generate different names on each call', function()