comparison src/testdir/test_vim9_expr.vim @ 21823:b1f3d8a44ab6 v8.2.1461

patch 8.2.1461: Vim9: string indexes are counted in bytes Commit: https://github.com/vim/vim/commit/e3c37d8ebf9dbbf210fde4a5fb28eb1f2a492a34 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 15 18:39:05 2020 +0200 patch 8.2.1461: Vim9: string indexes are counted in bytes Problem: Vim9: string indexes are counted in bytes. Solution: Use character indexes. (closes https://github.com/vim/vim/issues/6574)
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Aug 2020 18:45:04 +0200
parents 0deb6f96a5a3
children ccad66ac6c3e
comparison
equal deleted inserted replaced
21822:1ff3fa258bf9 21823:b1f3d8a44ab6
2073 let d = #{key: 123} 2073 let d = #{key: 123}
2074 assert_equal(123, d.key) 2074 assert_equal(123, d.key)
2075 enddef 2075 enddef
2076 2076
2077 def Test_expr7_subscript() 2077 def Test_expr7_subscript()
2078 let text = 'abcdef' 2078 let lines =<< trim END
2079 assert_equal('', text[-1]) 2079 let text = 'abcdef'
2080 assert_equal('a', text[0]) 2080 assert_equal('', text[-1])
2081 assert_equal('e', text[4]) 2081 assert_equal('a', text[0])
2082 assert_equal('f', text[5]) 2082 assert_equal('e', text[4])
2083 assert_equal('', text[6]) 2083 assert_equal('f', text[5])
2084 assert_equal('', text[6])
2085
2086 text = 'ábçdëf'
2087 assert_equal('', text[-999])
2088 assert_equal('', text[-1])
2089 assert_equal('á', text[0])
2090 assert_equal('b', text[1])
2091 assert_equal('ç', text[2])
2092 assert_equal('d', text[3])
2093 assert_equal('ë', text[4])
2094 assert_equal('f', text[5])
2095 assert_equal('', text[6])
2096 assert_equal('', text[999])
2097 END
2098 CheckDefSuccess(lines)
2099 CheckScriptSuccess(['vim9script'] + lines)
2084 enddef 2100 enddef
2085 2101
2086 def Test_expr7_subscript_linebreak() 2102 def Test_expr7_subscript_linebreak()
2087 let range = range( 2103 let range = range(
2088 3) 2104 3)