if mw.title.getCurrentTitle.prefixedText
function p.main return "
This does nothing as of right now. "..os.time.."
"end
function p.Debug(arg1, arg2) -- General-purpose debugger/testing tool; combines multiple submodules -- Runs CodeAnalysis and Benchmarker -- Benchmarker expects either p and the module name or the return function and the module name -- This is to be required in the module, not `#invoke:`ed require('Module:Module wikitext')._addText('') local Hook = require("Module:Sandbox/Aidan9382/Benchmarker") local t = type(arg1)
"nil" and or nil if t then return Hook(t, arg2 or "root module") elseif type(arg1)
function p.parentingLogic(frame) --Note: Not even sure this thing goes beyond 1 parent, but have overcomplicated code anyways local parentChain = local newframe = frame while true do local parent = newframe:getParent if not parent then break end newframe = parent parentChain[#parentChain+1] = parent end local parentText = "" for i,p in next,parentChain do parentText = parentText .. " parent"..i.."="..p:getTitle end return "frame="..frame:getTitle..parentText.." mw.gct="..mw.title.getCurrentTitle.textend
p["module-use"] = function(frame) local parentLogicStuff = p.parentingLogic(frame) local testlogic = "\n\n" local i = 1 while true do local c = frame.args["_test"..i] if c then testlogic = testlogic .. "_test"..i.."="..c else break end i = i + 1 end return parentLogicStuff..testlogicend
function p.getargs(frame) local text = "Frame arguments:" for k,v in pairs(frame.args) do k,v = tostring(k), tostring(v) text = text .. "\n\n'" .. mw.text.nowiki(mw.text.unstrip(k)) .. "
' = '" .. mw.text.nowiki(mw.text.unstrip(v)) .. "
'" end return textend
function p.testGP(frame) local s1 = "Frame args:" local s2 = "getParameters args:" local p1 = frame.args local p2 = require("Module:GetParameters").getParameters(p1,) for k,v in pairs(p1) do s1 = s1 .. "\n'" .. tostring(k) .. "' = '" .. v .. "'" end for k,v in pairs(p2) do s2 = s2 .. "\n'" .. tostring(k) .. "' = '" .. v .. "'" end return s1 .. "\n\n" .. s2 .. "\n\n\n"end
function p.testframe(options) --For the Debug console - easy way into template entry points --To be invoked with the wanted arguments and page titles, or none for the default. --Setting .args after testframe has been called is allowed but discouraged over simply --calling the function with provided arguments so as to match the real functionality local options = options or local base = mw.getCurrentFrame
local childArgs = options.args or local parentArgs = options.parentArgs or childArgs local childTitle = options.title or base:getTitle local parentTitle = options.parentTitle
local parentFrame = base:newChild local childFrame = parentFrame:newChild
--Hide the extra parents, which would be unexpected outside of a debug setting parentFrame.getParent = function return nil end --This 2nd hook is required, or else childFrame:getParent somehow returns --the unmodified parent frame, which doesn't have the getParent hook. :/ childFrame.getParent = function return parentFrame end
return childFrameend
function p.magicWordTests(frame) local args = frame.args if args.process
"y" then return frame:preprocess("") else return "" endend
function p.magicWordTests2(frame) local args = frame.args if args.process
"y" then return frame:preprocess("") else return "" endend
function p.substMagic(frame) local arg = tonumber(frame.args[1]) or 0 return ""end
function p.SpeedTest(frame) local text = mw.text.unstripNoWiki(frame.args[1]) local out = "" for i = 1, tonumber(frame.args[2]) or 10 do local r = tostring(math.random) out = out .. string.sub(frame:preprocess(text..r),1,-(1+#r)) .. (frame.args[3] or "\n") end return outend
function p.SpeedTestNoRandom(frame) local text = mw.text.unstripNoWiki(frame.args[1]) local out = "" for i = 1, tonumber(frame.args[2]) or 10 do out = out .. frame:preprocess(text) .. (frame.args[3] or "\n") end return outend
function p.AnalysisTest repeat local x = 5 until x
function p.WasteExecutionTime(frame) local t = tonumber(frame.args[1]) or 0 local start = os.clock while os.clock-start < t do end return "Wasted " .. (os.clock-start) .. " seconds"end
p["+expensive"] = function mw.incrementExpensiveFunctionCount return ""end
function p:namecall return selfend
return setmetatable(p,)