Modul:grammar-table/test
20 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
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> | ||
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> | ||
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 | |
---|---|---|---|
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 | |
---|---|---|---|
mut.getRow({"!"}, {"|rowspan=2"}, {'|class="min"'}) | |-
!| |rowspan="2"| [[Kategori:Wiktionary:Sidor med tomma celler]] |class="min"| [[Kategori:Wiktionary:Sidor med tomma celler]] || |- !| |rowspan="2"| [[Kategori:Wiktionary:Sidor med tomma celler]] |class="min"| [[Kategori:Wiktionary:Sidor med tomma celler]] |
Text | Expected | Actual | |
---|---|---|---|
mut.getRow({"!", type="no-link"}, {'|rowspan="2"', type="no-link"}) | |-
!| |rowspan="2"| [[Kategori:Wiktionary:Sidor med tomma celler]] || |- !| |rowspan="2"| [[Kategori:Wiktionary:Sidor med tomma celler]] |
Text | Expected | Actual | |
---|---|---|---|
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> | ||
mut.getRow("[[form1]]<sup>1</sup>") | |-
||<span class="infl">[[form1]]</span><sup>1</sup> || |- ||<span data-grammar-link="infl">[[form1]]</span><sup>1</sup> | ||
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> | ||
mut.getRow("([[form1]])") | |-
||'''('''<span class="infl">[[form1]]</span>''')''' || |- ||'''('''<span data-grammar-link="infl">[[form1]]</span>''')''' | ||
mut.getRow("[[form1|fōrm1]]") | |-
||<span class="infl">[[form1|fōrm1]]</span> || |- ||<span data-grammar-link="infl">[[form1|fōrm1]]</span> | ||
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> | ||
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 | |
---|---|---|---|
mut.getRow("ord1 ord2") | |-
||ord1 ord2 || |- ||ord1 ord2 |
Text | Expected | Actual | |
---|---|---|---|
mut.getRow(nil) | |- | |- | |
mut.getRow("") | |-
|| [[Kategori:Wiktionary:Sidor med tomma celler]] || |- || [[Kategori:Wiktionary:Sidor med tomma celler]] | ||
mut.getRow("-") | |-
||– || |- ||– | ||
mut.getRow("?") | |-
||? || |- ||? | ||
", type="no-link"})) | |-
|| [[Kategori:Wiktionary:Sidor med tomma celler]] || |- || [[Kategori:Wiktionary:Sidor med tomma celler]] | ||
", "", type="no-link"})) | |-
|| [[Kategori:Wiktionary:Sidor med tomma celler]] || |- || [[Kategori:Wiktionary:Sidor med tomma celler]] | ||
", "-", type="no-link"})) | |-
||– || |- ||– | ||
", "?", type="no-link"})) | |-
||? || |- ||? |
Text | Expected | Actual | |
---|---|---|---|
mut.getRow("e-post") | |-
||<span class="infl">[[e-post]]</span> || |- ||<span data-grammar-link="infl">[[e-post]]</span> | ||
mut.getRow("word's") | |-
||<span class="infl">[[word's]]</span> || |- ||<span data-grammar-link="infl">[[word's]]</span> | ||
mut.getRow("words'") | |-
||<span class="infl">[[words']]</span> || |- ||<span data-grammar-link="infl">[[words']]</span> | ||
mut.getRow("tv:n") | |-
||<span class="infl">[[tv:n]]</span> || |- ||<span data-grammar-link="infl">[[tv:n]]</span> | ||
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> | ||
mut.getRow("''[[Betula]]''") | |-
||''<span class="infl">[[Betula]]</span>'' || |- ||''<span data-grammar-link="infl">[[Betula]]</span>'' |
Text | Expected | Actual | |
---|---|---|---|
mut.setLanguage("de") | (nil) | (nil) | |
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> | ||
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> | ||
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!| \n|rowspan="2"| [[Kategori:Wiktionary:Sidor med tomma celler]]\n|class="min"| [[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!| \n|rowspan="2"| [[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|| [[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|| [[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|| [[Kategori:Wiktionary:Sidor med tomma celler]]\n'), {nowiki=1})
self:equals('mut.getRow({"|", "", type="no-link"}))', nowiki(mut.getRow({"|", "", type="no-link"})), nowiki('|-\n|| [[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