diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-04 17:35:53 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-04 17:35:53 +0200 |
commit | a74e4946de074d2916e3d6004f7fa1810d12dda9 (patch) | |
tree | 7c9ef20c9c2b2aab3ce363697623e290a456ce6d /src/testdir/test_method.vim | |
parent | e4ce825a55ad2445a212ce30837a3af566b7af6b (diff) | |
download | vim-git-a74e4946de074d2916e3d6004f7fa1810d12dda9.tar.gz |
patch 8.1.1809: more functions can be used as a methodv8.1.1809
Problem: More functions can be used as a method.
Solution: Add has_key(), split(), str2list(), etc.
Diffstat (limited to 'src/testdir/test_method.vim')
-rw-r--r-- | src/testdir/test_method.vim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/testdir/test_method.vim b/src/testdir/test_method.vim index cc0fe5d05..93918c83b 100644 --- a/src/testdir/test_method.vim +++ b/src/testdir/test_method.vim @@ -46,6 +46,7 @@ func Test_dict() call assert_equal(2, d->get('two')) call assert_fails("let x = d->index(2)", 'E897:') call assert_fails("let x = d->insert(0)", 'E899:') + call assert_true(d->has_key('two')) call assert_equal([['one', 1], ['two', 2], ['three', 3]], d->items()) call assert_fails("let x = d->join()", 'E714:') call assert_equal(['one', 'two', 'three'], d->keys()) @@ -65,6 +66,16 @@ func Test_dict() call assert_equal([1, 2, 3], d->values()) endfunc +func Test_string() + 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()) + call assert_equal(3, 'ABC'->strlen()) + call assert_equal('a^Mb^[c', "a\rb\ec"->strtrans()) + call assert_equal(4, "aあb"->strwidth()) + call assert_equal('axc', 'abc'->substitute('b', 'x', '')) +endfunc + func Test_append() new eval ['one', 'two', 'three']->append(1) |