HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/neovim/test/functional/legacy/035_increment_and_decrement_spec.lua
-- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal,
-- and octal numbers.

local n = require('test.functional.testnvim')()

local clear, feed, insert = n.clear, n.feed, n.insert
local feed_command, expect = n.feed_command, n.expect

describe('increment and decrement commands', function()
  setup(clear)

  it('should work', function()
    -- Insert some numbers in various bases.
    insert([[
      0b101   100     0x100     077     0
      0b101   100     0x100     077
      100     0x100     077     0xfF     0xFf
      100     0x100     077
      0x0b101  0b1101]])

    -- Increment and decrement numbers in the first row, interpreting the
    -- numbers as decimal, octal or hexadecimal.
    feed_command('set nrformats=bin,octal,hex', '1')
    feed('63l102ll64128$')

    -- For the second row, treat the numbers as decimal or octal.
    -- 0x100 should be interpreted as decimal 0, the character x, and decimal 100.
    feed_command('set nrformats=octal', '2')
    feed('0w102l2w65129blx6lD')

    -- For the third row, treat the numbers as decimal or hexadecimal.
    -- 077 should be interpreted as decimal 77.
    feed_command('set nrformats=hex', '3')
    feed('0101l257Txldt   ')

    -- For the fourth row, interpret all numbers as decimal.
    feed_command('set nrformats=', '4')
    feed('0200l100w78')

    -- For the last row, interpret as binary and hexadecimal.
    feed_command('set nrformats=bin,hex', '5')
    feed('010065l6432')

    expect([[
      0b011   0     0x0ff     0000     -1
      1b101   0     1x100     0777777
      -1     0x0     078     0xFE     0xfe
      -100     -100x100     000
      0x0b0de  0b0101101]])
  end)
end)