diff src/testdir/test_listdict.vim @ 25599:b85e44974a08 v8.2.3336

patch 8.2.3336: behavior of negative index in list change changed Commit: https://github.com/vim/vim/commit/92f05f21afdb8a43581554a252cb2fc050f9e03b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 12 21:12:56 2021 +0200 patch 8.2.3336: behavior of negative index in list change changed Problem: Behavior of negative index in list change changed. (Naruhiko Nishino) Solution: Only change it for Vim9 script. (closes #8749)
author Bram Moolenaar <Bram@vim.org>
date Thu, 12 Aug 2021 21:15:03 +0200
parents 0fdacd8f0cf3
children 525ef4d1d412
line wrap: on
line diff
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -42,6 +42,23 @@ func Test_list_slice()
   let l[:1] += [1, 2]
   let l[2:] -= [1]
   call assert_equal([2, 4, 2], l)
+
+  let lines =<< trim END
+      VAR l = [1, 2]
+      call assert_equal([1, 2], l[:])
+      call assert_equal([2], l[-1 : -1])
+      call assert_equal([1, 2], l[-2 : -1])
+  END
+  call CheckLegacyAndVim9Success(lines)
+
+  let l = [1, 2]
+  call assert_equal([], l[-3 : -1])
+
+  let lines =<< trim END
+      var l = [1, 2]
+      assert_equal([1, 2], l[-3 : -1])
+  END
+  call CheckDefAndScriptSuccess(lines)
 endfunc
 
 " List identity