Module:UnitTests/testcases

-- Example Unit tests for Module:UnitTests. Click talk page to run tests. local p = require('Module:UnitTests')

local frame0 = mw.getCurrentFrame local frame0_getTitle = frame0:getTitle local getCurrentFrame_getTitle = mw.getCurrentFrame:getTitle local arg = ...

function p._test(frame) return "# " .. frame:getTitle .. "\n" .. "# " .. frame0:getTitle .. "\n" .. "# " .. frame0_getTitle .. "\n" .. "# " .. getCurrentFrame_getTitle .. "\n" .. "# " .. mw.dumpObject(arg) .. "\n" .. "" end

function p._test0(frame) return "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. "# nil\n" .. "" end

function p.preprocess(frame) --return frame.args[1] return frame:preprocess(frame.args[1]) end

function p.p1(frame) return frame:preprocess('') end

function p.p2(frame) return frame:preprocess('') end

function p:test local testcases_expected_result = "" .. "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. "# Module:UnitTests/testcases\n" .. ""	self:preprocess_equals('', "\n" ..		testcases_expected_result ..		"# nil\n" ..	"") local testcases_frame_expected_result = "" .. "# Module:UnitTests/testcases/frame\n" .. "# Module:UnitTests/testcases/frame\n" .. "# Module:UnitTests/testcases/frame\n" .. "# Module:UnitTests/testcases/frame\n" .. ""	self:preprocess_equals('', "\n" ..		testcases_frame_expected_result ..		"# nil\n" ..	"") self:equals(" mw.getCurrentFrame:preprocess(  ) ",		mw.getCurrentFrame:preprocess(  ),		"\n" ..		testcases_frame_expected_result ..		"# nil\n" ..	"") self:equals(" frame0:preprocess(  ) ",		frame0:preprocess(  ),		"\n" ..		testcases_frame_expected_result ..		"# nil\n" ..	"") --self:equals(" frame0:expandTemplate{ title = ' self:equals("require('Module:UnitTests/testcases/frame')._test(mw.getCurrentFrame)",		"\n"..require('Module:UnitTests/testcases/frame')._test(mw.getCurrentFrame),		"\n" ..		testcases_expected_result ..		'# "Module:UnitTests/testcases/frame"\n' ..	"") self:equals("p._test(frame0)",		"\n"..p._test(frame0),		"\n" ..		testcases_expected_result ..		"# nil\n" ..	"") self:equals("p._test(mw.getCurrentFrame)",		"\n"..p._test(mw.getCurrentFrame),		"\n" ..		testcases_expected_result ..		"# nil\n" ..	"") --self:preprocess_equals('', "\n" ..		testcases_expected_result ..		" end

return p