vim.opt.rtp:prepend(".")
local t = require("test.runner")
local lsp = require("test.lsp")
local b = require("test.buf")
local buf = lsp.open_and_attach("test_files/array_hop_demo.pl")
local function wait_for_some_user(buf, line, col)
for _ = 1, 40 do
local labels = lsp.completion_labels(buf, line, col)
for _, l in ipairs(labels) do
if l == "greet" then return labels end
end
vim.wait(250)
end
return lsp.completion_labels(buf, line, col)
end
t.test("array-hop: $users[0]-> offers Some::User methods", function()
local N = "array-hop: $users[0]-> offers Some::User methods"
local line, col = b.find_pos(buf, "$users[0]->greet();")
if not t.ok(N, line, "couldn't find '$users[0]->greet();'") then return end
local arrow_col = col + #"$users[0]->"
local labels = wait_for_some_user(buf, line, arrow_col)
local ok = t.contains(N, labels, "greet", "completions")
ok = t.contains(N, labels, "email", "completions") and ok
ok = t.contains(N, labels, "name", "completions") and ok
if ok then t.pass(N) end
end)
t.finish()