0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 8.2.1462: Vim9: string slice not supported yet

Problem:    Vim9: string slice not supported yet.
Solution:   Add support for string slicing.
This commit is contained in:
Bram Moolenaar
2020-08-15 21:10:16 +02:00
parent 3d1cde8a2f
commit 11107bab7e
9 changed files with 183 additions and 24 deletions

View File

@@ -2074,7 +2074,7 @@ def Test_expr7_trailing()
assert_equal(123, d.key)
enddef
def Test_expr7_subscript()
def Test_expr7_string_subscript()
let lines =<< trim END
let text = 'abcdef'
assert_equal('', text[-1])
@@ -2094,6 +2094,28 @@ def Test_expr7_subscript()
assert_equal('f', text[5])
assert_equal('', text[6])
assert_equal('', text[999])
assert_equal('ábçdëf', text[0:-1])
assert_equal('ábçdëf', text[0 :-1])
assert_equal('ábçdëf', text[0: -1])
assert_equal('ábçdëf', text[0 : -1])
assert_equal('ábçdëf', text[0
:-1])
assert_equal('ábçdëf', text[0:
-1])
assert_equal('ábçdëf', text[0 : -1
])
assert_equal('bçdëf', text[1:-1])
assert_equal('çdëf', text[2:-1])
assert_equal('dëf', text[3:-1])
assert_equal('ëf', text[4:-1])
assert_equal('f', text[5:-1])
assert_equal('', text[6:-1])
assert_equal('', text[999:-1])
assert_equal('ábçd', text[:3])
assert_equal('bçdëf', text[1:])
assert_equal('ábçdëf', text[:])
END
CheckDefSuccess(lines)
CheckScriptSuccess(['vim9script'] + lines)