glob_spec.lua 859 B

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