Skip to content

Commit 54b61b6

Browse files
committed
Regenerate and Preload.
1 parent 0d416e9 commit 54b61b6

File tree

5 files changed

+59
-17
lines changed

5 files changed

+59
-17
lines changed

tests/assert_const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// GENERATED BY textFileToGoConst
22
// GitHub: github.com/logrusorgru/textFileToGoConst
33
// input file: assert.lua
4-
// generated: Fri Nov 11 12:44:59 PST 2022
4+
// generated: Fri Nov 11 18:08:06 PST 2022
55

66
package tests
77

tests/assertions_const.go

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// GENERATED BY textFileToGoConst
22
// GitHub: github.com/logrusorgru/textFileToGoConst
33
// input file: assertions.lua
4-
// generated: Fri Nov 11 12:44:58 PST 2022
4+
// generated: Fri Nov 11 18:08:04 PST 2022
55

66
package tests
77

@@ -21,13 +21,20 @@ function assertions:__call(...)
2121
return self.call(...)
2222
end
2323
24+
function assertions:cleanseString(s)
25+
s = string.gsub(s, '\n', '\\n')
26+
s = string.gsub(s, '\t', '\\t')
27+
s = string.gsub(s, '\r', '\\r')
28+
return s
29+
end
30+
2431
function assertions:Fail(t, ...)
2532
t:LogHelper(2, ...)
2633
if self.fail_now then
27-
print("Failing now")
34+
assert(t.FailNow, "First parameter must be t (the testing.T object)")
2835
t:FailNow()
2936
else
30-
print("Failing")
37+
assert(t.Fail, "First parameter must be t (the testing.T object)")
3138
t:Fail()
3239
end
3340
return false
@@ -36,8 +43,10 @@ end
3643
function assertions:Failf(t, fmt, ...)
3744
t:LogHelperf(2, fmt, ...)
3845
if self.fail_now then
46+
assert(t.FailNow, "First parameter must be t (the testing.T object)")
3947
t:FailNow()
4048
else
49+
assert(t.Fail, "First parameter must be t (the testing.T object)")
4150
t:Fail()
4251
end
4352
return false
@@ -47,56 +56,89 @@ function assertions:Equal(t, expected, actual, ...)
4756
if expected == actual then
4857
return true
4958
end
50-
return self:Fail(t, string.format([[expected "%s"; got "%s"]] .. '\n', expected, actual), ...)
59+
return self:Fail(t, string.format([[
60+
61+
Error: Not equal:
62+
expected: "%s"
63+
actual : "%s"
64+
Messages: ]], self:cleanseString(expected), self:cleanseString(actual)), ...)
5165
end
5266
5367
function assertions:Equalf(t, expected, actual, fmt, ...)
5468
if expected == actual then
5569
return true
5670
end
57-
return self:Failf(t, string.format([[expected "%s"; got "%s"%s%s]], expected, actual, '\n', fmt), ...)
71+
return self:Failf(t, string.format([[
72+
73+
Error: Not equal:
74+
expected: "%s"
75+
actual : "%s"
76+
Messages: %s
77+
]], self:cleanseString(expected), self:cleanseString(actual), fmt), ...)
5878
end
5979
6080
function assertions:NotEqual(t, expected, actual, ...)
6181
if expected ~= actual then
6282
return true
6383
end
64-
return self:Fail(t, string.format([[expected ~= "%s";]] .. '\n', expected), ...)
84+
return self:Fail(t, string.format([[
85+
86+
Error: Should not be %s
87+
Messages: ]], expected), ...)
6588
end
6689
6790
function assertions:NotEqualf(t, expected, actual, fmt, ...)
6891
if expected ~= actual then
6992
return true
7093
end
71-
return self:Failf(t, string.format([[expected ~= "%s"; got "%s"%s%s]], expected, '\n', fmt), ...)
94+
return self:Failf(t, string.format([[
95+
96+
Error: Should not be %s
97+
Messages: %s
98+
]], expected, fmt), ...)
7299
end
73100
74101
function assertions:True(t, actual, ...)
75102
if actual then
76103
return true
77104
end
78-
return self:Fail(t, string.format([[expected true; got %s]] .. '\n', actual), ...)
105+
return self:Fail(t, string.format([[
106+
107+
Error: Should be true
108+
Messages: ]]), ...)
79109
end
80110
81111
function assertions:Truef(t, actual, fmt, ...)
82112
if actual then
83113
return true
84114
end
85-
return self:Failf(t, string.format([[expected true; got %s%s%s]], actual, '\n', fmt), ...)
115+
return self:Failf(t, string.format([[
116+
117+
Error: Should be true
118+
Messages: %s
119+
]], fmt), ...)
120+
86121
end
87122
88123
function assertions:False(t, actual, ...)
89124
if not actual then
90125
return true
91126
end
92-
return self:Fail(t, string.format([[expected false; got %s]] .. '\n', actual), ...)
127+
return self:Fail(t, string.format([[
128+
129+
Error Should be false
130+
Messages: ]]), ...)
93131
end
94132
95133
function assertions:Falsef(t, actual, fmt, ...)
96134
if not actual then
97135
return true
98136
end
99-
return self:Failf(t, string.format([[expected false; got %s%s%s]], actual, '\n', fmt), ...)
137+
return self:Failf(t, string.format([[
138+
139+
Error: Should be false
140+
Messages: %s
141+
]], fmt), ...)
100142
end
101143
102144
return assertions

tests/lua_const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// GENERATED BY textFileToGoConst
22
// GitHub: github.com/logrusorgru/textFileToGoConst
33
// input file: suite.lua
4-
// generated: Fri Nov 11 12:44:57 PST 2022
4+
// generated: Fri Nov 11 18:08:04 PST 2022
55

66
package tests
77

tests/require_const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// GENERATED BY textFileToGoConst
22
// GitHub: github.com/logrusorgru/textFileToGoConst
33
// input file: require.lua
4-
// generated: Fri Nov 11 12:45:00 PST 2022
4+
// generated: Fri Nov 11 18:08:06 PST 2022
55

66
package tests
77

tests/testutil.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ func RunLuaTestFile(t *testing.T, preload PreloadFunc, filename string) (numTest
263263

264264
registerTType(L)
265265
PreloadSuite(L)
266-
//PreloadAssertions(L)
267-
//PreloadAssert(L)
268-
//PreloadRequire(L)
266+
PreloadAssertions(L)
267+
PreloadAssert(L)
268+
PreloadRequire(L)
269269
require.NotNil(t, preload)
270270
preload(L)
271271
L.SetGlobal("t", tLua(L, t))

0 commit comments

Comments
 (0)