Skip to content

Commit

Permalink
fix: reenable accidentally disabled tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Aug 2, 2024
1 parent e68eb30 commit 2e22be8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
18 changes: 9 additions & 9 deletions spec/declaration/global_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x: number = 1"
})
util.check([[
util.run_check([[
local foo = require("foo")
global x: number
x = 2
Expand All @@ -148,7 +148,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x <const>: number = 1"
})
util.check([[
util.run_check([[
local foo = require("foo")
global x <const>: number
]])
Expand All @@ -158,7 +158,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x <const>: number = 1"
})
util.check_type_error([[
util.run_check_type_error([[
local foo = require("foo")
global x <const>: number = 9
]], {
Expand All @@ -170,7 +170,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x: number"
})
util.check_type_error([[
util.run_check_type_error([[
local foo = require("foo")
global x <const>: number
]], {
Expand All @@ -182,7 +182,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x <const>: number"
})
util.check_type_error([[
util.run_check_type_error([[
local foo = require("foo")
global x: number
]], {
Expand All @@ -194,7 +194,7 @@ describe("global", function()
util.mock_io(finally, {
["foo.tl"] = "global x, y: number, string = 1, 'hello'"
})
util.check_type_error([[
util.run_check_type_error([[
local foo = require("foo")
global x: string
x = 2
Expand All @@ -213,7 +213,7 @@ describe("global", function()
global type Building
global type Person
global record Person
residence: Building
end
Expand All @@ -224,14 +224,14 @@ describe("global", function()
global type Person
global type Building
global record Building
owner: Person
end
return building
]],
})
util.check([[
util.run_check([[
local person = require("person")
local building = require("building")
local b: Building = {}
Expand Down
14 changes: 7 additions & 7 deletions spec/declaration/record_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do
it("can be nested", function()
util.mock_io(finally, {
["req.d.tl"] = [[
local type requests = record ]]..pick(i, "", "{requests}")..[[
local type requests = record
type RequestOpts = record
{string}
Expand All @@ -246,7 +246,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do
return requests
]],
})
util.check_type_error([[
util.run_check_type_error([[
local req = require("req")
local r = req.get("http://example.com")
Expand All @@ -260,7 +260,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do
it("can be nested with shorthand syntax", function()
util.mock_io(finally, {
["req.d.tl"] = [[
local type requests = record ]]..pick(i, "", "{requests}")..[[
local type requests = record
record RequestOpts
{string}
Expand All @@ -279,7 +279,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do
return requests
]],
})
util.check_type_error([[
util.run_check_type_error([[
local req = require("req")
local r = req.get("http://example.com")
Expand Down Expand Up @@ -437,7 +437,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do
it("can export types as nested " .. name, function()
util.mock_io(finally, {
["req.d.tl"] = [[
local type requests = record ]]..pick(i, "", "{requests}")..[[
local record requests
type RequestOpts = record
{string}
Expand All @@ -456,15 +456,15 @@ for i, name in ipairs({"records", "arrayrecords"}) do
return requests
]],
})
util.check([[
return util.check([[
local req = require("req")
local function f(): req.Response
return req.get("http://example.com")
end
print(f().status_code)
]])
]])()
end)

it("resolves aliasing of nested " .. name .. " (see #400)", util.check([[
Expand Down
20 changes: 10 additions & 10 deletions spec/error_reporting/typecheck_error_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ describe("typecheck errors", function()
util.mock_io(finally, {
["bar.tl"] = "local x: string = 1",
})
util.check_type_error([[
util.run_check_type_error([[
local bar = require "bar"
]], {
{ filename = "./bar.tl" }
})()
})
end)

it("unknowns include filename", util.lax_check([[
Expand All @@ -28,11 +28,11 @@ describe("typecheck errors", function()
util.mock_io(finally, {
["bar.lua"] = "local x: string = b"
})
util.lax_check([[
util.run_lax_check([[
local bar = require "bar"
]], {
{ msg = "b", filename = "./bar.lua" }
})()
})
end)

it("type mismatches across modules report their module names", function ()
Expand All @@ -54,7 +54,7 @@ describe("typecheck errors", function()
return bbb
]]
})
util.check_type_error([[
util.run_check_type_error([[
local aaa = require("aaa")
local bbb = require("bbb")
Expand All @@ -67,7 +67,7 @@ describe("typecheck errors", function()
myfunc(b)
]], {
{ msg = "bbb.Thing is not a aaa.Thing" }
})()
})
end)

it("localized type mismatches across module report their filenames", function ()
Expand Down Expand Up @@ -96,7 +96,7 @@ describe("typecheck errors", function()
return bbb
]]
})
util.check_type_error([[
util.run_check_type_error([[
local aaa = require("aaa")
local bbb = require("bbb")
Expand All @@ -107,7 +107,7 @@ describe("typecheck errors", function()
aaa.myfunc(b)
]], {
{ msg = "argument 1: Thing (defined in ./bbb.tl:4) is not a Thing (defined in ./aaa.tl:1)" }
})()
})
end)

it("type mismatches across local type names report their provenance", function ()
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("typecheck errors", function()
return bbb
]]
})
util.check_type_error([[
util.run_check_type_error([[
local aaa = require("aaa")
local bbb = require("bbb")
Expand All @@ -150,7 +150,7 @@ describe("typecheck errors", function()
aaa.myfunc(b)
]], {
{ msg = "argument 1: Thing (defined in ./bbb.tl:1) is not a Thing (defined in ./aaa.tl:1)" }
})()
})
end)

end)
2 changes: 1 addition & 1 deletion spec/lexer/literals_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ describe("lexer", function()
end
local input = table.concat(code, "\n")

util.check(input)
util.run_check(input)
end)
end)
12 changes: 12 additions & 0 deletions spec/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,16 @@ function util.gen(code, expected, gen_target)
return gen(false, code, expected, gen_target)
end

function util.run_check_type_error(...)
return util.check_type_error(...)()
end

function util.run_check(...)
return util.check(...)()
end

function util.run_lax_check(...)
return util.lax_check(...)()
end

return util

0 comments on commit 2e22be8

Please sign in to comment.