-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessages.luau
34 lines (30 loc) · 1.35 KB
/
messages.luau
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local frktest = require("@frktest/frktest")
local test = frktest.test
local check = frktest.assert.check
local req = frktest.assert.require
local msg = frktest.assert.msg
return function()
test.suite("Messages", function()
test.case("Print message if assertion fails", function()
check.equal(10, 20, msg("the check failed and has a message"))
local exp = 20
req.equal(10, exp, msg(`messages can use interpolation: {exp}`))
end)
test.case("Message doesn't have to be in assertion", function()
-- because of the way it's implemented, msg can be called before the check
msg("message on different line")
check.equal(1, 2)
end)
test.case("There can only be one message at a time", function()
msg("this message will never print")
check.equal(1, 2, msg("this message overwrote the one above"))
end)
test.case("Messages only affect the next assertion", function()
-- messages are forgotten after each assertion, whether is passes or fails
-- but only printed if the assertion fails
msg("this message will never print")
check.equal(1, 1) -- this assertions passes, but the message is still forgotten
check.equal(1, 2) -- prints no custom message
end)
end)
end