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

patch 8.2.1463: Vim9: list slice not supported yet

Problem:    Vim9: list slice not supported yet.
Solution:   Add support for list slicing.
This commit is contained in:
Bram Moolenaar
2020-08-15 22:14:53 +02:00
parent 11107bab7e
commit ed5918771f
9 changed files with 175 additions and 57 deletions

View File

@@ -2121,6 +2121,34 @@ def Test_expr7_string_subscript()
CheckScriptSuccess(['vim9script'] + lines)
enddef
def Test_expr7_list_subscript()
let lines =<< trim END
let list = [0, 1, 2, 3, 4]
assert_equal(0, list[0])
assert_equal(4, list[4])
assert_equal(4, list[-1])
assert_equal(0, list[-5])
assert_equal([0, 1, 2, 3, 4], list[0:4])
assert_equal([0, 1, 2, 3, 4], list[:])
assert_equal([1, 2, 3, 4], list[1:])
assert_equal([2, 3, 4], list[2:-1])
assert_equal([4], list[4:-1])
assert_equal([], list[5:-1])
assert_equal([], list[999:-1])
assert_equal([0, 1, 2, 3], list[0:3])
assert_equal([0], list[0:0])
assert_equal([0, 1, 2, 3, 4], list[0:-1])
assert_equal([0, 1, 2], list[0:-3])
assert_equal([0], list[0:-5])
assert_equal([], list[0:-6])
assert_equal([], list[0:-99])
END
CheckDefSuccess(lines)
CheckScriptSuccess(['vim9script'] + lines)
enddef
def Test_expr7_subscript_linebreak()
let range = range(
3)