aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/writefile_spec.lua
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-22 09:44:01 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-06-24 16:22:16 -0400
commit14b3741ec5410c4dc1b71950d1994f24c7a9744a (patch)
treeb13b97928206121ae9d06ac20d8f2deb9be156bf /test/functional/eval/writefile_spec.lua
parent39e284772d5ee7214341fce9e25f9d7e051dd39e (diff)
downloadrneovim-14b3741ec5410c4dc1b71950d1994f24c7a9744a.tar.gz
rneovim-14b3741ec5410c4dc1b71950d1994f24c7a9744a.tar.bz2
rneovim-14b3741ec5410c4dc1b71950d1994f24c7a9744a.zip
test: update writefile test for invalid list items
It validates list items with tv_check_str_on_nr() to catch invalid types (ex. E745, E805). If there is an invalid item, it does not write to the file.
Diffstat (limited to 'test/functional/eval/writefile_spec.lua')
-rw-r--r--test/functional/eval/writefile_spec.lua21
1 files changed, 9 insertions, 12 deletions
diff --git a/test/functional/eval/writefile_spec.lua b/test/functional/eval/writefile_spec.lua
index 2f84114b9b..0bb7523d7e 100644
--- a/test/functional/eval/writefile_spec.lua
+++ b/test/functional/eval/writefile_spec.lua
@@ -127,23 +127,20 @@ describe('writefile()', function()
eq('TEST', read_file(fname))
end)
- it('stops writing to file after error in list', function()
+ it('does not write to file if error in list', function()
local args = '["tset"] + repeat([%s], 3), "' .. fname .. '"'
- eq('\nE806: using Float as a String',
+ eq('\nE805: Expected a Number or a String, Float found',
redir_exec(('call writefile(%s)'):format(args:format('0.0'))))
- eq('tset\n', read_file(fname))
+ eq(nil, read_file(fname))
write_file(fname, 'TEST')
- eq('\nE730: using List as a String',
+ eq('\nE745: Expected a Number or a String, List found',
redir_exec(('call writefile(%s)'):format(args:format('[]'))))
- eq('tset\n', read_file(fname))
- write_file(fname, 'TEST')
- eq('\nE731: using Dictionary as a String',
+ eq('TEST', read_file(fname))
+ eq('\nE728: Expected a Number or a String, Dictionary found',
redir_exec(('call writefile(%s)'):format(args:format('{}'))))
- eq('tset\n', read_file(fname))
- write_file(fname, 'TEST')
- eq('\nE729: using Funcref as a String',
+ eq('TEST', read_file(fname))
+ eq('\nE703: Expected a Number or a String, Funcref found',
redir_exec(('call writefile(%s)'):format(args:format('function("tr")'))))
- eq('tset\n', read_file(fname))
- write_file(fname, 'TEST')
+ eq('TEST', read_file(fname))
end)
end)