diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-13 20:38:03 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-13 20:38:03 +0100 |
commit | c423ad77ed763c11ba67729bbf63c1cf0915231f (patch) | |
tree | d50a83a06633e84412413b5b6c8fcbe58a4acf75 /src/testdir/test_vim9_builtin.vim | |
parent | 9145846b6aa411e3ab5c0d145b37808654352877 (diff) |
patch 8.2.2343: Vim9: return type of readfile() is anyv8.2.2343
Problem: Vim9: return type of readfile() is any.
Solution: Add readblob() so that readfile() can be expected to always
return a list of strings. (closes #7671)
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 40cfdcbb14..3d474f3ed8 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -623,6 +623,32 @@ def Test_readdir() eval expand('sautest')->readdirex((e) => e.name[0] !=# '.') enddef +def Test_readblob() + var blob = 0z12341234 + writefile(blob, 'Xreadblob') + var read: blob = readblob('Xreadblob') + assert_equal(blob, read) + + var lines =<< trim END + var read: list<string> = readblob('Xreadblob') + END + CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<string> but got blob', 1) + delete('Xreadblob') +enddef + +def Test_readfile() + var text = ['aaa', 'bbb', 'ccc'] + writefile(text, 'Xreadfile') + var read: list<string> = readfile('Xreadfile') + assert_equal(text, read) + + var lines =<< trim END + var read: dict<string> = readfile('Xreadfile') + END + CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1) + delete('Xreadfile') +enddef + def Test_remove_return_type() var l = remove({one: [1, 2], two: [3, 4]}, 'one') var res = 0 |