Модуль:Testcase
Перейти к навигации
Перейти к поиску
Документация
Этому модулю не хватает документации. |
local p = {}
function p.tableRow(frame)
local is_template_exists = false
local BASEPAGE = mw.title.getCurrentTitle().baseText
local template_args, tlp_args, result = {}, {}, ""
for k, v in pairs(frame:getParent().args)
do
tlp_args[k] = v
if type(k) == "number" then k = k - 1 end
if k == 0 then -- первый параметр
result = v
else
template_args[k] = v
end
end
-- получаем результаты шаблонов
local is_template_exists, resultTemplate = pcall(frame.expandTemplate, frame, {title=BASEPAGE, args=template_args})
local is_sandbox_exists, resultSandbox = pcall(frame.expandTemplate, frame, {title=BASEPAGE.."/песочница", args=template_args})
local is_equalTemplate = ""
if is_template_exists then
is_equalTemplate = is_equal(result, resultTemplate)
tlp_args[1] = BASEPAGE
else
tlp_args[1] = BASEPAGE .. "/песочница"
end
local tr = mw.html.create('tr')
tr:tag('td'):wikitext(frame:expandTemplate{title="tlp", args=tlp_args})
tr:tag('td'):wikitext(resultSandbox)
tr:tag('td'):wikitext(result)
tr:tag('td'):wikitext(is_equalTemplate)
tr:tag('td'):wikitext(is_equal(result, resultSandbox))
local html = tostring(tr)
html = html:gsub('</tr>', '') -- убираем закрывающий тег, чтобы можно было дополнять таблицу
return html
end
function is_equal(wait, result)
local title = "Не сделано"
if mw.text.trim(wait) == mw.text.trim(result) then title = "Сделано" end
return mw.getCurrentFrame():expandTemplate{title=title, args={""}}
end
return p