diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2023-06-10 20:33:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-10 20:33:23 +0200 |
commit | 302d3cfb96d7f0c856262e1a4252d058e3300c8b (patch) | |
tree | d8ef192706ef388172420b58d3b1fde95a7224bf /test/functional/lua/iter_spec.lua | |
parent | b302da9ad220a7699d4b0ebf642529d142a0b9cf (diff) | |
download | rneovim-302d3cfb96d7f0c856262e1a4252d058e3300c8b.tar.gz rneovim-302d3cfb96d7f0c856262e1a4252d058e3300c8b.tar.bz2 rneovim-302d3cfb96d7f0c856262e1a4252d058e3300c8b.zip |
feat(lua): use callable table as iterator in vim.iter (#23957)
A table passed to `vim.iter` can be a class instance with a `__call`
implementation for the iterator protocol.
Diffstat (limited to 'test/functional/lua/iter_spec.lua')
-rw-r--r-- | test/functional/lua/iter_spec.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/lua/iter_spec.lua b/test/functional/lua/iter_spec.lua index 6e1ecc2f7e..3b603c9911 100644 --- a/test/functional/lua/iter_spec.lua +++ b/test/functional/lua/iter_spec.lua @@ -4,6 +4,15 @@ local matches = helpers.matches local pcall_err = helpers.pcall_err describe('vim.iter', function() + it('new() on iterable class instance', function() + local rb = vim.ringbuf(3) + rb:push("a") + rb:push("b") + + local it = vim.iter(rb) + eq({"a", "b"}, it:totable()) + end) + it('filter()', function() local function odd(v) return v % 2 ~= 0 |