neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

023_edit_arguments_spec.lua (1178B)


      1 -- Tests for complicated + argument to :edit command
      2 
      3 local n = require('test.functional.testnvim')()
      4 
      5 local clear, insert = n.clear, n.insert
      6 local command, expect = n.command, n.expect
      7 local poke_eventloop = n.poke_eventloop
      8 
      9 describe(':edit', function()
     10  setup(clear)
     11 
     12  it('is working', function()
     13    insert([[
     14      The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar"
     15      foo|bar
     16      foo/bar]])
     17    poke_eventloop()
     18 
     19    -- Prepare some test files
     20    command('$-1w! Xfile1')
     21    command('$w! Xfile2')
     22    command('w! Xfile0')
     23 
     24    -- Open Xfile using '+' range
     25    command('edit +1 Xfile1')
     26    command('s/|/PIPE/')
     27    command('yank A')
     28    command('w! Xfile1')
     29 
     30    -- Open Xfile2 using '|' range
     31    command('edit Xfile2|1')
     32    command('s/\\//SLASH/')
     33    command('yank A')
     34    command('w! Xfile2')
     35 
     36    -- Clean first buffer and put @a
     37    command('bf')
     38    command('%d')
     39    command('0put a')
     40 
     41    -- Remove empty line
     42    command('$d')
     43 
     44    -- The buffer should now contain
     45    expect([[
     46      fooPIPEbar
     47      fooSLASHbar]])
     48  end)
     49 
     50  teardown(function()
     51    os.remove('Xfile0')
     52    os.remove('Xfile1')
     53    os.remove('Xfile2')
     54  end)
     55 end)