changeset 25597:0fdacd8f0cf3 v8.2.3335

patch 8.2.3335: Vim9: not enough tests run with Vim9 Commit: https://github.com/vim/vim/commit/ef98257593a0abf1300d0f70358dc45a70a62580 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 12 19:27:57 2021 +0200 patch 8.2.3335: Vim9: not enough tests run with Vim9 Problem: Vim9: not enough tests run with Vim9. Solution: Run a few more tests in Vim9 script and :def function. Fix that items(), keys() and values9) return zero for a NULL dict. Make join() return an empty string for a NULL list. Make sort() return an empty list for a NULL list.
author Bram Moolenaar <Bram@vim.org>
date Thu, 12 Aug 2021 19:30:03 +0200
parents 15ce187b41b8
children 9569ab5f546a
files src/dict.c src/list.c src/testdir/test_listdict.vim src/testdir/vim9.vim src/version.c
diffstat 5 files changed, 244 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/src/dict.c
+++ b/src/dict.c
@@ -1209,11 +1209,12 @@ dict_list(typval_T *argvars, typval_T *r
 	emsg(_(e_dictreq));
 	return;
     }
-    if ((d = argvars[0].vval.v_dict) == NULL)
-	return;
 
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
+    if ((d = argvars[0].vval.v_dict) == NULL)
+	// empty dict behaves like an empty dict
+	return;
 
     todo = (int)d->dv_hashtab.ht_used;
     for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
--- a/src/list.c
+++ b/src/list.c
@@ -1436,15 +1436,15 @@ f_join(typval_T *argvars, typval_T *rett
 	emsg(_(e_listreq));
 	return;
     }
+    rettv->v_type = VAR_STRING;
     if (argvars[0].vval.v_list == NULL)
 	return;
+
     if (argvars[1].v_type == VAR_UNKNOWN)
 	sep = (char_u *)" ";
     else
 	sep = tv_get_string_chk(&argvars[1]);
 
-    rettv->v_type = VAR_STRING;
-
     if (sep != NULL)
     {
 	ga_init2(&ga, (int)sizeof(char), 80);
@@ -1968,11 +1968,13 @@ do_sort_uniq(typval_T *argvars, typval_T
     else
     {
 	l = argvars[0].vval.v_list;
-	if (l == NULL || value_check_lock(l->lv_lock,
+	if (l != NULL && value_check_lock(l->lv_lock,
 	     (char_u *)(sort ? N_("sort() argument") : N_("uniq() argument")),
 									TRUE))
 	    goto theend;
 	rettv_list_set(rettv, l);
+	if (l == NULL)
+	    goto theend;
 	CHECK_LIST_MATERIALIZE(l);
 
 	len = list_len(l);
@@ -3110,32 +3112,35 @@ f_reverse(typval_T *argvars, typval_T *r
 
     if (argvars[0].v_type != VAR_LIST)
 	semsg(_(e_listblobarg), "reverse()");
-    else if ((l = argvars[0].vval.v_list) != NULL
+    else
+    {
+	l = argvars[0].vval.v_list;
+	rettv_list_set(rettv, l);
+	if (l != NULL
 	    && !value_check_lock(l->lv_lock,
 				    (char_u *)N_("reverse() argument"), TRUE))
-    {
-	if (l->lv_first == &range_list_item)
 	{
-	    varnumber_T new_start = l->lv_u.nonmat.lv_start
+	    if (l->lv_first == &range_list_item)
+	    {
+		varnumber_T new_start = l->lv_u.nonmat.lv_start
 				  + (l->lv_len - 1) * l->lv_u.nonmat.lv_stride;
-	    l->lv_u.nonmat.lv_end = new_start
+		l->lv_u.nonmat.lv_end = new_start
 			   - (l->lv_u.nonmat.lv_end - l->lv_u.nonmat.lv_start);
-	    l->lv_u.nonmat.lv_start = new_start;
-	    l->lv_u.nonmat.lv_stride = -l->lv_u.nonmat.lv_stride;
-	    rettv_list_set(rettv, l);
-	    return;
+		l->lv_u.nonmat.lv_start = new_start;
+		l->lv_u.nonmat.lv_stride = -l->lv_u.nonmat.lv_stride;
+		return;
+	    }
+	    li = l->lv_u.mat.lv_last;
+	    l->lv_first = l->lv_u.mat.lv_last = NULL;
+	    l->lv_len = 0;
+	    while (li != NULL)
+	    {
+		ni = li->li_prev;
+		list_append(l, li);
+		li = ni;
+	    }
+	    l->lv_u.mat.lv_idx = l->lv_len - l->lv_u.mat.lv_idx - 1;
 	}
-	li = l->lv_u.mat.lv_last;
-	l->lv_first = l->lv_u.mat.lv_last = NULL;
-	l->lv_len = 0;
-	while (li != NULL)
-	{
-	    ni = li->li_prev;
-	    list_append(l, li);
-	    li = ni;
-	}
-	rettv_list_set(rettv, l);
-	l->lv_u.mat.lv_idx = l->lv_len - l->lv_u.mat.lv_idx - 1;
     }
 }
 
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -845,24 +845,27 @@ endfunc
 
 " Tests for reverse(), sort(), uniq()
 func Test_reverse_sort_uniq()
-  let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
-  call assert_equal(['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5], uniq(copy(l)))
-  call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(l))
-  call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(reverse(l)))
-  if has('float')
-    call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l))
-    call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l)))
-    call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l))))
-    call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l)))
+  let lines =<< trim END
+      VAR l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
+      call assert_equal(['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5], uniq(copy(l)))
+      call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(l))
+      call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(reverse(l)))
+      if has('float')
+        call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l))
+        call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l)))
+        call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l))))
+        call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l)))
 
-    let l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four']
-    call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n'))
+        LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four']
+        call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n'))
 
-    let l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
-    call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1))
-    call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
-    call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l)))
-  endif
+        LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []]
+        call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1))
+        call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i'))
+        call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l)))
+      endif
+  END
+  call CheckLegacyAndVim9Success(lines)
 
   call assert_fails('call reverse("")', 'E899:')
   call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:')
@@ -873,28 +876,34 @@ endfunc
 
 " reduce a list or a blob
 func Test_reduce()
-  call assert_equal(1, reduce([], { acc, val -> acc + val }, 1))
-  call assert_equal(10, reduce([1, 3, 5], { acc, val -> acc + val }, 1))
-  call assert_equal(2 * (2 * ((2 * 1) + 2) + 3) + 4, reduce([2, 3, 4], { acc, val -> 2 * acc + val }, 1))
-  call assert_equal('a x y z', ['x', 'y', 'z']->reduce({ acc, val -> acc .. ' ' .. val}, 'a'))
-  call assert_equal(#{ x: 1, y: 1, z: 1 }, ['x', 'y', 'z']->reduce({ acc, val -> extend(acc, { val: 1 }) }, {}))
-  call assert_equal([0, 1, 2, 3], reduce([1, 2, 3], function('add'), [0]))
+  let lines =<< trim END
+      call assert_equal(1, reduce([], LSTART acc, val LMIDDLE acc + val LEND, 1))
+      call assert_equal(10, reduce([1, 3, 5], LSTART acc, val LMIDDLE acc + val LEND, 1))
+      call assert_equal(2 * (2 * ((2 * 1) + 2) + 3) + 4, reduce([2, 3, 4], LSTART acc, val LMIDDLE 2 * acc + val LEND, 1))
+      call assert_equal('a x y z', ['x', 'y', 'z']->reduce(LSTART acc, val LMIDDLE acc .. ' ' .. val LEND, 'a'))
+      call assert_equal([0, 1, 2, 3], reduce([1, 2, 3], function('add'), [0]))
 
-  let l = ['x', 'y', 'z']
-  call assert_equal(42, reduce(l, function('get'), #{ x: #{ y: #{ z: 42 } } }))
-  call assert_equal(['x', 'y', 'z'], l)
+      VAR l = ['x', 'y', 'z']
+      call assert_equal(42, reduce(l, function('get'), {'x': {'y': {'z': 42 } } }))
+      call assert_equal(['x', 'y', 'z'], l)
 
-  call assert_equal(1, reduce([1], { acc, val -> acc + val }))
-  call assert_equal('x y z', reduce(['x', 'y', 'z'], { acc, val -> acc .. ' ' .. val }))
-  call assert_equal(120, range(1, 5)->reduce({ acc, val -> acc * val }))
-  call assert_fails("call reduce([], { acc, val -> acc + val })", 'E998: Reduce of an empty List with no initial value')
+      call assert_equal(1, reduce([1], LSTART acc, val LMIDDLE acc + val LEND))
+      call assert_equal('x y z', reduce(['x', 'y', 'z'], LSTART acc, val LMIDDLE acc .. ' ' .. val LEND))
+      call assert_equal(120, range(1, 5)->reduce(LSTART acc, val LMIDDLE acc * val LEND))
+
+      call assert_equal(1, reduce(0z, LSTART acc, val LMIDDLE acc + val LEND, 1))
+      call assert_equal(1 + 0xaf + 0xbf + 0xcf, reduce(0zAFBFCF, LSTART acc, val LMIDDLE acc + val LEND, 1))
+      call assert_equal(2 * (2 * 1 + 0xaf) + 0xbf, 0zAFBF->reduce(LSTART acc, val LMIDDLE 2 * acc + val LEND, 1))
 
-  call assert_equal(1, reduce(0z, { acc, val -> acc + val }, 1))
-  call assert_equal(1 + 0xaf + 0xbf + 0xcf, reduce(0zAFBFCF, { acc, val -> acc + val }, 1))
-  call assert_equal(2 * (2 * 1 + 0xaf) + 0xbf, 0zAFBF->reduce({ acc, val -> 2 * acc + val }, 1))
+      call assert_equal(0xff, reduce(0zff, LSTART acc, val LMIDDLE acc + val LEND))
+      call assert_equal(2 * (2 * 0xaf + 0xbf) + 0xcf, reduce(0zAFBFCF, LSTART acc, val LMIDDLE 2 * acc + val LEND))
+  END
+  call CheckLegacyAndVim9Success(lines)
 
-  call assert_equal(0xff, reduce(0zff, { acc, val -> acc + val }))
-  call assert_equal(2 * (2 * 0xaf + 0xbf) + 0xcf, reduce(0zAFBFCF, { acc, val -> 2 * acc + val }))
+  call assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce({ acc, val -> extend(acc, { val: 1 }) }, {}))
+  vim9 assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce((acc, val) => extend(acc, {[val]: 1 }), {}))
+
+  call assert_fails("call reduce([], { acc, val -> acc + val })", 'E998: Reduce of an empty List with no initial value')
   call assert_fails("call reduce(0z, { acc, val -> acc + val })", 'E998: Reduce of an empty Blob with no initial value')
 
   call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E897:')
@@ -922,29 +931,36 @@ endfunc
 
 " splitting a string to a List using split()
 func Test_str_split()
-  call assert_equal(['aa', 'bb'], split('  aa  bb '))
-  call assert_equal(['aa', 'bb'], split('  aa  bb  ', '\W\+', 0))
-  call assert_equal(['', 'aa', 'bb', ''], split('  aa  bb  ', '\W\+', 1))
-  call assert_equal(['', '', 'aa', '', 'bb', '', ''], split('  aa  bb  ', '\W', 1))
-  call assert_equal(['aa', '', 'bb'], split(':aa::bb:', ':', 0))
-  call assert_equal(['', 'aa', '', 'bb', ''], split(':aa::bb:', ':', 1))
-  call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1))
-  call assert_equal(['a', 'b', 'c'], split('abc', '\zs'))
-  call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
+  let lines =<< trim END
+      call assert_equal(['aa', 'bb'], split('  aa  bb '))
+      call assert_equal(['aa', 'bb'], split('  aa  bb  ', '\W\+', 0))
+      call assert_equal(['', 'aa', 'bb', ''], split('  aa  bb  ', '\W\+', 1))
+      call assert_equal(['', '', 'aa', '', 'bb', '', ''], split('  aa  bb  ', '\W', 1))
+      call assert_equal(['aa', '', 'bb'], split(':aa::bb:', ':', 0))
+      call assert_equal(['', 'aa', '', 'bb', ''], split(':aa::bb:', ':', 1))
+      call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1))
+      call assert_equal(['a', 'b', 'c'], split('abc', '\zs'))
+      call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1))
+      call assert_equal(['abc'], split('abc', '\\%('))
+  END
+  call CheckLegacyAndVim9Success(lines)
+
   call assert_fails("call split('abc', [])", 'E730:')
   call assert_fails("call split('abc', 'b', [])", 'E745:')
-  call assert_equal(['abc'], split('abc', '\\%('))
 endfunc
 
 " compare recursively linked list and dict
 func Test_listdict_compare()
-  let l = [1, 2, 3, 4]
-  let d = {'1': 1, '2': l, '3': 3}
-  let l[1] = d
-  call assert_true(l == l)
-  call assert_true(d == d)
-  call assert_false(l != deepcopy(l))
-  call assert_false(d != deepcopy(d))
+  let lines =<< trim END
+      VAR l = [1, 2, 3, '4']
+      VAR d = {'1': 1, '2': l, '3': 3}
+      LET l[1] = d
+      call assert_true(l == l)
+      call assert_true(d == d)
+      call assert_false(l != deepcopy(l))
+      call assert_false(d != deepcopy(d))
+  END
+  call CheckLegacyAndVim9Success(lines)
 
   " comparison errors
   call assert_fails('echo [1, 2] =~ {}', 'E691:')
@@ -955,14 +971,17 @@ endfunc
 
   " compare complex recursively linked list and dict
 func Test_listdict_compare_complex()
-  let l = []
-  call add(l, l)
-  let dict4 = {"l": l}
-  call add(dict4.l, dict4)
-  let lcopy = deepcopy(l)
-  let dict4copy = deepcopy(dict4)
-  call assert_true(l == lcopy)
-  call assert_true(dict4 == dict4copy)
+  let lines =<< trim END
+      VAR l = []
+      call add(l, l)
+      VAR dict4 = {"l": l}
+      call add(dict4.l, dict4)
+      VAR lcopy = deepcopy(l)
+      VAR dict4copy = deepcopy(dict4)
+      call assert_true(l == lcopy)
+      call assert_true(dict4 == dict4copy)
+  END
+  call CheckLegacyAndVim9Success(lines)
 endfunc
 
 " Test for extending lists and dictionaries
@@ -970,33 +989,36 @@ func Test_listdict_extend()
   " Test extend() with lists
 
   " Pass the same List to extend()
-  let l = [1, 2, 3]
-  call assert_equal([1, 2, 3, 1, 2, 3], extend(l, l))
-  call assert_equal([1, 2, 3, 1, 2, 3], l)
+  let lines =<< trim END
+      VAR l = [1, 2, 3]
+      call assert_equal([1, 2, 3, 1, 2, 3], extend(l, l))
+      call assert_equal([1, 2, 3, 1, 2, 3], l)
 
-  let l = [1, 2, 3]
-  call assert_equal([1, 2, 3, 4, 5, 6], extend(l, [4, 5, 6]))
-  call assert_equal([1, 2, 3, 4, 5, 6], l)
+      LET l = [1, 2, 3]
+      call assert_equal([1, 2, 3, 4, 5, 6], extend(l, [4, 5, 6]))
+      call assert_equal([1, 2, 3, 4, 5, 6], l)
 
-  let l = [1, 2, 3]
-  call extend(l, [4, 5, 6], 0)
-  call assert_equal([4, 5, 6, 1, 2, 3], l)
+      LET l = [1, 2, 3]
+      call extend(l, [4, 5, 6], 0)
+      call assert_equal([4, 5, 6, 1, 2, 3], l)
 
-  let l = [1, 2, 3]
-  call extend(l, [4, 5, 6], 1)
-  call assert_equal([1, 4, 5, 6, 2, 3], l)
+      LET l = [1, 2, 3]
+      call extend(l, [4, 5, 6], 1)
+      call assert_equal([1, 4, 5, 6, 2, 3], l)
 
-  let l = [1, 2, 3]
-  call extend(l, [4, 5, 6], 3)
-  call assert_equal([1, 2, 3, 4, 5, 6], l)
+      LET l = [1, 2, 3]
+      call extend(l, [4, 5, 6], 3)
+      call assert_equal([1, 2, 3, 4, 5, 6], l)
 
-  let l = [1, 2, 3]
-  call extend(l, [4, 5, 6], -1)
-  call assert_equal([1, 2, 4, 5, 6, 3], l)
+      LET l = [1, 2, 3]
+      call extend(l, [4, 5, 6], -1)
+      call assert_equal([1, 2, 4, 5, 6, 3], l)
 
-  let l = [1, 2, 3]
-  call extend(l, [4, 5, 6], -3)
-  call assert_equal([4, 5, 6, 1, 2,  3], l)
+      LET l = [1, 2, 3]
+      call extend(l, [4, 5, 6], -3)
+      call assert_equal([4, 5, 6, 1, 2,  3], l)
+  END
+  call CheckLegacyAndVim9Success(lines)
 
   let l = [1, 2, 3]
   call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:')
@@ -1008,21 +1030,24 @@ func Test_listdict_extend()
   " Test extend() with dictionaries.
 
   " Pass the same Dict to extend()
-  let d = { 'a': {'b': 'B'}}
-  call extend(d, d)
-  call assert_equal({'a': {'b': 'B'}}, d)
+  let lines =<< trim END
+      VAR d = {'a': {'b': 'B'}, 'x': 9}
+      call extend(d, d)
+      call assert_equal({'a': {'b': 'B'}, 'x': 9}, d)
 
-  let d = {'a': 'A', 'b': 'B'}
-  call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, extend(d, {'b': 0, 'c':'C'}))
-  call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d)
+      LET d = {'a': 'A', 'b': 9}
+      call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, extend(d, {'b': 0, 'c': 'C'}))
+      call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d)
 
-  let d = {'a': 'A', 'b': 'B'}
-  call extend(d, {'a': 'A', 'b': 0, 'c': 'C'}, "force")
-  call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d)
+      LET d = {'a': 'A', 'b': 9}
+      call extend(d, {'a': 'A', 'b': 0, 'c': 'C'}, "force")
+      call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d)
 
-  let d = {'a': 'A', 'b': 'B'}
-  call extend(d, {'b': 0, 'c':'C'}, "keep")
-  call assert_equal({'a': 'A', 'b': 'B', 'c': 'C'}, d)
+      LET d = {'a': 'A', 'b': 9}
+      call extend(d, {'b': 0, 'c': 'C'}, "keep")
+      call assert_equal({'a': 'A', 'b': 9, 'c': 'C'}, d)
+  END
+  call CheckLegacyAndVim9Success(lines)
 
   let d = {'a': 'A', 'b': 'B'}
   call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:')
@@ -1039,18 +1064,21 @@ func Test_listdict_extend()
   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)
+  let lines =<< trim END
+      VAR 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)
+  END
+  call CheckLegacyAndVim9Success(lines)
 endfunc
 
 func Test_listdict_extendnew()
@@ -1200,43 +1228,49 @@ endfunc
 
 " Test for a null list
 func Test_null_list()
+  let lines =<< trim END
+      VAR l = test_null_list()
+      call assert_equal('', join(test_null_list()))
+      call assert_equal('', join(l))
+      call assert_equal(0, len(l))
+      call assert_equal(1, empty(l))
+      call assert_equal([], split(test_null_string()))
+      call assert_equal([], l[ : 2])
+      call assert_true([] == l)
+      call assert_equal('[]', string(l))
+      call assert_equal([], sort(test_null_list()))
+      call assert_equal([], sort(l))
+      call assert_equal([], uniq(test_null_list()))
+      call assert_equal([], uniq(l))
+      VAR k = [] + l
+      call assert_equal([], k)
+      LET k = l + []
+      call assert_equal([], k)
+      call assert_equal(0, len(copy(l)))
+      call assert_equal(0, count(l, 5))
+      call assert_equal([], deepcopy(l))
+      call assert_equal(5, get(l, 2, 5))
+      call assert_equal(-1, index(l, 2, 5))
+      call assert_equal(0, min(l))
+      call assert_equal(0, max(l))
+      call assert_equal(0, remove(test_null_list(), 0, 2))
+      call assert_equal([], repeat(l, 2))
+      call assert_equal([], reverse(test_null_list()))
+      call assert_equal([], reverse(l))
+      call assert_equal([], sort(test_null_list()))
+      call assert_equal([], sort(l))
+      call assert_equal('[]', string(l))
+  END
+  call CheckLegacyAndVim9Success(lines)
+
   let l = test_null_list()
-  call assert_equal(0, join(test_null_list()))
-  call assert_equal('', join(l))
-  call assert_equal(0, len(l))
-  call assert_equal(1, empty(l))
+  call assert_equal([], extend(l, l, 0))
+  call assert_equal(0, insert(test_null_list(), 2, -1))
   call assert_fails('let s = join([1, 2], [])', 'E730:')
-  call assert_equal([], split(test_null_string()))
-  call assert_equal([], l[:2])
-  call assert_true([] == l)
-  call assert_equal('[]', string(l))
-  call assert_equal(0, sort(test_null_list()))
-  call assert_equal([], sort(l))
-  call assert_equal(0, uniq(test_null_list()))
-  call assert_equal([], uniq(l))
-  let k = [] + l
-  call assert_equal([], k)
-  let k = l + []
-  call assert_equal([], k)
-  call assert_equal(0, len(copy(l)))
-  call assert_equal(0, count(l, 5))
-  call assert_equal([], deepcopy(l))
-  call assert_equal(5, get(l, 2, 5))
-  call assert_equal(-1, index(l, 2, 5))
-  call assert_equal(0, insert(test_null_list(), 2, -1))
+  call assert_fails('call remove(l, 0, 2)', 'E684:')
   call assert_fails('call insert(l, 2, -1)', 'E684:')
-  call assert_equal(0, min(l))
-  call assert_equal(0, max(l))
-  call assert_equal(0, remove(test_null_list(), 0, 2))
-  call assert_fails('call remove(l, 0, 2)', 'E684:')
-  call assert_equal([], repeat(l, 2))
-  call assert_equal(0, reverse(test_null_list()))
-  call assert_equal([], reverse(l))
-  call assert_equal(0, sort(test_null_list()))
-  call assert_equal([], sort(l))
-  call assert_equal('[]', string(l))
   call assert_fails('call extend(test_null_list(), test_null_list())', 'E1134:')
-  call assert_equal([], extend(l, l, 0))
+
   lockvar l
   call assert_equal(1, islocked('l'))
   unlockvar l
@@ -1244,32 +1278,37 @@ endfunc
 
 " Test for a null dict
 func Test_null_dict()
-  call assert_equal(test_null_dict(), test_null_dict())
+  let lines =<< trim END
+      call assert_equal(test_null_dict(), test_null_dict())
+      VAR d = test_null_dict()
+      call assert_equal({}, d)
+      call assert_equal(0, len(d))
+      call assert_equal(1, empty(d))
+      call assert_equal([], items(test_null_dict()))
+      call assert_equal([], items(d))
+      call assert_equal([], keys(test_null_dict()))
+      call assert_equal([], keys(d))
+      call assert_equal([], values(test_null_dict()))
+      call assert_equal([], values(d))
+      call assert_false(has_key(d, 'k'))
+      call assert_equal('{}', string(d))
+      call assert_equal({}, {})
+      call assert_equal(0, len(copy(d)))
+      call assert_equal(0, count(d, 'k'))
+      call assert_equal({}, deepcopy(d))
+      call assert_equal(20, get(d, 'k', 20))
+      call assert_equal(0, min(d))
+      call assert_equal(0, max(d))
+      call assert_equal(0, remove(test_null_dict(), 'k'))
+      call assert_equal('{}', string(d))
+  END
+  call CheckLegacyAndVim9Success(lines)
+
   let d = test_null_dict()
-  call assert_equal({}, d)
-  call assert_equal(0, len(d))
-  call assert_equal(1, empty(d))
-  call assert_equal(0, items(test_null_dict()))
-  call assert_equal([], items(d))
-  call assert_equal(0, keys(test_null_dict()))
-  call assert_equal([], keys(d))
-  call assert_equal(0, values(test_null_dict()))
-  call assert_equal([], values(d))
-  call assert_false(has_key(d, 'k'))
-  call assert_equal('{}', string(d))
+  call assert_equal({}, extend(d, d, 'keep'))
+  call assert_fails("call remove(d, 'k')", 'E716:')
   call assert_fails('let x = d[10]', 'E716:')
-  call assert_equal({}, {})
-  call assert_equal(0, len(copy(d)))
-  call assert_equal(0, count(d, 'k'))
-  call assert_equal({}, deepcopy(d))
-  call assert_equal(20, get(d, 'k', 20))
-  call assert_equal(0, min(d))
-  call assert_equal(0, max(d))
-  call assert_equal(0, remove(test_null_dict(), 'k'))
-  call assert_fails("call remove(d, 'k')", 'E716:')
-  call assert_equal('{}', string(d))
   call assert_fails('call extend(test_null_dict(), test_null_dict())', 'E1133:')
-  call assert_equal({}, extend(d, d, 'keep'))
   lockvar d
   call assert_equal(1, islocked('d'))
   unlockvar d
--- a/src/testdir/vim9.vim
+++ b/src/testdir/vim9.vim
@@ -172,6 +172,9 @@ def CheckTransLegacySuccess(lines: list<
   var legacylines = lines->mapnew((_, v) =>
   				v->substitute('\<VAR\>', 'let', 'g')
 		           	 ->substitute('\<LET\>', 'let', 'g')
+		           	 ->substitute('\<LSTART\>', '{', 'g')
+		           	 ->substitute('\<LMIDDLE\>', '->', 'g')
+				 ->substitute('\<LEND\>', '}', 'g')
 		           	 ->substitute('#"', ' "', 'g'))
   CheckLegacySuccess(legacylines)
 enddef
@@ -181,7 +184,10 @@ enddef
 def CheckTransDefSuccess(lines: list<string>)
   var vim9lines = lines->mapnew((_, v) =>
   				v->substitute('\<VAR\>', 'var', 'g')
-		           	 ->substitute('\<LET ', '', 'g'))
+		           	 ->substitute('\<LET ', '', 'g')
+		           	 ->substitute('\<LSTART\>', '(', 'g')
+		           	 ->substitute('\<LMIDDLE\>', ') =>', 'g')
+				 ->substitute(' *\<LEND\> *', '', 'g'))
   CheckDefSuccess(vim9lines)
 enddef
 
@@ -190,7 +196,10 @@ enddef
 def CheckTransVim9Success(lines: list<string>)
   var vim9lines = lines->mapnew((_, v) =>
   				v->substitute('\<VAR\>', 'var', 'g')
-		           	 ->substitute('\<LET ', '', 'g'))
+		           	 ->substitute('\<LET ', '', 'g')
+		           	 ->substitute('\<LSTART\>', '(', 'g')
+		           	 ->substitute('\<LMIDDLE\>', ') =>', 'g')
+				 ->substitute(' *\<LEND\> *', '', 'g'))
   CheckScriptSuccess(['vim9script'] + vim9lines)
 enddef
 
@@ -198,6 +207,7 @@ enddef
 " Use 'VAR' for a declaration.
 " Use 'LET' for an assignment
 " Use ' #"' for a comment
+" Use LSTART arg LMIDDLE expr LEND for lambda
 def CheckLegacyAndVim9Success(lines: list<string>)
   CheckTransLegacySuccess(lines)
   CheckTransDefSuccess(lines)
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3335,
+/**/
     3334,
 /**/
     3333,