20 of 38 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
anchor | |||
{{l|en|-er#Etymology 2|-er}} | <span class="Latn" lang="en">[[-er#Etymology 2|-er]]</span> | <span class="Latn" lang="en">[[-er#Etymology 2|-er]]</span> | |
{{l|en|[[-er#Etymology 2|-er]]}} | <span class="Latn" lang="en">[[-er#Etymology 2|-er]]</span> | <span class="Latn" lang="en">[[-er#Etymology 2|-er]]</span> | |
character entity references in link target | |||
{{l|nia|wa'a}} | <span class="Latn" lang="nia">[[wa'a#Nias|wa'a]]</span> | <span class="Latn" lang="nia">[[wa'a#Nias|wa'a]]</span> | |
{{l|nia|wa'a}} | <span class="Latn" lang="nia">[[wa'a#Nias|wa'a]]</span> | <span class="Latn" lang="nia">[[wa'a#Nias|wa'a]]</span> | |
{{l|ja|恵‌美|恵&#8204;美}} | <span class="Jpan" lang="ja">[[恵美#Japanese|恵&#8204;美]]</span> | <span class="Jpan" lang="ja">[[恵美#Japanese|恵<span style="color: red;"></span>美]]</span> | |
{{l|en|&}} | <span class="None" lang="en">[[Unsupported titles/Amp#English|&]]</span> | <span class="None" lang="en">[[<span style="color: red;">&</span>amp;#English|&]]</span> | |
simple linking | |||
{{l|la|verbum}} | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> | |
using wikilinks | |||
{{l|en|[] be [] []}} | <span class="Latn" lang="en">[[God#English|God]] be [[with#English|with]] [[you#English|you]]</span> | <span class="Latn" lang="en">[[God#English|God]] be [[with#English|with]] [[you#English|you]]</span> | |
alternative text | |||
{{l|en|go|went}} | <span class="Latn" lang="en">[[go#English|went]]</span> | <span class="Latn" lang="en">[[go#English|went]]</span> | |
{{l|en|to []|went}} | <span class="Latn" lang="en">to [[go#English|go]]</span> | <span class="Latn" lang="en">to [[go#English|go]]</span> | |
sense id | |||
{{l|en|go|id=game}} | <span class="Latn" lang="en">[[go#English-game|go]]</span> | <span class="Latn" lang="en">[[go#English<span style="color: red;">&</span>#58;_game|go]]</span> | |
constructed terms | |||
{{l|sjn|mithril}} | <span class="Latn" lang="sjn">[[Appendix:Sindarin/mithril|mithril]]</span> | <span class="Latn" lang="sjn">[[Appendix&#<span style="color: red;">5</span>8;Sindarin/mithril|mithril]]</span> | |
reconstructed terms | |||
{{l|ine-pro|*bʰréh₂tēr}} | <span class="Latn" lang="ine-pro">[[Reconstruction:Proto-Indo-European/bʰréh₂tēr|*bʰréh₂tēr]]</span> | <span class="Latn" lang="ine-pro">[[Reconstruction&#<span style="color: red;">5</span>8;Proto-Indo-European/bʰréh₂tēr|*bʰréh₂tēr]]</span> | |
{{#iferror:{{l|ine-pro|bʰréh₂tēr}}|Script error}} | Script error | Script error | |
{{l|sla-pro|[[*dьnь]] [[*serda]]}} | <span class="Latn" lang="sla-pro">[[Reconstruction:Proto-Slavic/dьnь|*dьnь]] [[Reconstruction:Proto-Slavic/serda|*serda]]</span> | <span class="Latn" lang="sla-pro">[[Reconstruction&#<span style="color: red;">5</span>8;Proto-Slavic/dьnь|*dьnь]] [[Reconstruction:Proto-Slavic/serda|*serda]]</span> | |
{{l|la|verbum .. [] .. [[*verbum]] .. [[*verbum|verbum]] .. [[*verbum|*verba]]}} | <span class="Latn" lang="la">verbum .. [[verbum#Latin|verbum]] .. [[Reconstruction:Latin/verbum|*verbum]] .. [[Reconstruction:Latin/verbum|verbum]] .. [[Reconstruction:Latin/verbum|*verba]]</span> | <span class="Latn" lang="la">verbum .. [[verbum#Latin|verbum]] .. [[Reconstruction&#<span style="color: red;">5</span>8;Latin/verbum|*verbum]] .. [[Reconstruction:Latin/verbum|verbum]] .. [[Reconstruction:Latin/verbum|*verba]]</span> | |
{{l|sla-pro|*[]}} | <span class="Latn" lang="sla-pro">*[[Reconstruction:Proto-Slavic/serda|serda]]</span> | <span class="Latn" lang="sla-pro"><span style="color: red;">&</span>#42;[[Reconstruction:Proto-Slavic/serda|serda]]</span> | |
{{l|sla-pro|*[[*serda]] .. [[*serda]] .. [] .. [[*serda|serda]] .. [[*serda|*serda]]}} | <span class="Latn" lang="sla-pro">[[Reconstruction:Proto-Slavic/*serda|*serda]] .. [[Reconstruction:Proto-Slavic/*serda|*serda]] .. [[Reconstruction:Proto-Slavic/serda|serda]] .. [[Reconstruction:Proto-Slavic/*serda|serda]] .. [[Reconstruction:Proto-Slavic/*serda|*serda]]</span> | <span class="Latn" lang="sla-pro"><span style="color: red;">&</span>#42;[[Reconstruction:Proto-Slavic/serda|*serda]] .. [[Reconstruction:Proto-Slavic/serda|*serda]] .. [[Reconstruction:Proto-Slavic/serda|serda]] .. [[Reconstruction:Proto-Slavic/serda|serda]] .. [[Reconstruction:Proto-Slavic/serda|*serda]]</span> | |
{{l|sla-pro|*[[dьnь|alt1]] [[serda|alt2]]}} | <span class="Latn" lang="sla-pro">*[[Reconstruction:Proto-Slavic/dьnь|alt1]] [[Reconstruction:Proto-Slavic/serda|alt2]]</span> | <span class="Latn" lang="sla-pro"><span style="color: red;">&</span>#42;[[Reconstruction:Proto-Slavic/dьnь|alt1]] [[Reconstruction:Proto-Slavic/serda|alt2]]</span> | |
{{l|und|[] .. [[*unattested]] .. [[*unattested|unattested-alt]]}} | <span class="Zyyy" lang="und">[[attested|attested]] .. *unattested .. unattested-alt</span>[[Category:Undetermined language links]] | <span class="<span style="color: red;">L</span>atn" lang="und">[[attested|attested]] .. *unattested .. unattested-alt</span>[[Category:Undetermined language links]] | |
script detection | |||
{{l|sh|српски}} / {{l|sh|srpski}} | <span class="Cyrl" lang="sh">[[српски#Serbo-Croatian|српски]]</span> / <span class="Latn" lang="sh">[[srpski#Serbo-Croatian|srpski]]</span> | <span class="Cyrl" lang="sh">[[српски#Serbo-Croatian|српски]]</span> / <span class="Latn" lang="sh">[[srpski#Serbo-Croatian|srpski]]</span> | |
target page's title | |||
{{l|la|verbō}} | <span class="Latn" lang="la">[[verbo#Latin|verbō]]</span> | <span class="Latn" lang="la">[[verbo#Latin|verbō]]</span> | |
gender and number | |||
{{l|la|verbum|g=m}} | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> <span class="gender"><abbr title="masculine gender">m</abbr></span> | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> <span class="gender"><abbr title="masculine gender">m</abbr></span> | |
{{l|la|verbum|g=m|g2=f}} | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> <span class="gender"><abbr title="masculine gender">m</abbr> or <abbr title="feminine gender">f</abbr></span> | <span class="Latn" lang="la">[[verbum#Latin|verbum]]</span> <span class="gender"><abbr title="masculine gender">m</abbr> or <abbr title="feminine gender">f</abbr></span> | |
transliteration | |||
{{l|ar|كلمة|tr=kalima}} | <span class="Arab" lang="ar">[[كلمة#Arabic|كلمة]]</span>‎ <span class="mention-gloss-paren annotation-paren">(</span><span lang="ar-Latn" class="tr Latn">kalima</span><span class="mention-gloss-paren annotation-paren">)</span> | <span class="Arab" lang="ar">[[كلمة#Arabic|كلمة]]</span><span style="background-color: pink;"> </span><span class="mention-gloss-paren annotation-paren">(</span><span lang="ar-Latn" class="tr Latn">kalima</span><span class="mention-gloss-paren annotation-paren">)</span> | |
{{l|ru|русский}} | <span class="Cyrl" lang="ru">[[русский#Russian|русский]]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span><span class="mention-gloss-paren annotation-paren">)</span> | <span class="Cyrl" lang="ru">[[русский#Russian|русский]]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span><span class="mention-gloss-paren annotation-paren">)</span> | |
gloss | |||
{{l|ru|русский|gloss=Russian}} | <span class="Cyrl" lang="ru">[[русский#Russian|русский]]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span>, <span class="mention-gloss-double-quote">“</span><span class="mention-gloss">Russian</span><span class="mention-gloss-double-quote">”</span><span class="mention-gloss-paren annotation-paren">)</span> | <span class="Cyrl" lang="ru">[[русский#Russian|русский]]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span>, <span class="mention-gloss-double-quote">“</span><span class="mention-gloss">Russian</span><span class="mention-gloss-double-quote">”</span><span class="mention-gloss-paren annotation-paren">)</span> | |
Wikipedia link | |||
{{l|en|w:word}} | <span class="Latn" lang="en">[[w:word|word]]</span> | <span class="Latn" lang="en">[[<span style="color: red;">:</span>w:word|word]]</span> | |
{{l|en|[[w:English language]]}} | <span class="Latn" lang="en">[[w:English language|w:English language]]</span> | <span class="Latn" lang="en">[[<span style="color: red;">:</span>w:English language|English language]]</span> | |
{{l|en|[[wikipedia:English language]]}} | <span class="Latn" lang="en">[[wikipedia:English language|wikipedia:English language]]</span> | <span class="Latn" lang="en">[[<span style="color: red;">:</span>wikipedia:English language|English language]]</span> | |
Linking to titles with special characters: asterisk, slash | |||
{{l|mul|/}} | <span class="None" lang="mul">[[:/#Translingual|/]]</span> | <span class="None" lang="mul">[[<span style="color: red;">:</span>/#Translingual|/]]</span> | |
{{l|mul|//}} | <span class="None" lang="mul">[[://#Translingual|//]]</span> | <s<span style="color: red;">m</span>all>[Term?]</small> | |
{{l|mul|*}} | <span class="None" lang="mul">[[*#Translingual|*]]</span> | <span class="None" lang="mul">[[*#Translingual|<span style="color: red;">&</span>#42;]]</span> |
Text | Expected | Actual | |
---|---|---|---|
ба́бушка | бабушка | бабушка | |
ЃѓЌќ - е́а́́ | ЃѓЌќ - еа | ЃѓЌќ - еа | |
Łł ĆćŃńŹź Ŭŭ - ȁàȃáā ȐȒŔ ѝӣ | Łł ĆćŃńŹź Ŭŭ - aaaaa RRR ии | Łł ĆćNnŹź Ŭŭ - aaaaa RRR ии | |
ᾱ, ᾱ́, ᾰ̓́ | α, ά, ἄ | α, ά, ἄ |
Text | Expected | Actual | |
---|---|---|---|
w:Hindustani phonology#Vowels [ɛ], [ɛː] | w:Hindustani phonology § Vowels , | w:Hindustani phonology § Vowels [ɛ], [ɛː] |
--[=[
Unit tests for ]. Click talk page to run tests.
]=]
local p = require('Module:UnitTests')
local m_links = require('Module:links')
local m_util = require('Module:utilities')
local get_lang_by_code = require("Module:languages").getByCode
local function tag(lang_code, sc_code)
return function (text)
return '<span class="' .. sc_code .. '" lang="' .. lang_code .. '">' .. text .. '</span>'
end
end
local options = { nowiki = true, show_difference = true }
function p:check_link(example, expected)
self:preprocess_equals(example, expected, options)
end
function p:test_links()
local frame = mw.getCurrentFrame()
local temp = frame.args.temp or "l"
local compat = frame.args.compat
local lang = compat and "lang=" or ""
local link_examples = {
'anchor',
{
'{{' .. temp .. '|' .. lang .. 'en|-er#Etymology 2|-er}}',
'<span class="Latn" lang="en">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'en|]}}',
'<span class="Latn" lang="en">]</span>'
},
'character entity references in link target',
{
'{{' .. temp .. '|' .. lang .. 'nia|wa'a}}',
'<span class="Latn" lang="nia">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'nia|wa'a}}',
'<span class="Latn" lang="nia">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'ja|恵‌美|恵&#8204;美}}',
'<span class="Jpan" lang="ja">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'en|&}}',
'<span class="None" lang="en">]</span>'
},
'simple linking', -- (])
{
'{{' .. temp .. '|' .. lang .. 'la|verbum}}',
'<span class="Latn" lang="la">]</span>'
},
'using wikilinks',
{
'{{' .. temp .. '|' .. lang .. 'en|] be ] ]}}',
'<span class="Latn" lang="en">] be ] ]</span>'
},
'alternative text',
{
'{{' .. temp .. '|' .. lang .. 'en|go|went}}',
'<span class="Latn" lang="en">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'en|to ]|went}}',
'<span class="Latn" lang="en">to ]</span>'
},
'sense id',
{
'{{' .. temp .. '|' .. lang .. 'en|go|id=game}}',
'<span class="Latn" lang="en">]</span>'
},
'constructed terms', -- (])
{
'{{' .. temp .. '|' .. lang .. 'sjn|mithril}}',
'<span class="Latn" lang="sjn">]</span>'
},
'reconstructed terms', -- (])
{
'{{' .. temp .. '|' .. lang .. 'ine-pro|*bʰréh₂tēr}}',
'<span class="Latn" lang="ine-pro">]</span>'
},
{
'{{#iferror:{{' .. temp .. '|' .. lang .. 'ine-pro|bʰréh₂tēr}}|Script error}}',
'Script error'
},
{
'{{' .. temp .. '|' .. lang .. 'sla-pro|] ]}}',
'<span class="Latn" lang="sla-pro">] ]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'la|verbum .. ] .. ] .. ] .. ]}}',
'<span class="Latn" lang="la">verbum .. ] .. ] .. ] .. ]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'sla-pro|*]}}',
'<span class="Latn" lang="sla-pro">*]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'sla-pro|*] .. ] .. ] .. ] .. ]}}',
'<span class="Latn" lang="sla-pro">] .. ] .. ] .. ] .. ]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'sla-pro|*] ]}}',
'<span class="Latn" lang="sla-pro">*] ]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'und|] .. ] .. ]}}',
'<span class="Zyyy" lang="und">] .. *unattested .. unattested-alt</span>]'
},
'script detection', -- (lang_obj:findBestScript())
{
'{{' .. temp .. '|' .. lang .. 'sh|српски}} / {{' .. temp .. '|' .. lang .. 'sh|srpski}}',
'<span class="Cyrl" lang="sh">]</span> / <span class="Latn" lang="sh">]</span>'
},
'target page\'s title', -- (Language:makeEntryName())
{
'{{' .. temp .. '|' .. lang .. 'la|verbō}}',
'<span class="Latn" lang="la">]</span>'
},
'gender and number', -- (])
{
'{{' .. temp .. '|' .. lang .. 'la|verbum|g=m}}',
'<span class="Latn" lang="la">]</span> <span class="gender"><abbr title="masculine gender">m</abbr></span>'
},
{
'{{' .. temp .. '|' .. lang .. 'la|verbum|g=m|g2=f}}',
'<span class="Latn" lang="la">]</span> <span class="gender"><abbr title="masculine gender">m</abbr> or <abbr title="feminine gender">f</abbr></span>'
},
'transliteration',
{
'{{' .. temp .. '|' .. lang .. 'ar|كلمة|tr=kalima}}',
'<span class="Arab" lang="ar">]</span>‎ <span class="mention-gloss-paren annotation-paren">(</span><span lang="ar-Latn" class="tr Latn">kalima</span><span class="mention-gloss-paren annotation-paren">)</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'ru|русский}}',
'<span class="Cyrl" lang="ru">]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span><span class="mention-gloss-paren annotation-paren">)</span>'
},
'gloss',
{
'{{' .. temp .. '|' .. lang .. 'ru|русский|gloss=Russian}}',
'<span class="Cyrl" lang="ru">]</span> <span class="mention-gloss-paren annotation-paren">(</span><span lang="ru-Latn" class="tr Latn">russkij</span>, <span class="mention-gloss-double-quote">“</span><span class="mention-gloss">Russian</span><span class="mention-gloss-double-quote">”</span><span class="mention-gloss-paren annotation-paren">)</span>'
},
'Wikipedia link',
{
'{{' .. temp .. '|' .. lang .. 'en|w:word}}',
'<span class="Latn" lang="en">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'en|]}}',
'<span class="Latn" lang="en">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'en|]}}',
'<span class="Latn" lang="en">]</span>'
},
'Linking to titles with special characters: asterisk, slash',
{
'{{' .. temp .. '|' .. lang .. 'mul|/}}',
'<span class="None" lang="mul">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'mul|//}}',
'<span class="None" lang="mul">]</span>'
},
{
'{{' .. temp .. '|' .. lang .. 'mul|*}}',
'<span class="None" lang="mul">]</span>'
},
}
self:iterate(link_examples, 'check_link')
end
function p:check_make_entry_name(lang_code, unstripped, stripped)
local lang_obj = get_lang_by_code(lang_code)
local sc_code = lang_obj:findBestScript(unstripped):getCode()
self:equals(
(' <i class="mention %s" lang="%s">%s</i>'):format(lang_code, sc_code, lang_code, unstripped),
(lang_obj:makeEntryName(unstripped)),
stripped,
{ display = tag(lang_code, sc_code) }
)
end
function p:test_remove_diacritics()
-- insert here lines of the form:
local examples = {
{ 'ru', 'ба́бушка', 'бабушка' },
{ 'mk', 'ЃѓЌќ - е́а́́', 'ЃѓЌќ - еа' }, -- ]
{ 'sh', 'Łł ĆćŃńŹź Ŭŭ - ȁàȃáā ȐȒŔ ѝӣ', 'Łł ĆćŃńŹź Ŭŭ - aaaaa RRR ии' }, -- ] / ]
{ 'grc', 'ᾱ, ᾱ́, ᾰ̓́', 'α, ά, ἄ' },
}
self:iterate(examples, 'check_make_entry_name')
end
function p:test_section_link()
local examples = {
{
"w:Hindustani phonology#Vowels , ",
"[[w:Hindustani phonology#Vowels_%5B%C9%9B%5D,_%5B%C9%9B%CB%90%5D|"
.. "w:Hindustani phonology § Vowels , ]]"
},
}
self:iterate(
examples,
function (self, page, expected)
self:equals(
mw.text.nowiki(page),
m_links.section_link(page),
expected)
end)
end
return p