neovim

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

026_execute_while_if_spec.lua (1135B)


      1 -- Test for :execute, :while and :if
      2 
      3 local n = require('test.functional.testnvim')()
      4 
      5 local clear = n.clear
      6 local expect = n.expect
      7 local source = n.source
      8 local command = n.command
      9 
     10 describe(':execute, :while and :if', function()
     11  setup(clear)
     12 
     13  it('is working', function()
     14    source([[
     15      let i = 0
     16      while i < 12
     17        let i = i + 1
     18        execute "normal o" . i . "\033"
     19        if i % 2
     20          normal Ax
     21          if i == 9
     22            break
     23          endif
     24          if i == 5
     25            continue
     26          else
     27            let j = 9
     28            while j > 0
     29              execute "normal" j . "a" . j . "\x1b"
     30              let j = j - 1
     31            endwhile
     32          endif
     33        endif
     34        if i == 9
     35          execute "normal Az\033"
     36        endif
     37      endwhile
     38      unlet i j
     39    ]])
     40 
     41    -- Remove empty line
     42    command('1d')
     43 
     44    -- Assert buffer contents.
     45    expect([[
     46      1x999999999888888887777777666666555554444333221
     47      2
     48      3x999999999888888887777777666666555554444333221
     49      4
     50      5x
     51      6
     52      7x999999999888888887777777666666555554444333221
     53      8
     54      9x]])
     55  end)
     56 end)