neovim

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

uniq_spec.lua (849B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 
      4 local eq = t.eq
      5 local clear = n.clear
      6 local command = n.command
      7 local exc_exec = n.exc_exec
      8 local pcall_err = t.pcall_err
      9 
     10 setup(clear)
     11 
     12 describe('uniq()', function()
     13  it('errors out when processing special values', function()
     14    eq(
     15      'Vim(call):E362: Using a boolean value as a Float',
     16      exc_exec('call uniq([v:true, v:false], "f")')
     17    )
     18  end)
     19 
     20  it('can yield E882 and stop filtering after that', function()
     21    command([[
     22      function Cmp(a, b)
     23        if type(a:a) == type([]) || type(a:b) == type([])
     24          return []
     25        endif
     26        return (a:a > a:b) - (a:a < a:b)
     27      endfunction
     28    ]])
     29    eq(
     30      'Vim(let):E745: Using a List as a Number',
     31      pcall_err(command, 'let fl = uniq([0, 0, [], 1, 1], "Cmp")')
     32    )
     33  end)
     34 end)