mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	 052498ed42
			
		
	
	052498ed42
	
	
	
		
			
			Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
		
			
				
	
	
		
			41 lines
		
	
	
		
			928 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			928 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
| local t = require('test.testutil')
 | |
| local n = require('test.functional.testnvim')()
 | |
| 
 | |
| local call = n.call
 | |
| local clear = n.clear
 | |
| local eq = t.eq
 | |
| local expect = n.expect
 | |
| 
 | |
| describe('getline()', function()
 | |
|   before_each(function()
 | |
|     clear()
 | |
|     call('setline', 1, { 'a', 'b', 'c' })
 | |
|     expect([[
 | |
|       a
 | |
|       b
 | |
|       c]])
 | |
|   end)
 | |
| 
 | |
|   it('returns empty string for invalid line', function()
 | |
|     eq('', call('getline', -1))
 | |
|     eq('', call('getline', 0))
 | |
|     eq('', call('getline', 4))
 | |
|   end)
 | |
| 
 | |
|   it('returns empty list for invalid range', function()
 | |
|     eq({}, call('getline', 2, 1))
 | |
|     eq({}, call('getline', -1, 1))
 | |
|     eq({}, call('getline', 4, 4))
 | |
|   end)
 | |
| 
 | |
|   it('returns value of valid line', function()
 | |
|     eq('b', call('getline', 2))
 | |
|     eq('a', call('getline', '.'))
 | |
|   end)
 | |
| 
 | |
|   it('returns value of valid range', function()
 | |
|     eq({ 'a', 'b' }, call('getline', 1, 2))
 | |
|     eq({ 'a', 'b', 'c' }, call('getline', 1, 4))
 | |
|   end)
 | |
| end)
 |