diff src/testdir/test_vim9_assign.vim @ 23448:8f31b990ab1e v8.2.2267

patch 8.2.2267: Vim9: cannot use unlet for a dict member Commit: https://github.com/vim/vim/commit/c368957b1904bfaa2b0b52bbcade51b20173f3ed Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 1 19:40:02 2021 +0100 patch 8.2.2267: Vim9: cannot use unlet for a dict member Problem: Vim9: cannot use unlet for a dict member. Solution: Pass GLV_NO_DECL to get_lval(). (closes https://github.com/vim/vim/issues/7585)
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Jan 2021 19:45:03 +0100
parents 5807e3958e38
children a8e7acf71fa4
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -984,19 +984,39 @@ def Test_assign_list()
 enddef
 
 def Test_assign_dict()
-  var d: dict<string> = {}
-  d['key'] = 'value'
-  assert_equal('value', d['key'])
+  var lines =<< trim END
+      var d: dict<string> = {}
+      d['key'] = 'value'
+      assert_equal('value', d['key'])
+
+      d[123] = 'qwerty'
+      assert_equal('qwerty', d[123])
+      assert_equal('qwerty', d['123'])
+
+      var nrd: dict<number> = {}
+      for i in range(3)
+        nrd[i] = i
+      endfor
+      assert_equal({0: 0, 1: 1, 2: 2}, nrd)
 
-  d[123] = 'qwerty'
-  assert_equal('qwerty', d[123])
-  assert_equal('qwerty', d['123'])
+      d.somekey = 'someval'
+      assert_equal({key: 'value', '123': 'qwerty', somekey: 'someval'}, d)
+      # unlet d.somekey
+      # assert_equal({key: 'value', '123': 'qwerty'}, d)
+  END
+  CheckDefAndScriptSuccess(lines)
 
-  var nrd: dict<number> = {}
-  for i in range(3)
-    nrd[i] = i
-  endfor
-  assert_equal({0: 0, 1: 1, 2: 2}, nrd)
+  # TODO: move to above once "unlet d.somekey" in :def is implemented
+  lines =<< trim END
+      vim9script
+      var d: dict<string> = {}
+      d['key'] = 'value'
+      d.somekey = 'someval'
+      assert_equal({key: 'value', somekey: 'someval'}, d)
+      unlet d.somekey
+      assert_equal({key: 'value'}, d)
+  END
+  CheckScriptSuccess(lines)
 
   CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
   CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)