robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal, 2-- and octal numbers. 3 4local n =require ( 'test.functional.testnvim' )() 5local t =require ( 'test.testutil' ) 6 7local describe , it , setup =t . describe , t . it , t . setup 8local clear , feed , insert =n . clear , n . feed , n . insert 9local feed_command , expect =n . feed_command , n . expect 10 11describe ( 'increment and decrement commands' , function () 12setup ( clear ) 13 14it ( 'should work' , function () 15-- Insert some numbers in various bases. 16insert ( [[ 170b101 100 0x100 077 0 180b101 100 0x100 077 19100 0x100 077 0xfF 0xFf 20100 0x100 077 210x0b101 0b1101]] ) 22 23-- Increment and decrement numbers in the first row, interpreting the 24-- numbers as decimal, octal or hexadecimal. 25feed_command ( 'set nrformats=bin,octal,hex' , '1' ) 26feed ( '63l102ll64128$' ) 27 28-- For the second row, treat the numbers as decimal or octal. 29-- 0x100 should be interpreted as decimal 0, the character x, and decimal 100. 30feed_command ( 'set nrformats=octal' , '2' ) 31feed ( '0w102l2w65129blx6lD' ) 32 33-- For the third row, treat the numbers as decimal or hexadecimal. 34-- 077 should be interpreted as decimal 77. 35feed_command ( 'set nrformats=hex' , '3' ) 36feed ( '0101l257Txldt ' ) 37 38-- For the fourth row, interpret all numbers as decimal. 39feed_command ( 'set nrformats=' , '4' ) 40feed ( '0200l100w78' ) 41 42-- For the last row, interpret as binary and hexadecimal. 43feed_command ( 'set nrformats=bin,hex' , '5' ) 44feed ( '010065l6432' ) 45 46expect ( [[ 470b011 0 0x0ff 0000 -1 481b101 0 1x100 0777777 49-1 0x0 078 0xFE 0xfe 50-100 -100x100 000 510x0b0de 0b0101101]] ) 52end ) 53end )