diff options
| author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-06 18:58:27 +0100 |
|---|---|---|
| committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-12 22:35:21 +0100 |
| commit | d41b87e070037786bf2cc4486b1839169805ee21 (patch) | |
| tree | 7a0a68bd5fea74a8a3604efe2cf281c5c679d113 /src/nvim/testdir | |
| parent | 8d1ca37d1f413b08f5ff9ceb502fa35ffd6034c7 (diff) | |
| download | rneovim-d41b87e070037786bf2cc4486b1839169805ee21.tar.gz rneovim-d41b87e070037786bf2cc4486b1839169805ee21.tar.bz2 rneovim-d41b87e070037786bf2cc4486b1839169805ee21.zip | |
vim-patch:8.1.1820: using expr->FuncRef() does not work
Problem: Using expr->FuncRef() does not work.
Solution: Make FuncRef work as a method.
https://github.com/vim/vim/commit/761fdf01c6e307c448cec2684f8b315ba6d1f454
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_method.vim | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/nvim/testdir/test_method.vim b/src/nvim/testdir/test_method.vim index ef87773924..a1fbe7af28 100644 --- a/src/nvim/testdir/test_method.vim +++ b/src/nvim/testdir/test_method.vim @@ -1,6 +1,6 @@ " Tests for ->method() -func Test_list() +func Test_list_method() let l = [1, 2, 3] call assert_equal([1, 2, 3, 4], [1, 2, 3]->add(4)) eval l->assert_equal(l) @@ -34,7 +34,7 @@ func Test_list() call assert_fails('eval l->values()', 'E715:') endfunc -func Test_dict() +func Test_dict_method() let d = #{one: 1, two: 2, three: 3} call assert_equal(d, d->copy()) @@ -71,7 +71,7 @@ func Test_dict() call assert_equal([1, 2, 3], d->values()) endfunc -func Test_string() +func Test_string_method() call assert_equal(['1', '2', '3'], '1 2 3'->split()) call assert_equal([1, 2, 3], '1 2 3'->split()->map({i, v -> str2nr(v)})) call assert_equal([65, 66, 67], 'ABC'->str2list()) @@ -81,7 +81,7 @@ func Test_string() call assert_equal('axc', 'abc'->substitute('b', 'x', '')) endfunc -func Test_append() +func Test_method_append() new eval ['one', 'two', 'three']->append(1) call assert_equal(['', 'one', 'two', 'three'], getline(1, '$')) @@ -95,4 +95,17 @@ func Test_append() exe 'bwipe! ' .. bnr endfunc +func Test_method_funcref() + func Concat(one, two, three) + return a:one .. a:two .. a:three + endfunc + let FuncRef = function('Concat') + eval 'foo'->FuncRef('bar', 'tail')->assert_equal('foobartail') + + let Partial = function('Concat', ['two']) + eval 'one'->Partial('three')->assert_equal('onetwothree') + + delfunc Concat +endfunc + " vim: shiftwidth=2 sts=2 expandtab |