writefile_spec.lua 789 B

1234567891011121314151617181920212223242526272829303132
  1. -- Tests for writefile()
  2. local n = require('test.functional.testnvim')()
  3. local clear, command, expect = n.clear, n.command, n.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)