diff src/testdir/test_vim9_expr.vim @ 21399:5cb6e676defd v8.2.1250

patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces Commit: https://github.com/vim/vim/commit/2f8ce0ae8a8247563be0a77a308130e767e0566e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 19 19:47:35 2020 +0200 patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces Problem: Vim9: cannot use the g:, b:, t: and w: namespaces. Solution: Add instructions to push a dict for the namespaces. (closes https://github.com/vim/vim/issues/6480)
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Jul 2020 20:00:04 +0200
parents 320581a133d9
children e1aeb986712f
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1345,6 +1345,32 @@ def Test_expr7_register()
   assert_equal('register a', @a)
 enddef
 
+def Test_expr7_namespace()
+  g:some_var = 'some'
+  assert_equal('some', get(g:, 'some_var'))
+  assert_equal('some', get(g:, 'some_var', 'xxx'))
+  assert_equal('xxx', get(g:, 'no_var', 'xxx'))
+  unlet g:some_var
+
+  b:some_var = 'some'
+  assert_equal('some', get(b:, 'some_var'))
+  assert_equal('some', get(b:, 'some_var', 'xxx'))
+  assert_equal('xxx', get(b:, 'no_var', 'xxx'))
+  unlet b:some_var
+
+  w:some_var = 'some'
+  assert_equal('some', get(w:, 'some_var'))
+  assert_equal('some', get(w:, 'some_var', 'xxx'))
+  assert_equal('xxx', get(w:, 'no_var', 'xxx'))
+  unlet w:some_var
+
+  t:some_var = 'some'
+  assert_equal('some', get(t:, 'some_var'))
+  assert_equal('some', get(t:, 'some_var', 'xxx'))
+  assert_equal('xxx', get(t:, 'no_var', 'xxx'))
+  unlet t:some_var
+enddef
+
 def Test_expr7_parens()
   # (expr)
   assert_equal(4, (6 * 4) / 6)