Mercurial > vim
diff src/testdir/test_vim9_assign.vim @ 23523:b0a6e7325169 v8.2.2304
patch 8.2.2304: Vim9: no test for unletting an imported variable
Commit: https://github.com/vim/vim/commit/0acbf5ae6632b36c2d2f93406478270ef21f528b
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 5 20:58:25 2021 +0100
patch 8.2.2304: Vim9: no test for unletting an imported variable
Problem: Vim9: no test for unletting an imported variable.
Solution: Add a test. Fix line number in error.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 05 Jan 2021 21:00:06 +0100 |
parents | 36bf9a6fbd4c |
children | f39a18a42aed |
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1349,6 +1349,11 @@ def Test_unlet() assert_false(exists('s:somevar')) unlet! s:somevar + CheckDefExecFailure([ + 'var dd = 111', + 'unlet dd', + ], 'E1081:', 2) + # dict unlet var dd = {a: 1, b: 2, c: 3} unlet dd['a'] @@ -1367,21 +1372,29 @@ def Test_unlet() assert_equal([{a: 1}, {c: 3}], dl) CheckDefExecFailure([ - 'var ll = test_null_list()', - 'unlet ll[0]', - ], 'E684:') + 'var ll = test_null_list()', + 'unlet ll[0]', + ], 'E684:', 2) CheckDefExecFailure([ - 'var ll = [1]', - 'unlet ll[2]', - ], 'E684:') + 'var ll = [1]', + 'unlet ll[2]', + ], 'E684:', 2) + CheckDefExecFailure([ + 'var ll = [1]', + 'unlet ll[g:astring]', + ], 'E39:', 2) CheckDefExecFailure([ - 'var dd = test_null_dict()', - 'unlet dd["a"]', - ], 'E716:') + 'var dd = test_null_dict()', + 'unlet dd["a"]', + ], 'E716:', 2) CheckDefExecFailure([ - 'var dd = {a: 1}', - 'unlet dd["b"]', - ], 'E716:') + 'var dd = {a: 1}', + 'unlet dd["b"]', + ], 'E716:', 2) + CheckDefExecFailure([ + 'var dd = {a: 1}', + 'unlet dd[g:alist]', + ], 'E1105:', 2) # can compile unlet before variable exists g:someDict = {key: 'val'} @@ -1426,6 +1439,18 @@ def Test_unlet() 'defcompile', ], 'E1081:') + writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim') + var lines =<< trim END + vim9script + import svar from './XunletExport.vim' + def UnletSvar() + unlet svar + enddef + defcompile + END + CheckScriptFailure(lines, 'E1081:', 1) + delete('XunletExport.vim') + $ENVVAR = 'foobar' assert_equal('foobar', $ENVVAR) unlet $ENVVAR