• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
m
Reverted edits by IloveSuiseiseki (talk) to last version by がか
Line 187: Line 187:  
     else
 
     else
 
         return success, data
 
         return success, data
 +
    end
 +
end
 +
 +
-- * Testing functions.
 +
 +
function Utils.debugPrint(x, i)
 +
    i = i or 0
 +
    if type(x) == "table" then
 +
        for k, v in pairs(x) do
 +
            mw.log(
 +
                string.rep("  ", i) .. tostring(k) .. " : " .. type(k) .. " = " ..
 +
                (type(v) == "table" and "table" or tostring(v) .. " : " .. type(v))
 +
            )
 +
            if type(v) == "table" then
 +
                debugPrint(v, i + 1)
 +
            end
 +
        end
 +
    else
 +
        mw.log(tostring(x) .. " : " .. type(x))
 +
    end
 +
end
 +
 +
function Utils.registerFormatTests(obj, tests, fn)
 +
    obj.run_format_tests = function()
 +
        for _, test in ipairs(tests) do
 +
            local result = obj.format(nil, test)
 +
            mw.log(fn and fn(result) or result)
 +
        end
 +
    end
 +
end
 +
 +
function Utils.registerTableTests(obj, tests, fn)
 +
    obj.run_table_tests = function()
 +
        for _, test in ipairs(tests) do
 +
            local result = obj:Table(test)
 +
            mw.log(fn and fn(result) or result)
 +
        end
 
     end
 
     end
 
end
 
end
    
return Utils
 
return Utils
cssedit, gkautomate
7,064

edits

Navigation menu