2015-03-18 19:41:51 -07:00
|
|
|
-- Tests for writefile()
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, command, expect = helpers.clear, helpers.command, helpers.expect
|
2015-03-18 19:41:51 -07:00
|
|
|
|
|
|
|
describe('writefile', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
command('%delete _')
|
|
|
|
command('let f = tempname()')
|
|
|
|
command('call writefile(["over","written"], f, "b")')
|
|
|
|
command('call writefile(["hello","world"], f, "b")')
|
|
|
|
command('call writefile(["!", "good"], f, "a")')
|
|
|
|
command('call writefile(["morning"], f, "ab")')
|
|
|
|
command('call writefile(["", "vimmers"], f, "ab")')
|
|
|
|
command('bwipeout!')
|
|
|
|
command('$put =readfile(f)')
|
|
|
|
command('1 delete _')
|
|
|
|
command('call delete(f)')
|
2015-03-18 19:41:51 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
hello
|
|
|
|
world!
|
|
|
|
good
|
|
|
|
morning
|
|
|
|
vimmers]])
|
|
|
|
end)
|
|
|
|
end)
|