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

Code before:
    should_fail('history', 1000000, 'E474')
    should_fail('regexpengine', -1, 'E474')
    should_fail('regexpengine', 3, 'E474')
    should_succeed('regexpengine', 2)
    should_fail('report', -1, 'E487')
    should_succeed('report', 0)
    should_fail('sidescroll', -1, 'E487')
    should_fail('cmdwinheight', 0, 'E487')
    should_fail('updatetime', -1, 'E487')

    should_fail('foldlevel', -5, 'E487')
    should_fail('foldcolumn', '13', 'E474')
    should_fail('conceallevel', 4, 'E474')
    should_fail('numberwidth', 21, 'E474')
    should_fail('numberwidth', 0, 'E487')

    -- If smaller than 1 this one is set to 'lines'-1
    command('setglobal window=-10')
    api.nvim_set_option_value('window', -10, {})
    eq(23, api.nvim_get_option_value('window', {}))
    eq('', eval('v:errmsg'))

    -- 'scrolloff' and 'sidescrolloff' can have a -1 value when
    -- set for the current window, but not globally
    matches('E487', pcall_err(command, 'setglobal scrolloff=-1'))
    matches('E487', pcall_err(command, 'setglobal sidescrolloff=-1'))

    eq(true, pcall(command, 'setlocal scrolloff=-1'))
    eq(true, pcall(command, 'setlocal sidescrolloff=-1'))
  end)

  it('set wmh/wh wmw/wiw checks', function()
    command('set winheight=2')
    matches('E591', pcall_err(command, 'set winminheight=3'))

    command('set winwidth=2')
    matches('E592', pcall_err(command, 'set winminwidth=3'))
  end)

  it('set maxcombine resets to 6', function()
    local function setto(value)
      command('setglobal maxcombine=' .. value)
      command('setlocal maxcombine=' .. value)
      api.nvim_set_option_value('maxcombine', value, {})
      eq(6, api.nvim_get_option_value('maxcombine', {}))
      eq('', eval('v:errmsg'))
    end
    setto(0)
    setto(1)
    setto(6)
    setto(7)

Review comment (suggestion):
```suggestion
    matches('E487:', pcall_err(command, 'setglobal scrolloff=-1'))
    matches('E487:', pcall_err(command, 'setglobal sidescrolloff=-1'))
```

Code after:
    should_fail('history', 1000000, 'E474')
    should_fail('regexpengine', -1, 'E474')
    should_fail('regexpengine', 3, 'E474')
    should_succeed('regexpengine', 2)
    should_fail('report', -1, 'E487')
    should_succeed('report', 0)
    should_fail('sidescroll', -1, 'E487')
    should_fail('cmdwinheight', 0, 'E487')
    should_fail('updatetime', -1, 'E487')

    should_fail('foldlevel', -5, 'E487')
    should_fail('foldcolumn', '13', 'E474')
    should_fail('conceallevel', 4, 'E474')
    should_fail('numberwidth', 21, 'E474')
    should_fail('numberwidth', 0, 'E487')

    -- If smaller than 1 this one is set to 'lines'-1
    command('setglobal window=-10')
    api.nvim_set_option_value('window', -10, {})
    eq(23, api.nvim_get_option_value('window', {}))
    eq('', eval('v:errmsg'))

    -- 'scrolloff' and 'sidescrolloff' can have a -1 value when
    -- set for the current window, but not globally
    matches('E487:', pcall_err(command, 'setglobal scrolloff=-1'))
    matches('E487:', pcall_err(command, 'setglobal sidescrolloff=-1'))

    eq(true, pcall(command, 'setlocal scrolloff=-1'))
    eq(true, pcall(command, 'setlocal sidescrolloff=-1'))
  end)

  it('set wmh/wh wmw/wiw checks', function()
    command('set winheight=2')
    matches('E591:', pcall_err(command, 'set winminheight=3'))

    command('set winwidth=2')
    matches('E592:', pcall_err(command, 'set winminwidth=3'))
  end)

  it('set maxcombine resets to 6', function()
    local function setto(value)
      command('setglobal maxcombine=' .. value)
      command('setlocal maxcombine=' .. value)
      api.nvim_set_option_value('maxcombine', value, {})
      eq(6, api.nvim_get_option_value('maxcombine', {}))
      eq('', eval('v:errmsg'))
    end
    setto(0)
    setto(1)
    setto(6)
    setto(7)