Skip to content

Commit 81ba544

Browse files
committed
Capitalize all error messages
Because it looks better in GUI.
1 parent 25702c8 commit 81ba544

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

api.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function assert_eq(expected, actual, msg)
102102

103103
if not equal(expected, actual) then
104104
test_fail {
105-
msg = msg_or(msg, "args not equal"),
105+
msg = msg_or(msg, "Args not equal"),
106106
expect = expected,
107107
actual = actual
108108
}
@@ -117,7 +117,7 @@ function assert_not_eq(not_expected, actual, msg)
117117

118118
if equal(not_expected, actual) then
119119
test_fail {
120-
msg = msg_or(msg, "args are equal"),
120+
msg = msg_or(msg, "Args are equal"),
121121
not_expect = not_expected,
122122
actual = actual,
123123
}
@@ -134,7 +134,7 @@ function assert_close(expected, actual, delta, msg)
134134
local invalid_args = expected == nil or actual == nil or delta == nil
135135
if invalid_args or abs(expected - actual) > delta then
136136
test_fail {
137-
msg = msg_or(msg, "args not close"),
137+
msg = msg_or(msg, "Args not close"),
138138
expect = expected,
139139
actual = actual,
140140
delta = delta,
@@ -152,7 +152,7 @@ function assert_not_close(not_expected, actual, delta, msg)
152152
local invalid_args = not_expected == nil or actual == nil or delta == nil
153153
if invalid_args or abs(not_expected - actual) <= delta then
154154
test_fail {
155-
msg = msg_or(msg, "args too close"),
155+
msg = msg_or(msg, "Args too close"),
156156
not_expect = not_expected,
157157
actual = actual,
158158
delta = delta,
@@ -167,7 +167,7 @@ function assert_not_nil(actual, msg)
167167

168168
if actual == nil then
169169
test_fail {
170-
msg = msg_or(msg, "arg is nil")
170+
msg = msg_or(msg, "Arg is nil")
171171
}
172172
end
173173
end
@@ -179,7 +179,7 @@ function assert_nil(actual, msg)
179179

180180
if actual != nil then
181181
test_fail {
182-
msg = msg_or(msg, "arg is not nil"),
182+
msg = msg_or(msg, "Arg is not nil"),
183183
actual = actual
184184
}
185185
end

examples/subject_test.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ test("assert nil", function()
4343
end)
4444

4545
-- standard assert function can be used too to verify if argument is true
46-
test("standard assert aka assert true", function()
46+
-- or not nil
47+
test("standard assert", function()
4748
assert(true)
4849
end)
4950

@@ -99,7 +100,7 @@ test("custom assert function", function()
99100
if n % 2 != 0 then
100101
test_fail {
101102
-- msg will be presented in the GUI when assertion failed:
102-
msg = "arg is not even",
103+
msg = "Arg is not even",
103104
-- you can add as many fields as you want. All will be presented
104105
-- in the GUI along with msg:
105106
actual = n

runner.lua

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ function test(name, test)
7676
msg = err:sub(#file + 1, #err)
7777
file = file:sub(1, #file - 2) -- drop ": "
7878
end
79+
if msg == "assertion failed!" then
80+
msg = "Assertion failed"
81+
end
7982
err = {
8083
__traceback = { file },
8184
msg = msg,

0 commit comments

Comments
 (0)