Mercurial > vim
diff src/testdir/test_vim9_assign.vim @ 27762:3196066c5795 v8.2.4407
patch 8.2.4407: Vim9: some code not covered by tests
Commit: https://github.com/vim/vim/commit/e08be09a08485e8c919f46c05223c1ccfdaf175d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Feb 17 13:08:26 2022 +0000
patch 8.2.4407: Vim9: some code not covered by tests
Problem: Vim9: some code not covered by tests.
Solution: Add more tests. Avoid giving two errors. Remove dead code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Feb 2022 14:15:04 +0100 |
parents | d754ac2f5ac5 |
children | 1662d2d2e27b |
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -543,6 +543,13 @@ def Test_assign_index() d3.one.two.three = 123 assert_equal({one: {two: {three: 123}}}, d3) + # blob + var bl: blob = 0z11223344 + bl[0] = 0x77 + assert_equal(0z77223344, bl) + bl[-2] = 0x66 + assert_equal(0z77226644, bl) + # should not read the next line when generating "a.b" var a = {} a.b = {} @@ -591,6 +598,18 @@ def Test_assign_index() dl.one = {} END v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected list<number> but got dict<unknown>', 2) + + lines =<< trim END + g:l = [1, 2] + g:l['x'] = 3 + END + v9.CheckDefExecAndScriptFailure(lines, ['E39:', 'E1030:'], 2) + + lines =<< trim END + var bl: blob = test_null_blob() + bl[1] = 8 + END + v9.CheckDefExecAndScriptFailure(lines, ['E1184:', 'E979:'], 2) enddef def Test_init_in_for_loop() @@ -1201,6 +1220,21 @@ def Test_assignment_default() assert_equal(5678, nr) enddef +def Test_script_var_default() + var lines =<< trim END + vim9script + var l: list<number> + var bl: blob + var d: dict<number> + def Echo() + assert_equal([], l) + assert_equal(0z, bl) + assert_equal({}, d) + enddef + END + v9.CheckScriptSuccess(lines) +enddef + let s:scriptvar = 'init' def Test_assignment_var_list() @@ -2082,6 +2116,25 @@ def Test_unlet() 'var ll = [1, 2]', 'unlet ll[0: 1]', ], 'E1004:', 2) + + v9.CheckDefExecFailure([ + 'g:ll = [1, 2]', + 'g:idx = "x"', + 'unlet g:ll[g:idx]', + ], 'E1029: Expected number but got string', 3) + + v9.CheckDefExecFailure([ + 'g:ll = [1, 2, 3]', + 'g:idx = "x"', + 'unlet g:ll[g:idx : 2]', + ], 'E1029: Expected number but got string', 3) + + v9.CheckDefExecFailure([ + 'g:ll = [1, 2, 3]', + 'g:idx = "x"', + 'unlet g:ll[0 : g:idx]', + ], 'E1029: Expected number but got string', 3) + # command recognized as assignment when skipping, should not give an error v9.CheckScriptSuccess([ 'vim9script',