diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-22 22:18:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-22 22:18:17 +0200 |
commit | 64b4d73524b9a2304d89b87529cd8d3cef14b856 (patch) | |
tree | 23357c484e9ae935c37d16872d5468fd56bbb546 /src/testdir | |
parent | 448262176b382c63bd2faa9a1354670a4eede36b (diff) |
patch 8.1.1911: more functions can be used as methodsv8.1.1911
Problem: More functions can be used as methods.
Solution: Make a few more functions usable as a method.
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test69.in | 15 | ||||
-rw-r--r-- | src/testdir/test69.ok | 8 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 32 |
3 files changed, 31 insertions, 24 deletions
diff --git a/src/testdir/test69.in b/src/testdir/test69.in index 2510c122ba..29dad8bb9d 100644 --- a/src/testdir/test69.in +++ b/src/testdir/test69.in @@ -165,21 +165,6 @@ ENDTEST x STARTTEST -:let a = '.é.' " one char of two bytes -:let b = '.é.' " normal e with composing char -/^byteidx -:put =string([byteidx(a, 0), byteidx(a, 1), byteidx(a, 2), byteidx(a, 3), byteidx(a, 4)]) -:put =string([byteidx(b, 0), byteidx(b, 1), byteidx(b, 2), byteidx(b, 3), byteidx(b, 4)]) -/^byteidxcomp -:put =string([byteidxcomp(a, 0), byteidxcomp(a, 1), byteidxcomp(a, 2), byteidxcomp(a, 3), byteidxcomp(a, 4)]) -:let b = '.é.' -:put =string([byteidxcomp(b, 0), byteidxcomp(b, 1), byteidxcomp(b, 2), byteidxcomp(b, 3), byteidxcomp(b, 4), byteidxcomp(b, 5)]) -ENDTEST - -byteidx -byteidxcomp - -STARTTEST /^substitute :let y = substitute('123', '\zs', 'a', 'g') | put =y ENDTEST diff --git a/src/testdir/test69.ok b/src/testdir/test69.ok index af8befb0c7..b80d2bb2cd 100644 --- a/src/testdir/test69.ok +++ b/src/testdir/test69.ok @@ -153,14 +153,6 @@ aaa áx -byteidx -[0, 1, 3, 4, -1] -[0, 1, 4, 5, -1] -byteidxcomp -[0, 1, 3, 4, -1] -[0, 1, 2, 4, 5, -1] - - substitute a1a2a3a diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 5249d4e946..6f65ae0866 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -872,7 +872,7 @@ func Test_byte2line_line2byte() set fileformat=mac call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1], - \ map(range(-1, 8), 'byte2line(v:val)')) + \ map(range(-1, 8), 'v:val->byte2line()')) call assert_equal([-1, -1, 1, 3, 6, 8, -1], \ map(range(-1, 5), 'line2byte(v:val)')) @@ -895,6 +895,34 @@ func Test_byte2line_line2byte() bw! endfunc +func Test_byteidx() + let a = '.é.' " one char of two bytes + call assert_equal(0, byteidx(a, 0)) + call assert_equal(0, byteidxcomp(a, 0)) + call assert_equal(1, byteidx(a, 1)) + call assert_equal(1, byteidxcomp(a, 1)) + call assert_equal(3, byteidx(a, 2)) + call assert_equal(3, byteidxcomp(a, 2)) + call assert_equal(4, byteidx(a, 3)) + call assert_equal(4, byteidxcomp(a, 3)) + call assert_equal(-1, byteidx(a, 4)) + call assert_equal(-1, byteidxcomp(a, 4)) + + let b = '.é.' " normal e with composing char + call assert_equal(0, b->byteidx(0)) + call assert_equal(1, b->byteidx(1)) + call assert_equal(4, b->byteidx(2)) + call assert_equal(5, b->byteidx(3)) + call assert_equal(-1, b->byteidx(4)) + + call assert_equal(0, b->byteidxcomp(0)) + call assert_equal(1, b->byteidxcomp(1)) + call assert_equal(2, b->byteidxcomp(2)) + call assert_equal(4, b->byteidxcomp(3)) + call assert_equal(5, b->byteidxcomp(4)) + call assert_equal(-1, b->byteidxcomp(5)) +endfunc + func Test_count() let l = ['a', 'a', 'A', 'b'] call assert_equal(2, count(l, 'a')) @@ -1506,6 +1534,7 @@ endfunc func Test_call() call assert_equal(3, call('len', [123])) + call assert_equal(3, 'len'->call([123])) call assert_fails("call call('len', 123)", 'E714:') call assert_equal(0, call('', [])) @@ -1513,6 +1542,7 @@ func Test_call() return len(self.data) endfunction let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} + eval mydict.len->call([], mydict)->assert_equal(4) call assert_fails("call call('Mylen', [], 0)", 'E715:') endfunc |