Mercurial > vim
diff src/testdir/test_vim9_builtin.vim @ 23816:525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Commit: https://github.com/vim/vim/commit/3b690069730805a147d45d92eaca4dc838272d1d
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 1 20:14:51 2021 +0100
patch 8.2.2449: Vim9: flatten() always changes the list type
Problem: Vim9: flatten() always changes the list type.
Solution: Disallow using flatten() and add flattennew().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 01 Feb 2021 20:15:04 +0100 |
parents | 007fa6365dfb |
children | 7e0d8f1cae7d |
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -382,6 +382,23 @@ def Test_findfile() CheckDefExecFailure(['echo findfile("")'], 'E1142:') enddef +def Test_flattennew() + var lines =<< trim END + var l = [1, [2, [3, 4]], 5] + call assert_equal([1, 2, 3, 4, 5], flattennew(l)) + call assert_equal([1, [2, [3, 4]], 5], l) + + call assert_equal([1, 2, [3, 4], 5], flattennew(l, 1)) + call assert_equal([1, [2, [3, 4]], 5], l) + END + CheckDefAndScriptSuccess(lines) + + lines =<< trim END + echo flatten([1, 2, 3]) + END + CheckDefAndScriptFailure(lines, 'E1158:') +enddef + def Test_fnamemodify() CheckDefSuccess(['echo fnamemodify(test_null_string(), ":p")']) CheckDefSuccess(['echo fnamemodify("", ":p")'])