robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each =t . describe , t . it , t . before_each 5local call =n . call 6local clear =n . clear 7local eq =t . eq 8local expect =n . expect 9 10describe ( 'getline()' , function () 11before_each ( function () 12clear () 13call ( 'setline' , 1 , { 'a' , 'b' , 'c' } ) 14expect ( [[ 15a 16b 17c]] ) 18end ) 19 20it ( 'returns empty string for invalid line' , function () 21eq ( '' , call ( 'getline' , - 1 )) 22eq ( '' , call ( 'getline' , 0 )) 23eq ( '' , call ( 'getline' , 4 )) 24end ) 25 26it ( 'returns empty list for invalid range' , function () 27eq ( {} , call ( 'getline' , 2 , 1 )) 28eq ( {} , call ( 'getline' , - 1 , 1 )) 29eq ( {} , call ( 'getline' , 4 , 4 )) 30end ) 31 32it ( 'returns value of valid line' , function () 33eq ( 'b' , call ( 'getline' , 2 )) 34eq ( 'a' , call ( 'getline' , '.' )) 35end ) 36 37it ( 'returns value of valid range' , function () 38eq ( { 'a' , 'b' } , call ( 'getline' , 1 , 2 )) 39eq ( { 'a' , 'b' , 'c' } , call ( 'getline' , 1 , 4 )) 40end ) 41end )