aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-19 12:26:08 -0600
committerJosh Rahm <rahm@google.com>2022-08-19 13:06:41 -0600
commita7237662f96933efe29eed8212464571e3778cd0 (patch)
tree27930202726b4251437c8cfa53069f65b4db90dc /test/functional/ex_cmds
parent02292344929069ea63c0bb872cc22d552d86b67f (diff)
parentb2f979b30beac67906b2dd717fcb6a34f46f5e54 (diff)
downloadrneovim-tmp.tar.gz
rneovim-tmp.tar.bz2
rneovim-tmp.zip
Merge branch 'master' of https://github.com/neovim/neovim into rahmtmp
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua3
-rw-r--r--test/functional/ex_cmds/source_spec.lua65
-rw-r--r--test/functional/ex_cmds/wincmd_spec.lua13
3 files changed, 75 insertions, 6 deletions
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index 003ab64dd4..5f87c3cdd9 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -29,7 +29,6 @@ describe(':oldfiles', function()
it('shows most recently used files', function()
local screen = Screen.new(100, 5)
screen:attach()
- feed_command("set display-=msgsep")
feed_command('edit testfile1')
feed_command('edit testfile2')
feed_command('wshada')
@@ -37,7 +36,7 @@ describe(':oldfiles', function()
local oldfiles = helpers.meths.get_vvar('oldfiles')
feed_command('oldfiles')
screen:expect([[
- testfile2 |
+ |
1: ]].. add_padding(oldfiles[1]) ..[[ |
2: ]].. add_padding(oldfiles[2]) ..[[ |
|
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 13a40fcc53..163ded43f9 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -13,6 +13,10 @@ local exec_lua = helpers.exec_lua
local eval = helpers.eval
local exec_capture = helpers.exec_capture
local neq = helpers.neq
+local matches = helpers.matches
+local iswin = helpers.iswin
+local mkdir = helpers.mkdir
+local rmdir = helpers.rmdir
describe(':source', function()
before_each(function()
@@ -39,6 +43,47 @@ describe(':source', function()
os.remove(test_file)
end)
+ it("changing 'shellslash' changes the result of expand()", function()
+ if not iswin() then
+ pending("'shellslash' only works on Windows")
+ return
+ end
+ meths.set_option('shellslash', false)
+ mkdir('Xshellslash')
+
+ write_file([[Xshellslash/Xstack.vim]], [[
+ let g:stack1 = expand('<stack>')
+ set shellslash
+ let g:stack2 = expand('<stack>')
+ set noshellslash
+ let g:stack3 = expand('<stack>')
+ ]])
+
+ for _ = 1, 2 do
+ command([[source Xshellslash/Xstack.vim]])
+ matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack1'))
+ matches([[Xshellslash/Xstack%.vim]], meths.get_var('stack2'))
+ matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack3'))
+ end
+
+ write_file([[Xshellslash/Xstack.lua]], [[
+ vim.g.stack1 = vim.fn.expand('<stack>')
+ vim.o.shellslash = true
+ vim.g.stack2 = vim.fn.expand('<stack>')
+ vim.o.shellslash = false
+ vim.g.stack3 = vim.fn.expand('<stack>')
+ ]])
+
+ for _ = 1, 2 do
+ command([[source Xshellslash/Xstack.lua]])
+ matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack1'))
+ matches([[Xshellslash/Xstack%.lua]], meths.get_var('stack2'))
+ matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack3'))
+ end
+
+ rmdir('Xshellslash')
+ end)
+
it('current buffer', function()
insert([[
let a = 2
@@ -117,11 +162,18 @@ describe(':source', function()
it('can source lua files', function()
local test_file = 'test.lua'
- write_file (test_file, [[vim.g.sourced_lua = 1]])
-
- exec('source ' .. test_file)
+ write_file(test_file, [[
+ vim.g.sourced_lua = 1
+ vim.g.sfile_value = vim.fn.expand('<sfile>')
+ vim.g.stack_value = vim.fn.expand('<stack>')
+ ]])
+ command('set shellslash')
+ command('source ' .. test_file)
eq(1, eval('g:sourced_lua'))
+ matches([[/test%.lua$]], meths.get_var('sfile_value'))
+ matches([[/test%.lua$]], meths.get_var('stack_value'))
+
os.remove(test_file)
end)
@@ -153,13 +205,15 @@ describe(':source', function()
it('can source current lua buffer without argument', function()
local test_file = 'test.lua'
- write_file (test_file, [[
+ write_file(test_file, [[
vim.g.c = 10
vim.g.c = 11
vim.g.c = 12
a = [=[
\ 1
"\ 2]=]
+ vim.g.sfile_value = vim.fn.expand('<sfile>')
+ vim.g.stack_value = vim.fn.expand('<stack>')
]])
command('edit '..test_file)
@@ -167,6 +221,9 @@ describe(':source', function()
eq(12, eval('g:c'))
eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
+ eq(':source (no file)', meths.get_var('sfile_value'))
+ eq(':source (no file)', meths.get_var('stack_value'))
+
os.remove(test_file)
end)
diff --git a/test/functional/ex_cmds/wincmd_spec.lua b/test/functional/ex_cmds/wincmd_spec.lua
new file mode 100644
index 0000000000..b1f174f445
--- /dev/null
+++ b/test/functional/ex_cmds/wincmd_spec.lua
@@ -0,0 +1,13 @@
+local helpers = require("test.functional.helpers")(after_each)
+local clear = helpers.clear
+local eq = helpers.eq
+local funcs = helpers.funcs
+local command = helpers.command
+
+it(':wincmd accepts a count', function()
+ clear()
+ command('vsplit')
+ eq(1, funcs.winnr())
+ command('wincmd 2 w')
+ eq(2, funcs.winnr())
+end)