glob_spec.lua 857 B

12345678910111213141516171819202122232425262728293031
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local clear, command, eval, eq = n.clear, n.command, n.eval, t.eq
  4. local mkdir = t.mkdir
  5. before_each(function()
  6. clear()
  7. mkdir('test-glob')
  8. -- Long path might cause "Press ENTER" prompt; use :silent to avoid it.
  9. command('silent cd test-glob')
  10. end)
  11. after_each(function()
  12. vim.uv.fs_rmdir('test-glob')
  13. end)
  14. describe('glob()', function()
  15. it("glob('.*') returns . and .. ", function()
  16. eq({ '.', '..' }, eval("glob('.*', 0, 1)"))
  17. -- Do it again to verify scandir_next_with_dots() internal state.
  18. eq({ '.', '..' }, eval("glob('.*', 0, 1)"))
  19. end)
  20. it("glob('*') returns an empty list ", function()
  21. eq({}, eval("glob('*', 0, 1)"))
  22. -- Do it again to verify scandir_next_with_dots() internal state.
  23. eq({}, eval("glob('*', 0, 1)"))
  24. end)
  25. end)