aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-21 11:37:13 +0800
committerGitHub <noreply@github.com>2022-08-21 11:37:13 +0800
commit6b9852cc4188d9ca7bce8e7592dcfca38539c743 (patch)
tree3e3dbcffc76ecac8ffa2862a1d307483c4091f0c /src/nvim/testdir
parent506a3ec91359da077eee81c82d23c4805ad22f9a (diff)
downloadrneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.tar.gz
rneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.tar.bz2
rneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.zip
vim-patch:8.2.4754: using cached values after unsetting some environment variables (#19872)
Problem: Still using cached values after unsetting some known environment variables. Solution: Take care of the side effects. (closes vim/vim#10194) https://github.com/vim/vim/commit/7714231bb5b15f7c85453f3945c108478de1d08a Cherry-pick vim_setenv_ext() from patch 8.2.0200.
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_environ.vim20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_environ.vim b/src/nvim/testdir/test_environ.vim
index dd34983ee5..d8344817f5 100644
--- a/src/nvim/testdir/test_environ.vim
+++ b/src/nvim/testdir/test_environ.vim
@@ -28,6 +28,26 @@ func Test_setenv()
call assert_equal(v:null, getenv('TEST ENV'))
endfunc
+func Test_special_env()
+ " The value for $HOME is cached internally by Vim, ensure the value is up to
+ " date.
+ let orig_ENV = $HOME
+
+ let $HOME = 'foo'
+ call assert_equal('foo', expand('~'))
+ " old $HOME value is kept until a new one is set
+ unlet $HOME
+ call assert_equal('foo', expand('~'))
+
+ call setenv('HOME', 'bar')
+ call assert_equal('bar', expand('~'))
+ " old $HOME value is kept until a new one is set
+ call setenv('HOME', v:null)
+ call assert_equal('bar', expand('~'))
+
+ let $HOME = orig_ENV
+endfunc
+
func Test_external_env()
call setenv('FOO', 'HelloWorld')
if has('win32')