20 tests failed. (refresh)

Text Expected Actual
test01_basic:
Failed mut.getRow({"!", "rubrik", '|rowspan="2"'}, "form1", "form2", "form3") |-

!|rubrik |rowspan="2"|<span class="infl">[[form1]]</span> ||<span class="infl">[[form2]]</span> ||<span class="infl">[[form3]]</span> || |- !|rubrik |rowspan="2"|<span data-grammar-link="infl">[[form1]]</span> ||<span data-grammar-link="infl">[[form2]]</span> ||<span data-grammar-link="infl">[[form3]]</span>

Failed mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]") |-

||<span class="adv">[[form1]]</span>, <span class="adv">[[form2]]</span> ||<span class="infl">[[form3]]</span>, <span class="infl">[[form4]]</span> || |- ||<span data-grammar-link="adv">[[form1]]</span>, <span data-grammar-link="adv">[[form2]]</span> ||<span data-grammar-link="infl">[[form3]]</span>, <span data-grammar-link="infl">[[form4]]</span>

Failed mut.getRow("form1, form2") |-

||<span class="infl">[[form1]]</span>, <span class="infl">[[form2]]</span> || |- ||<span data-grammar-link="infl">[[form1]]</span>, <span data-grammar-link="infl">[[form2]]</span>

Text Expected Actual
test02_only_content:
Failed mut.getRow("form1", "form2", "form3") |-

||<span class="infl">[[form1]]</span> ||<span class="infl">[[form2]]</span> ||<span class="infl">[[form3]]</span> || |- ||<span data-grammar-link="infl">[[form1]]</span> ||<span data-grammar-link="infl">[[form2]]</span> ||<span data-grammar-link="infl">[[form3]]</span>

Text Expected Actual
test03_only_meta:
Passed mut.getRow({"!"}, {"|rowspan=2"}, {'|class="min"'}) |-

!|&nbsp; |rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] |class="min"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] || |- !|&nbsp; |rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] |class="min"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]

Text Expected Actual
test04_only_meta_and_type:
Passed mut.getRow({"!", type="no-link"}, {'|rowspan="2"', type="no-link"}) |-

!|&nbsp; |rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] || |- !|&nbsp; |rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]

Text Expected Actual
test05_no_extra_links:
Failed mut.getRow("[[form1]], form2") |-

||<span class="infl">[[form1]]</span>, <span class="infl">[[form2]]</span> || |- ||<span data-grammar-link="infl">[[form1]]</span>, <span data-grammar-link="infl">[[form2]]</span>

Failed mut.getRow("[[form1]]<sup>1</sup>") |-

||<span class="infl">[[form1]]</span><sup>1</sup> || |- ||<span data-grammar-link="infl">[[form1]]</span><sup>1</sup>

Failed mut.getRow("[[form1]], vard. [[form2]]") |-

||<span class="infl">[[form1]]</span>, vard. <span class="infl">[[form2]]</span> || |- ||<span data-grammar-link="infl">[[form1]]</span>, vard. <span data-grammar-link="infl">[[form2]]</span>

Failed mut.getRow("([[form1]])") |-

||'''('''<span class="infl">[[form1]]</span>''')''' || |- ||'''('''<span data-grammar-link="infl">[[form1]]</span>''')'''

Failed mut.getRow("[[form1|fōrm1]]") |-

||<span class="infl">[[form1|fōrm1]]</span> || |- ||<span data-grammar-link="infl">[[form1|fōrm1]]</span>

Failed mut.getRow("<nowiki/>form1, form2")
Med nowiki i modul
|-

||<nowiki/>form1, <span class="infl">[[form2]]</span> || |- ||<nowiki/>form1, <span data-grammar-link="infl">[[form2]]</span>

Failed mut.getRow("<nowiki/>form1, form2")
Med nowiki i mall
|-

||"`UNIQ--nowiki-00000001-QINU`"'form1, <span class="infl">[[form2]]</span> || |- ||"`UNIQ--nowiki-00000001-QINU`"'form1, <span data-grammar-link="infl">[[form2]]</span>

Text Expected Actual
test06_multiple_words:
Passed mut.getRow("ord1 ord2") |-

||ord1 ord2 || |- ||ord1 ord2

Text Expected Actual
test07_special_cases:
Passed mut.getRow(nil) |- |-
Passed mut.getRow("") |-

||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] || |- ||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]

Passed mut.getRow("-") |-

||– || |- ||–

Passed mut.getRow("?") |-

||? || |- ||?

Passed ", type="no-link"})) |-

||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] || |- ||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]

Passed ", "", type="no-link"})) |-

||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]] || |- ||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]

Passed ", "-", type="no-link"})) |-

||– || |- ||–

Passed ", "?", type="no-link"})) |-

||? || |- ||?

Text Expected Actual
test_08_words_containg_special_chars:
Failed mut.getRow("e-post") |-

||<span class="infl">[[e-post]]</span> || |- ||<span data-grammar-link="infl">[[e-post]]</span>

Failed mut.getRow("word's") |-

||<span class="infl">[[word's]]</span> || |- ||<span data-grammar-link="infl">[[word's]]</span>

Failed mut.getRow("words'") |-

||<span class="infl">[[words']]</span> || |- ||<span data-grammar-link="infl">[[words']]</span>

Failed mut.getRow("tv:n") |-

||<span class="infl">[[tv:n]]</span> || |- ||<span data-grammar-link="infl">[[tv:n]]</span>

Failed mut.getRow("[[Övriga_uppslagsord#EU:s|EU:s]]") |-

||<span class="infl">[[Övriga_uppslagsord#EU:s|EU:s]]</span> || |- ||<span data-grammar-link="infl">[[Övriga_uppslagsord#EU:s|EU:s]]</span>

Failed mut.getRow("''[[Betula]]''") |-

||''<span class="infl">[[Betula]]</span>'' || |- ||''<span data-grammar-link="infl">[[Betula]]</span>''

Text Expected Actual
test_09_basic_with_lang_code:
Passed mut.setLanguage("de") (nil) (nil)
Failed mut.getRow({"!", "rubrik", '|rowspan="2"'}, "form1", "form2", "form3") |-

!|rubrik |rowspan="2"|<span class="infl">[[form1#Tyska|form1]]</span> ||<span class="infl">[[form2#Tyska|form2]]</span> ||<span class="infl">[[form3#Tyska|form3]]</span> || |- !|rubrik |rowspan="2"|<span data-grammar-link="infl">[[form1#Tyska|form1]]</span> ||<span data-grammar-link="infl">[[form2#Tyska|form2]]</span> ||<span data-grammar-link="infl">[[form3#Tyska|form3]]</span>

Failed mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]") |-

||<span class="adv">[[form1#Tyska|form1]]</span>, <span class="adv">[[form2#Tyska|form2]]</span> ||<span class="infl">[[form3#Tyska|form3]]</span>, <span class="infl">[[form4#Tyska|form4]]</span> || |- ||<span data-grammar-link="adv">[[form1#Tyska|form1]]</span>, <span data-grammar-link="adv">[[form2#Tyska|form2]]</span> ||<span data-grammar-link="infl">[[form3#Tyska|form3]]</span>, <span data-grammar-link="infl">[[form4#Tyska|form4]]</span>

Failed mut.getRow("form1, form2") |-

||<span class="infl">[[form1#Tyska|form1]]</span>, <span class="infl">[[form2#Tyska|form2]]</span> || |- ||<span data-grammar-link="infl">[[form1#Tyska|form1]]</span>, <span data-grammar-link="infl">[[form2#Tyska|form2]]</span>

local t = require("Modul:UnitTests")
local mut = require("Modul:grammar-table")

local nowiki = function(s)
	return s:gsub('[\r\n][!]', {["\n!"] = "\n !", ["\r!"] = "\r !"})
end

function t:test01_basic()
	self:equals('<nowiki>mut.getRow({"!", "rubrik", \'|rowspan="2"\'}, "form1", "form2", "form3")</nowiki>', nowiki(mut.getRow({"!", "rubrik"}, {'|rowspan="2"', "form1"}, "form2", "form3")), nowiki('|-\n!|rubrik\n|rowspan="2"|<span class="infl">[[form1]]</span>\n||<span class="infl">[[form2]]</span>\n||<span class="infl">[[form3]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]")</nowiki>', mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]"), '|-\n||<span class="adv">[[form1]]</span>, <span class="adv">[[form2]]</span>\n||<span class="infl">[[form3]]</span>, <span class="infl">[[form4]]</span>\n', {nowiki=1})
	self:equals('<nowiki>mut.getRow("form1, form2")</nowiki>', nowiki(mut.getRow("form1, form2")), nowiki('|-\n||<span class="infl">[[form1]]</span>, <span class="infl">[[form2]]</span>\n'), {nowiki=1})
end

function t:test02_only_content()
	self:equals('mut.getRow("form1", "form2", "form3")', nowiki(mut.getRow("form1", "form2", "form3")), nowiki('|-\n||<span class="infl">[[form1]]</span>\n||<span class="infl">[[form2]]</span>\n||<span class="infl">[[form3]]</span>\n'), {nowiki=1})
end

function t:test03_only_meta()
	self:equals('<nowiki>mut.getRow({"!"}, {"|rowspan=2"}, {\'|class="min"\'})</nowiki>', nowiki(mut.getRow({"!"}, {'|rowspan="2"'}, {'|class="min"'})), nowiki('|-\n!|&nbsp;\n|rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n|class="min"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
end

function t:test04_only_meta_and_type()
	self:equals('<nowiki>mut.getRow({"!", type="no-link"}, {\'|rowspan="2"\', type="no-link"})</nowiki>', nowiki(mut.getRow({"!", type="no-link"}, {'|rowspan="2"', type="no-link"})), nowiki('|-\n!|&nbsp;\n|rowspan="2"|&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
end

function t:test05_no_extra_links()
	self:equals('<nowiki>mut.getRow("[[form1]], form2")</nowiki>', nowiki(mut.getRow("[[form1]], form2")), nowiki('|-\n||<span class="infl">[[form1]]</span>, <span class="infl">[[form2]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow("[[form1]]<sup>1</sup>")</nowiki>', nowiki(mut.getRow("[[form1]]<sup>1</sup>")), nowiki('|-\n||<span class="infl">[[form1]]</span><sup>1</sup>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow("[[form1]], vard. [[form2]]")</nowiki>', nowiki(mut.getRow("[[form1]], vard. [[form2]]")), nowiki('|-\n||<span class="infl">[[form1]]</span>, vard. <span class="infl">[[form2]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow("([[form1]])")</nowiki>', nowiki(mut.getRow("([[form1]])")), nowiki("|-\n||'''('''<span class=\"infl\">[[form1]]</span>''')'''\n"), {nowiki=1})
	self:equals('<nowiki>mut.getRow("[[form1|fōrm1]]")</nowiki>', nowiki(mut.getRow("[[form1|fōrm1]]")), nowiki('|-\n||<span class="infl">[[form1|fōrm1]]</span>\n'), {nowiki=1})
--	self:equals('<nowiki>mut.getRow("[[form1]]<ref>[[Källa]]</ref>")</nowiki>', nowiki(mut.getRow("[[form1]]<ref>[[Källa]]</ref>")), nowiki('|-\n||<span class="infl">[[form1]]</span><ref>[[Källa]]</ref>\n'), {nowiki=1}) -- inaktiverad tills vi vet hur vi vill ha det
	self:equals([[<nowiki>mut.getRow("<nowiki/>form1, form2")</nowiki><br>''Med nowiki i modul'']], nowiki(mut.getRow("<nowiki/>form1, form2")), nowiki('|-\n||<nowiki/>form1, <span class="infl">[[form2]]</span>\n'), {nowiki=1})
	
	local uniq_nowiki = "\127\"`UNIQ--nowiki-00000001-QINU`\"'\127"
	self:equals([[<nowiki>mut.getRow("<nowiki/>form1, form2")</nowiki><br>''Med nowiki i mall'']], nowiki(mut.getRow(uniq_nowiki .. "form1, form2")), nowiki('|-\n||' .. uniq_nowiki .. 'form1, <span class="infl">[[form2]]</span>\n'), {nowiki=1})
end

function t:test06_multiple_words()
	-- TODO eller ska dom länkas?
	self:equals('<nowiki>mut.getRow("ord1 ord2")</nowiki>', nowiki(mut.getRow("ord1 ord2")), nowiki('|-\n||ord1 ord2\n'), {nowiki=1})
end

function t:test07_special_cases()
	--self:equals('mut.getRow({})', nowiki(mut.getRow({})), nowiki('|-\n||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
	self:equals('mut.getRow(nil)', nowiki(mut.getRow(nil)), nowiki('|-\n'), {nowiki=1})
	self:equals('mut.getRow("")', nowiki(mut.getRow("")), nowiki('|-\n||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
	self:equals('mut.getRow("-")', nowiki(mut.getRow("-")), nowiki('|-\n||–\n'), {nowiki=1})
	self:equals('mut.getRow("?")', nowiki(mut.getRow("?")), nowiki('|-\n||?\n'), {nowiki=1})
	self:equals('mut.getRow({"|", type="no-link"}))', nowiki(mut.getRow({"|", type="no-link"})), nowiki('|-\n||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
	self:equals('mut.getRow({"|", "", type="no-link"}))', nowiki(mut.getRow({"|", "", type="no-link"})), nowiki('|-\n||&nbsp;[[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
	self:equals('mut.getRow({"|", "-", type="no-link"}))', nowiki(mut.getRow({"|", "-", type="no-link"})), nowiki('|-\n||–\n'), {nowiki=1})
	self:equals('mut.getRow({"|", "?", type="no-link"}))', nowiki(mut.getRow({"|", "?", type="no-link"})), nowiki('|-\n||?\n'), {nowiki=1})
end

function t:test_08_words_containg_special_chars()
	self:equals('mut.getRow("e-post")', nowiki(mut.getRow("e-post")), nowiki('|-\n||<span class="infl">[[e-post]]</span>\n'), {nowiki=1})
	self:equals('mut.getRow("word\'s")', nowiki(mut.getRow("word's")), nowiki('|-\n||<span class="infl">[[word\'s]]</span>\n'), {nowiki=1})
	self:equals('mut.getRow("words\'")', nowiki(mut.getRow("words'")), nowiki('|-\n||<span class="infl">[[words\']]</span>\n'), {nowiki=1})
	self:equals('mut.getRow("tv:n")', nowiki(mut.getRow("tv:n")), nowiki('|-\n||<span class="infl">[[tv:n]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow("[[Övriga_uppslagsord#EU:s|EU:s]]</nowiki>")', nowiki(mut.getRow("[[Övriga_uppslagsord#EU:s|EU:s]]")), nowiki('|-\n||<span class="infl">[[Övriga_uppslagsord#EU:s|EU:s]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow("\'\'[[Betula]]\'\'</nowiki>")', nowiki(mut.getRow("''[[Betula]]''")), nowiki('|-\n||\'\'<span class="infl">[[Betula]]</span>\'\'\n'), {nowiki=1})
end

function t:test_09_basic_with_lang_code()
	self:equals('mut.setLanguage("de")', mut.setLanguage("de"), nil, {nowiki=1})
	self:equals('<nowiki>mut.getRow({"!", "rubrik", \'|rowspan="2"\'}, "form1", "form2", "form3")</nowiki>', nowiki(mut.getRow({"!", "rubrik"}, {'|rowspan="2"', "form1"}, "form2", "form3")), nowiki('|-\n!|rubrik\n|rowspan="2"|<span class="infl">[[form1#Tyska|form1]]</span>\n||<span class="infl">[[form2#Tyska|form2]]</span>\n||<span class="infl">[[form3#Tyska|form3]]</span>\n'), {nowiki=1})
	self:equals('<nowiki>mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]")</nowiki>', mut.getRow({"|", "[[form1]], [[form2]]", type="adv"}, "[[form3]], [[form4]]"), '|-\n||<span class="adv">[[form1#Tyska|form1]]</span>, <span class="adv">[[form2#Tyska|form2]]</span>\n||<span class="infl">[[form3#Tyska|form3]]</span>, <span class="infl">[[form4#Tyska|form4]]</span>\n', {nowiki=1})
	self:equals('<nowiki>mut.getRow("form1, form2")</nowiki>', nowiki(mut.getRow("form1, form2")), nowiki('|-\n||<span class="infl">[[form1#Tyska|form1]]</span>, <span class="infl">[[form2#Tyska|form2]]</span>\n'), {nowiki=1})
end

return t