aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/exit_spec.lua
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2016-12-01 15:00:58 +0100
committerGitHub <noreply@github.com>2016-12-01 15:00:58 +0100
commitd2e8c76dc22460ddfde80477dd93aab3d5866506 (patch)
tree4eb42bd2ae42fe8b683b3a4ea5ecb1b1a788183f /test/functional/core/exit_spec.lua
parent5194e3bc458eaa43871398bacea01e2d8b30b7e6 (diff)
parentdf2ffe48ce71ec2653bd74a566a8f4ef585e1d55 (diff)
downloadrneovim-d2e8c76dc22460ddfde80477dd93aab3d5866506.tar.gz
rneovim-d2e8c76dc22460ddfde80477dd93aab3d5866506.tar.bz2
rneovim-d2e8c76dc22460ddfde80477dd93aab3d5866506.zip
Merge PR #5651 from mhinz/vv/exitval
Diffstat (limited to 'test/functional/core/exit_spec.lua')
-rw-r--r--test/functional/core/exit_spec.lua46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
new file mode 100644
index 0000000000..3fb39f3e78
--- /dev/null
+++ b/test/functional/core/exit_spec.lua
@@ -0,0 +1,46 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local command = helpers.command
+local eval = helpers.eval
+local eq, neq = helpers.eq, helpers.neq
+local run = helpers.run
+
+describe('v:exiting', function()
+ local cid
+
+ before_each(function()
+ helpers.clear()
+ cid = helpers.nvim('get_api_info')[1]
+ end)
+
+ it('defaults to v:null', function()
+ eq(1, eval('v:exiting is v:null'))
+ end)
+
+ it('is 0 on normal exit', function()
+ local function on_setup()
+ command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
+ command('autocmd VimLeave * call rpcrequest('..cid..', "")')
+ command('quit')
+ end
+ local function on_request()
+ eq(0, eval('v:exiting'))
+ return ''
+ end
+ run(on_request, nil, on_setup)
+ end)
+
+ it('is non-zero after :cquit', function()
+ local function on_setup()
+ command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
+ command('autocmd VimLeave * call rpcrequest('..cid..', "")')
+ command('cquit')
+ end
+ local function on_request()
+ neq(0, eval('v:exiting'))
+ return ''
+ end
+ run(on_request, nil, on_setup)
+ end)
+
+end)