diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-21 17:03:46 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-09-21 14:03:46 -0700 |
commit | b3e56957f8e9468497e5db508d97d7b560ccfe85 (patch) | |
tree | a268fb727adda47f9b3fd729fa3ba5b2f2fe30d7 /test/functional/legacy/assert_spec.lua | |
parent | d6f658e38fc6a44dfc43af9eef3ae09452a8c2a5 (diff) | |
download | rneovim-b3e56957f8e9468497e5db508d97d7b560ccfe85.tar.gz rneovim-b3e56957f8e9468497e5db508d97d7b560ccfe85.tar.bz2 rneovim-b3e56957f8e9468497e5db508d97d7b560ccfe85.zip |
vim-patch:8.1.0460: assert_fails() message argument #11051
Problem: assert_fails() does not take a message argument
Solution: Add the argument.
https://github.com/vim/vim/commit/1307d1c003b01b4f67524c95feb07c3d91c7c428
Diffstat (limited to 'test/functional/legacy/assert_spec.lua')
-rw-r--r-- | test/functional/legacy/assert_spec.lua | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 97c1f1405c..3cb5d97869 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -3,6 +3,7 @@ local nvim, call = helpers.meths, helpers.call local clear, eq = helpers.clear, helpers.eq local source, command = helpers.source, helpers.command local exc_exec = helpers.exc_exec +local eval = helpers.eval local function expected_errors(errors) eq(errors, nvim.get_vvar('errors')) @@ -233,20 +234,31 @@ describe('assert function:', function() -- assert_fails({cmd}, [, {error}]) describe('assert_fails', function() it('should change v:errors when error does not match v:errmsg', function() - command([[call assert_fails('xxx', {})]]) + eq(1, eval([[assert_fails('xxx', {})]])) command([[call assert_match("Expected {} but got 'E731:", v:errors[0])]]) expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"}) end) it('should not change v:errors when cmd errors', function() - call('assert_fails', 'NonexistentCmd') + eq(0, eval([[assert_fails('NonexistentCmd')]])) expected_empty() end) it('should change v:errors when cmd succeeds', function() - call('assert_fails', 'call empty("")') + eq(1, eval([[assert_fails('call empty("")', '')]])) expected_errors({'command did not fail: call empty("")'}) end) + + it('can specify and get a message about what failed', function() + eq(1, eval([[assert_fails('xxx', {}, 'stupid')]])) + command([[call assert_match("stupid: Expected {} but got 'E731:", v:errors[0])]]) + expected_errors({"stupid: Expected {} but got 'E731: using Dictionary as a String'"}) + end) + + it('can specify and get a message even when cmd succeeds', function() + eq(1, eval([[assert_fails('echo', '', 'echo command')]])) + expected_errors({'command did not fail: echo command'}) + end) end) -- assert_inrange({lower}, {upper}, {actual}[, {msg}]) |