2014-10-21 01:07:47 -07:00
|
|
|
|
-- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal,
|
|
|
|
|
-- and octal numbers.
|
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2014-10-21 01:07:47 -07:00
|
|
|
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
|
local feed_command, expect = helpers.feed_command, helpers.expect
|
2014-10-21 01:07:47 -07:00
|
|
|
|
|
|
|
|
|
describe('increment and decrement commands', function()
|
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
|
|
it('should work', function()
|
|
|
|
|
-- Insert some numbers in various bases.
|
|
|
|
|
insert([[
|
2015-12-29 16:17:16 -07:00
|
|
|
|
0b101 100 0x100 077 0
|
|
|
|
|
0b101 100 0x100 077
|
2014-10-21 01:07:47 -07:00
|
|
|
|
100 0x100 077 0xfF 0xFf
|
2015-12-29 16:17:16 -07:00
|
|
|
|
100 0x100 077
|
|
|
|
|
0x0b101 0b1101]])
|
2014-10-21 01:07:47 -07:00
|
|
|
|
|
|
|
|
|
-- Increment and decrement numbers in the first row, interpreting the
|
|
|
|
|
-- numbers as decimal, octal or hexadecimal.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set nrformats=bin,octal,hex', '1')
|
2015-12-29 16:17:16 -07:00
|
|
|
|
feed('63l102ll64128$')
|
2014-10-21 01:07:47 -07:00
|
|
|
|
|
|
|
|
|
-- For the second row, treat the numbers as decimal or octal.
|
|
|
|
|
-- 0x100 should be interpreted as decimal 0, the character x, and decimal 100.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set nrformats=octal', '2')
|
2015-12-29 16:17:16 -07:00
|
|
|
|
feed('0w102l2w65129blx6lD')
|
2014-10-21 01:07:47 -07:00
|
|
|
|
|
|
|
|
|
-- For the third row, treat the numbers as decimal or hexadecimal.
|
|
|
|
|
-- 077 should be interpreted as decimal 77.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set nrformats=hex', '3')
|
2014-10-21 01:07:47 -07:00
|
|
|
|
feed('0101l257Txldt ')
|
|
|
|
|
|
2015-12-29 16:17:16 -07:00
|
|
|
|
-- For the fourth row, interpret all numbers as decimal.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set nrformats=', '4')
|
2014-10-21 01:07:47 -07:00
|
|
|
|
feed('0200l100w78')
|
|
|
|
|
|
2015-12-29 16:17:16 -07:00
|
|
|
|
-- For the last row, interpret as binary and hexadecimal.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set nrformats=bin,hex', '5')
|
2015-12-29 16:17:16 -07:00
|
|
|
|
feed('010065l6432')
|
|
|
|
|
|
2014-10-21 01:07:47 -07:00
|
|
|
|
expect([[
|
2015-12-29 16:17:16 -07:00
|
|
|
|
0b011 0 0x0ff 0000 -1
|
|
|
|
|
1b101 0 1x100 0777777
|
2014-10-21 01:07:47 -07:00
|
|
|
|
-1 0x0 078 0xFE 0xfe
|
2015-12-29 16:17:16 -07:00
|
|
|
|
-100 -100x100 000
|
|
|
|
|
0x0b0de 0b0101101]])
|
2014-10-21 01:07:47 -07:00
|
|
|
|
end)
|
|
|
|
|
end)
|