patch 8.2.2738: extending a list with itself can give wrong result

Problem:    Extending a list with itself can give wrong result.
Solution:   Remember the item before where the insertion happens and skip to
            after the already inserted items. (closes #1112)
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 051a37c..1b0796d 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -862,6 +862,20 @@
 
   " Extend g: dictionary with an invalid variable name
   call assert_fails("call extend(g:, {'-!' : 10})", 'E461:')
+
+  " Extend a list with itself.
+  let l = [1, 5, 7]
+  call extend(l, l, 0)
+  call assert_equal([1, 5, 7, 1, 5, 7], l)
+  let l = [1, 5, 7]
+  call extend(l, l, 1)
+  call assert_equal([1, 1, 5, 7, 5, 7], l)
+  let l = [1, 5, 7]
+  call extend(l, l, 2)
+  call assert_equal([1, 5, 1, 5, 7, 7], l)
+  let l = [1, 5, 7]
+  call extend(l, l, 3)
+  call assert_equal([1, 5, 7, 1, 5, 7], l)
 endfunc
 
 func Test_listdict_extendnew()