@@ -2304,7 +2304,7 @@ def Test_expr7_any_index_slice()
23042304 # string is permissive, index out of range accepted
23052305 g: teststring = ' abcdef'
23062306 assert_equal (' b' , g: teststring [1 ])
2307- assert_equal (' ' , g: teststring [-1 ])
2307+ assert_equal (' f ' , g: teststring [-1 ])
23082308 assert_equal (' ' , g: teststring [99 ])
23092309
23102310 assert_equal (' b' , g: teststring [1 : 1 ])
@@ -2368,10 +2368,10 @@ def Test_expr7_any_index_slice()
23682368 CheckDefExecFailure ([' echo g:testblob[-3]' ], ' E979:' , 1 )
23692369 CheckScriptFailure ([' vim9script' , ' echo g:testblob[-3]' ], ' E979:' , 2 )
23702370
2371- CheckDefExecFailure ([' echo g:testlist[4]' ], ' E684:' , 1 )
2371+ CheckDefExecFailure ([' echo g:testlist[4]' ], ' E684: list index out of range: 4 ' , 1 )
23722372 CheckScriptFailure ([' vim9script' , ' echo g:testlist[4]' ], ' E684:' , 2 )
23732373 CheckDefExecFailure ([' echo g:testlist[-5]' ], ' E684:' , 1 )
2374- CheckScriptFailure ([' vim9script' , ' echo g:testlist[-5]' ], ' E684:' , 2 )
2374+ CheckScriptFailure ([' vim9script' , ' echo g:testlist[-5]' ], ' E684: list index out of range: -5 ' , 2 )
23752375
23762376 CheckDefExecFailure ([' echo g:testdict["a" : "b"]' ], ' E719:' , 1 )
23772377 CheckScriptFailure ([' vim9script' , ' echo g:testdict["a" : "b"]' ], ' E719:' , 2 )
@@ -2802,15 +2802,23 @@ enddef
28022802def Test_expr7_string_subscript ()
28032803 var lines = << trim END
28042804 var text = ' abcdef'
2805- assert_equal (' ' , text[-1 ])
2805+ assert_equal (' f ' , text[-1 ])
28062806 assert_equal (' a' , text[0 ])
28072807 assert_equal (' e' , text[4 ])
28082808 assert_equal (' f' , text[5 ])
28092809 assert_equal (' ' , text[6 ])
28102810
2811+ text = ' ábçdë'
2812+ assert_equal (' ë' , text[-1 ])
2813+ assert_equal (' d' , text[-2 ])
2814+ assert_equal (' ç' , text[-3 ])
2815+ assert_equal (' b' , text[-4 ])
2816+ assert_equal (' á' , text[-5 ])
2817+ assert_equal (' ' , text[-6 ])
2818+
28112819 text = ' ábçdëf'
28122820 assert_equal (' ' , text[-999 ])
2813- assert_equal (' ' , text[-1 ])
2821+ assert_equal (' f ' , text[-1 ])
28142822 assert_equal (' á' , text[0 ])
28152823 assert_equal (' b' , text[1 ])
28162824 assert_equal (' ç' , text[2 ])
@@ -2904,8 +2912,7 @@ def Test_expr7_list_subscript()
29042912 assert_equal ([], list [0 : -6 ])
29052913 assert_equal ([], list [0 : -99 ])
29062914 END
2907- CheckDefSuccess (lines )
2908- CheckScriptSuccess ([' vim9script' ] + lines )
2915+ CheckDefAndScriptSuccess (lines )
29092916
29102917 lines = [' var l = [0, 1, 2]' , ' echo l[g:astring : g:theone]' ]
29112918 CheckDefExecFailure (lines , ' E1012:' )
0 commit comments