Mercurial > vim
diff src/testdir/test_vim9_expr.vim @ 21826:ccad66ac6c3e v8.2.1462
patch 8.2.1462: Vim9: string slice not supported yet
Commit: https://github.com/vim/vim/commit/11107bab7ead9124f46a7ddf6aa3bb66b43a8246
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 15 21:10:16 2020 +0200
patch 8.2.1462: Vim9: string slice not supported yet
Problem: Vim9: string slice not supported yet.
Solution: Add support for string slicing.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Aug 2020 21:15:04 +0200 |
parents | b1f3d8a44ab6 |
children | af5db9b6d210 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -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)