2015-03-18 19:41:51 -07:00
|
|
|
-- Tests for writefile()
|
|
|
|
|
2024-04-09 04:26:16 -07:00
|
|
|
local t = require('test.functional.testutil')()
|
2024-04-08 02:03:20 -07:00
|
|
|
local clear, command, expect = t.clear, t.command, t.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)
|