diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-07 01:28:52 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-12 22:35:22 +0100 |
commit | 287a77ef51a7a12813d3fa6e1c49c595e5951ba5 (patch) | |
tree | 2314f398ac41254032b9c60a143470577242b672 /test/functional/legacy/assert_spec.lua | |
parent | f03dd22f0d37af88f40a27c694c3265026178e80 (diff) | |
download | rneovim-287a77ef51a7a12813d3fa6e1c49c595e5951ba5.tar.gz rneovim-287a77ef51a7a12813d3fa6e1c49c595e5951ba5.tar.bz2 rneovim-287a77ef51a7a12813d3fa6e1c49c595e5951ba5.zip |
vim-patch:8.1.1861: only some assert functions can be used as a method
Problem: Only some assert functions can be used as a method.
Solution: Allow using most assert functions as a method.
https://github.com/vim/vim/commit/24278d2407dfbc8d93eb36593cdd006ff5d86f94
Port tests to assert_spec.lua.
Diffstat (limited to 'test/functional/legacy/assert_spec.lua')
-rw-r--r-- | test/functional/legacy/assert_spec.lua | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 515d6d91b8..40050f6ce8 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -26,6 +26,14 @@ describe('assert function:', function() call('assert_beeps', 'normal 0') expected_errors({'command did not beep: normal 0'}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(0, 'normal h'->assert_beeps()) + call assert_equal(1, 'normal 0'->assert_beeps()) + ]] + expected_errors({tmpname .. ' line 2: command did not beep: normal 0'}) + end) end) -- assert_equal({expected}, {actual}, [, {msg}]) @@ -133,6 +141,14 @@ describe('assert function:', function() call('assert_false', {}) expected_errors({'Expected False but got []'}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(0, v:false->assert_false()) + call assert_equal(1, 123->assert_false()) + ]] + expected_errors({tmpname .. ' line 2: Expected False but got 123'}) + end) end) -- assert_true({actual}, [, {msg}]) @@ -148,6 +164,14 @@ describe('assert function:', function() eq(1, call('assert_true', 1.5)) expected_errors({'Expected True but got 1.5'}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(0, v:true->assert_true()) + call assert_equal(1, 0->assert_true()) + ]] + expected_errors({tmpname .. ' line 2: Expected True but got 0'}) + end) end) describe('v:errors', function() @@ -223,6 +247,15 @@ describe('assert function:', function() call('assert_match', 'bar.*foo', 'foobar', 'wrong') expected_errors({"wrong: Pattern 'bar.*foo' does not match 'foobar'"}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(1, 'foobar'->assert_match('bar.*foo', 'wrong')) + ]] + expected_errors({ + tmpname .. " line 1: wrong: Pattern 'bar.*foo' does not match 'foobar'" + }) + end) end) -- assert_notmatch({pat}, {text}[, {msg}]) @@ -237,6 +270,13 @@ describe('assert function:', function() call('assert_notmatch', 'foo', 'foobar') expected_errors({"Pattern 'foo' does match 'foobar'"}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(1, 'foobar'->assert_notmatch('foo')) + ]] + expected_errors({tmpname .. " line 1: Pattern 'foo' does match 'foobar'"}) + end) end) -- assert_fails({cmd}, [, {error}]) @@ -267,6 +307,15 @@ describe('assert function:', function() eq(1, eval([[assert_fails('echo', '', 'echo command')]])) expected_errors({'command did not fail: echo command'}) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(1, 'echo'->assert_fails('', 'echo command')) + ]] + expected_errors({ + tmpname .. ' line 1: command did not fail: echo command' + }) + end) end) -- assert_inrange({lower}, {upper}, {actual}[, {msg}]) @@ -292,6 +341,15 @@ describe('assert function:', function() eq('Vim(call):E119: Not enough arguments for function: assert_inrange', exc_exec("call assert_inrange(1, 1)")) end) + + it('can be used as a method', function() + local tmpname = source [[ + call assert_equal(0, 5->assert_inrange(5, 7)) + call assert_equal(0, 7->assert_inrange(5, 7)) + call assert_equal(1, 8->assert_inrange(5, 7)) + ]] + expected_errors({tmpname .. ' line 3: Expected range 5 - 7, but got 8'}) + end) end) -- assert_report({msg}) |