writefile_spec.lua 821 B

12345678910111213141516171819202122232425262728293031
  1. -- Tests for writefile()
  2. local helpers = require('test.functional.helpers')(after_each)
  3. local clear, command, expect = helpers.clear, helpers.command, helpers.expect
  4. describe('writefile', function()
  5. setup(clear)
  6. it('is working', function()
  7. command('%delete _')
  8. command('let f = tempname()')
  9. command('call writefile(["over","written"], f, "b")')
  10. command('call writefile(["hello","world"], f, "b")')
  11. command('call writefile(["!", "good"], f, "a")')
  12. command('call writefile(["morning"], f, "ab")')
  13. command('call writefile(["", "vimmers"], f, "ab")')
  14. command('bwipeout!')
  15. command('$put =readfile(f)')
  16. command('1 delete _')
  17. command('call delete(f)')
  18. -- Assert buffer contents.
  19. expect([[
  20. hello
  21. world!
  22. good
  23. morning
  24. vimmers]])
  25. end)
  26. end)