aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-10-02 00:24:19 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-10-02 01:46:16 +0200
commit6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882 (patch)
tree0ee28dd373787791a12a977a2476ae0dd38e3edb
parente9dba214eada40a2d64b89616f1799b87cab1e5e (diff)
downloadrneovim-6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882.tar.gz
rneovim-6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882.tar.bz2
rneovim-6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882.zip
test: avoid extra clear() calls
also: various other cleanup
-rw-r--r--test/functional/core/path_spec.lua53
-rw-r--r--test/functional/ui/screen_basic_spec.lua12
-rw-r--r--test/unit/path_spec.lua4
3 files changed, 29 insertions, 40 deletions
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 44e69fff7b..669bc99136 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -2,60 +2,55 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
-local get_pathsep = helpers.get_pathsep
local command = helpers.command
+local iswin = helpers.iswin
-describe("'%:p' expanding", function()
- local pathsep
+describe('path collapse', function()
local targetdir
local expected_path
- local function get_full_path()
- return eval('expand("%:p")')
- end
-
local function join_path(...)
+ local pathsep = (iswin() and '\\' or '/')
return table.concat({...}, pathsep)
end
before_each(function()
- clear()
- pathsep = get_pathsep()
targetdir = join_path('test', 'functional', 'fixtures')
- clear(join_path(targetdir, 'tty-test.c'))
- expected_path = get_full_path()
+ clear()
+ command('edit '..join_path(targetdir, 'tty-test.c'))
+ expected_path = eval('expand("%:p")')
end)
- it('given a relative path with current directory in the middle #7117', function()
- clear(join_path(targetdir, '.', 'tty-test.c'))
- eq(expected_path, get_full_path())
+ it('with /./ segment #7117', function()
+ command('edit '..join_path(targetdir, '.', 'tty-test.c'))
+ eq(expected_path, eval('expand("%:p")'))
end)
- it('given a relative path with current directory #7117', function()
- clear(join_path('.', targetdir, 'tty-test.c'))
- eq(expected_path, get_full_path())
+ it('with ./ prefix #7117', function()
+ command('edit '..join_path('.', targetdir, 'tty-test.c'))
+ eq(expected_path, eval('expand("%:p")'))
end)
- it('given a relative path with current directory to a file when changing directory #7117', function()
- clear(join_path('.', targetdir, 'tty-test.c'))
+ it('with ./ prefix, after directory change #7117', function()
+ command('edit '..join_path('.', targetdir, 'tty-test.c'))
command('cd test')
- eq(expected_path, get_full_path())
+ eq(expected_path, eval('expand("%:p")'))
end)
- it('given a relative path with directory up the tree to a file #7117', function()
- clear(join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
- eq(expected_path, get_full_path())
+ it('with /../ segment #7117', function()
+ command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
+ eq(expected_path, eval('expand("%:p")'))
end)
- it('given a different starting directory and a relative path with directory up the tree #7117', function()
+ it('with ../ and different starting directory #7117', function()
command('cd test')
- command('e ' .. join_path('..', targetdir, 'tty-test.c'))
- eq(expected_path, get_full_path())
+ command('edit '..join_path('..', targetdir, 'tty-test.c'))
+ eq(expected_path, eval('expand("%:p")'))
end)
- it('given a different starting directory and a relative path with current directory and up the tree #7117', function()
+ it('with ./../ and different starting directory #7117', function()
command('cd test')
- command('e ' .. join_path('.', '..', targetdir, 'tty-test.c'))
- eq(expected_path, get_full_path())
+ command('edit '..join_path('.', '..', targetdir, 'tty-test.c'))
+ eq(expected_path, eval('expand("%:p")'))
end)
end)
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 9032239b31..b31d9cb32f 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -120,16 +120,10 @@ describe('Screen', function()
end)
it('has correct default title with named file', function()
- local expected = 'myfile (/mydir) - NVIM'
- if iswin() then
- expected = 'myfile (C:\\mydir) - NVIM'
- end
+ local expected = (iswin() and 'myfile (C:\\mydir) - NVIM'
+ or 'myfile (/mydir) - NVIM')
command('set title')
- if iswin() then
- command('file C:\\mydir\\myfile')
- else
- command('file /mydir/myfile')
- end
+ command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
screen:expect(function()
eq(expected, screen.title)
end)
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 0400747e72..befb204d0a 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -482,14 +482,14 @@ describe('path.c', function()
eq(OK, result)
end)
- itp('works with a relative path with the current directory prefix #7117', function()
+ itp('expands "./" to the current directory #7117', function()
local force_expansion = 1
local result = vim_FullName('./unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
end)
- itp('works with a relative path with the directory name mentioned twice #7117', function()
+ itp('collapses "foo/../foo" to "foo" #7117', function()
local force_expansion = 1
local result = vim_FullName('unit-test-directory/../unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)