Skip to content

Commit

Permalink
tests: tl types: add test for -p (symbols_in_scope)
Browse files Browse the repository at this point in the history
Also reading with multiple files in the argument. `-p` applies
to the first file.
  • Loading branch information
hishamhm committed Aug 21, 2024
1 parent 8296e59 commit 9e483f4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/cli/types_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ describe("tl types works like check", function()
end
end)

it("reports symbols in scope for a position", function()
local name1 = util.write_tmp_file(finally, [[
local function add1(a: number, b: number): number
return a + b
end
print(add1(10, 20))
]])
local name2 = util.write_tmp_file(finally, [[
local function add2(a: number, b: number): number
return a + b
end
print(add2(10, 20))
]])
local pd = io.popen(util.tl_cmd("types", "-p", "2:23", name1, name2), "r")
local output = pd:read("*a")
util.assert_popen_close(0, pd:close())
local types = json.decode(output)
assert.same({
["a"] = 1,
["add2"] = 370,
["b"] = 1,
}, types)
end)

it("reports number of errors in stderr and code 1 on syntax errors", function()
local name = util.write_tmp_file(finally, [[
print(add("string", 20))))))
Expand Down

0 comments on commit 9e483f4

Please sign in to comment.