Repository: neovim/neovim
File: test/functional/lua/fs_spec.lua (Lua)

Code before:
          vim.fs.find(function(_, d)
            return d:match('[\\/]contrib$')
          end, opts)
        )
      )
    end)
  end)

  describe('root()', function()
    before_each(function()
      command('edit test/functional/fixtures/tty-test.c')
    end)

    it('works with a single marker', function()
      eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
    end)

    it('works with multiple markers', function()
      local bufnr = api.nvim_get_current_buf()
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua([[return vim.fs.root(..., {'CMakeLists.txt', 'CMakePresets.json'})]], bufnr)
      )
    end)

    it('assings priorities according to nested markers', function()
      local bufnr = api.nvim_get_current_buf()
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional'),
        exec_lua(
          [[return vim.fs.root(..., { 'example_spec.lua', {'CMakeLists.txt', 'CMakePresets.json'}, '.luarc.json'})]],
          bufnr
        )
      )
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua(
          [[return vim.fs.root(..., { {'CMakeLists.txt', 'CMakePresets.json'}, 'example_spec.lua', '.luarc.json'})]],
          bufnr
        )
      )
      eq(vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua(
          [[return vim.fs.root(..., {
            function(name, _)
              return name:match('%.txt$')
            end,
            'example_spec.lua',
            '.luarc.json' })]],
          bufnr
        )

Review comment (suggestion):
typo
```suggestion
    it('nested markers have equal priority', function()
```

Code after:
          vim.fs.find(function(_, d)
            return d:match('[\\/]contrib$')
          end, opts)
        )
      )
    end)
  end)

  describe('root()', function()
    before_each(function()
      command('edit test/functional/fixtures/tty-test.c')
    end)

    it('works with a single marker', function()
      eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
    end)

    it('works with multiple markers', function()
      local bufnr = api.nvim_get_current_buf()
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua([[return vim.fs.root(..., {'CMakeLists.txt', 'CMakePresets.json'})]], bufnr)
      )
    end)

    it('nested markers have equal priority', function()
      local bufnr = api.nvim_get_current_buf()
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional'),
        exec_lua(
          [[return vim.fs.root(..., { 'example_spec.lua', {'CMakeLists.txt', 'CMakePresets.json'}, '.luarc.json'})]],
          bufnr
        )
      )
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua(
          [[return vim.fs.root(..., { {'CMakeLists.txt', 'CMakePresets.json'}, 'example_spec.lua', '.luarc.json'})]],
          bufnr
        )
      )
      eq(
        vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
        exec_lua(
          [[return vim.fs.root(..., {
            function(name, _)
              return name:match('%.txt$')
            end,
            'example_spec.lua',
            '.luarc.json' })]],
          bufnr