Module:Sandbox/Vergir: Difference between revisions

Vergir (talk | contribs)
Improve verification harness: plain-text output and scaling diagnostic (with help from vergir-bot LLM)
Vergir (talk | contribs)
Use stub frame so harness output is plain text (with help from vergir-bot LLM)
Line 3: Line 3:


local GameData = require("Module:GameData")
local GameData = require("Module:GameData")
-- A stand-in frame whose expandTemplate returns the bare argument, so the
-- module's output stays plain text instead of parser strip markers.
local stub = {
    expandTemplate = function(self, args) return args.args[1] end,
}


function p.check(frame)
function p.check(frame)
     local out = require("Module:ArcaneSurge").render(frame)
     local out = require("Module:ArcaneSurge").render(stub)


     local lines, heroes, notes = {}, 0, 0
     local heroes, abilities, notes = 0, 0, 0
    local lines = {}
     for item in out:gmatch("<li>(.-)</li>") do
     for item in out:gmatch("<li>(.-)</li>") do
         heroes = heroes + 1
         heroes = heroes + 1
         local text = item:gsub("<!%-%-.-%-%->", ""):gsub("<[^>]*>", "")
         for _ in item:gmatch("%(after T") do notes = notes + 1 end
         text = text:gsub("%s+", " "):gsub("^%s+", ""):gsub("%s+$", "")
         local _, commas = item:gsub(", ", "")
         for _ in text:gmatch("%(after T") do notes = notes + 1 end
         abilities = abilities + commas + 1
         table.insert(lines, text)
         table.insert(lines, item)
     end
     end


     return "<pre>heroes=" .. heroes .. " notes=" .. notes .. "\n\n"
     return "<pre>heroes=" .. heroes .. " abilities=" .. abilities
        .. " notes=" .. notes .. "\n\n"
         .. mw.text.encode(table.concat(lines, "\n")) .. "</pre>"
         .. mw.text.encode(table.concat(lines, "\n")) .. "</pre>"
end
end