uniq_spec.lua 855 B

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