aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVikram Pal <vikrampal659@gmail.com>2021-02-18 11:55:51 +0530
committerGitHub <noreply@github.com>2021-02-18 01:25:51 -0500
commit4d5dbea4f402c76de4419977f7f89d3dec572510 (patch)
tree73c801e43db2a69aabc04377fa94d1b094905bd1 /test
parentd08e983c6bfdca650406b23aa09171d1d6195084 (diff)
downloadrneovim-4d5dbea4f402c76de4419977f7f89d3dec572510.tar.gz
rneovim-4d5dbea4f402c76de4419977f7f89d3dec572510.tar.bz2
rneovim-4d5dbea4f402c76de4419977f7f89d3dec572510.zip
[RFC] ":source" sources from current buffer if filename is omitted (#11444)
Fix https://github.com/neovim/neovim/issues/8722
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/source_spec.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
new file mode 100644
index 0000000000..16d0dfb6a1
--- /dev/null
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -0,0 +1,47 @@
+local helpers = require('test.functional.helpers')(after_each)
+local command = helpers.command
+local insert = helpers.insert
+local eq = helpers.eq
+local clear = helpers.clear
+local meths = helpers.meths
+local feed = helpers.feed
+local feed_command = helpers.feed_command
+
+describe(':source', function()
+ before_each(function()
+ clear()
+ end)
+
+ it('current buffer', function()
+ insert('let a = 2')
+ command('source')
+ eq('2', meths.exec('echo a', true))
+ end)
+
+ it('selection in current buffer', function()
+ insert(
+ 'let a = 2\n'..
+ 'let a = 3\n'..
+ 'let a = 4\n')
+
+ -- Source the 2nd line only
+ feed('ggjV')
+ feed_command(':source')
+ eq('3', meths.exec('echo a', true))
+
+ -- Source from 2nd line to end of file
+ feed('ggjVG')
+ feed_command(':source')
+ eq('4', meths.exec('echo a', true))
+ end)
+
+ it('multiline heredoc command', function()
+ insert(
+ 'lua << EOF\n'..
+ 'y = 4\n'..
+ 'EOF\n')
+
+ command('source')
+ eq('4', meths.exec('echo luaeval("y")', true))
+ end)
+end)