This module contains testcases for its parent module, UnitTests.
See also
-- <nowiki>
-- Example Unit tests for [[Module:UnitTests]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local mw_getTitle = mw.title.getCurrentTitle().baseText
function p._test(frame)
return
"# " .. mw_getTitle .. "\n" ..
""
end
function p1(frame)
return frame:preprocess('{{#invoke:UnitTests/testcases | _test}}')
end
function p2(frame)
return frame:preprocess('{{#invoke:UnitTests/testcases/frame | _test}}')
end
function p:test()
local testcases_expected_result = "" ..
"# Module talk:UnitTests/testcases\n" ..
""
self:preprocess_equals('{{#invoke:UnitTests/testcases | _test}}',
p1(self.frame) ..
"")
local testcases_frame_expected_result = "" ..
"# Module talk:UnitTests/testcases\n" ..
""
self:preprocess_equals(p2(self.frame), "\n" ..
testcases_frame_expected_result ..
"")
self:equals(mw.text.nowiki("frame:preprocess( '{{#invoke:UnitTests/testcases/frame | _test}}' )"),
self.frame:preprocess( '{{#invoke:UnitTests/testcases/frame | _test}}' ),
"\n" ..
testcases_frame_expected_result ..
"")
self:equals(mw.text.nowiki("frame:preprocess( '{{#invoke:UnitTests/testcases/frame | _test}}' )"),
p2(self.frame),
"\n" ..
testcases_frame_expected_result ..
"")
self:equals(mw.text.nowiki("require('Module:UnitTests/testcases/frame')._test(frame)"),
"\n"..require('Module:UnitTests/testcases/frame')._test(self.frame),
"\n" ..
testcases_expected_result ..
"")
self:equals("p._test(frame)",
"\n" .. p._test(self.frame),
"\n" ..
'# UnitTests\n' ..
"")
end
return p