@@ -12,8 +12,7 @@ T["api"] = new_set()
1212T [" api" ][" fzf_exec" ] = new_set ()
1313
1414T [" api" ][" fzf_exec" ][" table" ] = function ()
15- helpers .FzfLua .fzf_exec (child ,
16- [==[ (function()
15+ helpers .FzfLua .fzf_exec (child , [==[ (function()
1716 local contents = {}
1817 for i = 1, 100 do
1918 for j, s in ipairs({ "foo", "bar", "baz" }) do
@@ -44,11 +43,84 @@ T["api"]["fzf_exec"]["function"] = new_set({ parametrize = { { "sync" }, { "asyn
4443 coroutine.yield()
4544 end
4645 fzf_cb(nil)
47- end))
48- ]==] ,
46+ end))]==] ,
4947 { __expect_lines = true , __postprocess_wait = true })
5048 end
5149 end ,
5250})
5351
52+ T [" api" ][" fzf_live" ] = new_set ()
53+
54+ T [" api" ][" fzf_live" ][" table" ] = function ()
55+ helpers .FzfLua .fzf_live (child , [==[ function(args)
56+ local q = args[1]
57+ if not tonumber(q) then
58+ return { "Invalid number: " .. tostring(q) }
59+ end
60+ local lines = {}
61+ for i = 1, tonumber(q) do
62+ for j, s in ipairs({ "foo", "bar", "baz" }) do
63+ table.insert(lines, tostring((i - 1) * 3 + j) .. ": " .. s)
64+ end
65+ end
66+ return lines
67+ end]==] ,
68+ {
69+ __expect_lines = true ,
70+ __postprocess_wait = true ,
71+ query = 100 ,
72+ })
73+ end
74+
75+ T [" api" ][" fzf_live" ][" function" ] = new_set ({ parametrize = { { " sync" }, { " async" } } }, {
76+ function (type )
77+ if type == " sync" then
78+ helpers .FzfLua .fzf_live (child , [==[ function(args)
79+ local q = args[1]
80+ return function(fzf_cb)
81+ if not tonumber(q) then
82+ fzf_cb("Invalid number: " .. tostring(q))
83+ else
84+ for i = 1, tonumber(q) do
85+ for j, s in ipairs({ "foo", "bar", "baz" }) do
86+ fzf_cb(tostring((i - 1) * 3 + j) .. ": " .. s)
87+ end
88+ end
89+ end
90+ fzf_cb(nil)
91+ end
92+ end]==] ,
93+ {
94+ __expect_lines = true ,
95+ __postprocess_wait = true ,
96+ query = 100 ,
97+ })
98+ else
99+ helpers .FzfLua .fzf_live (child , [==[ function(args)
100+ local q = args[1]
101+ return coroutine.wrap(function(fzf_cb)
102+ local co = coroutine.running()
103+ if not tonumber(q) then
104+ fzf_cb("Invalid number: " .. tostring(q), function() coroutine.resume(co) end)
105+ coroutine.yield()
106+ else
107+ for i = 1, tonumber(q) do
108+ for j, s in ipairs({ "foo", "bar", "baz" }) do
109+ fzf_cb(tostring((i - 1) * 3 + j) .. ": " .. s, function() coroutine.resume(co) end)
110+ coroutine.yield()
111+ end
112+ end
113+ end
114+ fzf_cb(nil)
115+ end)
116+ end]==] ,
117+ {
118+ __expect_lines = true ,
119+ __postprocess_wait = true ,
120+ query = 100 ,
121+ })
122+ end
123+ end ,
124+ })
125+
54126return T
0 commit comments