Module:usex/testcases
Appearance
- පහත දැක්වෙන උපදෙස්, Module:usex/testcases/documentation හි පිහිටා ඇත. Module:usex/testcases/documentation]]. [සංස්කරණය] Categories were auto-generated by Module:documentation. [edit]
- ප්රයෝජනවත් සබැඳි: root page • root page’s subpages • සබැඳි • transclusions • tested module • sandbox
9 tests failed.
Name | Expected | Actual | |
---|---|---|---|
test_format_english | |||
test_format_quote_quotation_content_is_wrapped_ | |||
test_format_quote_quotation_is_wrapped | |||
test_format_quote_with_translation | |||
test_format_quote_without_quote_displays_hint | Module:usex/testcases:36: Failed to find plain string "(please add the primary text of this quote)" in string "<div class="h-quotation"><small>(මෙම quotation සඳහා වන ප්රාථමික පෙළ එක් කිරීමට කාරුණික වන්න)</small><dl><dd><small>(මෙම quotation සඳහා වන [[WT:Quotations#Adding translations to quotations|සිංහල පරිවර්තනය එක් කිරීමට]] කාරුණික වන්න)</small></dd></dl></div>" | ||
test_format_quote_without_translation_displays_hint_hint | Module:usex/testcases:143: Failed to find plain string "(please add an English translation of this quote)" in string "<div class="h-quotation"><span class="Latn e-quotation" lang="fr">Ceci est un quote</span><dl><dd><small>(මෙම quotation සඳහා වන [[WT:Quotations#Adding translations to quotations|සිංහල පරිවර්තනය එක් කිරීමට]] කාරුණික වන්න)</small></dd></dl></div>" | ||
test_format_usex_adds_does_not_add_italic_tag_for_quote | |||
test_format_usex_adds_italic_tag_for_latn_script | |||
test_format_usex_adds_left_to_right_mark_after_example | Module:usex/testcases:163: Failed to find pattern "‏.+Original.+‎.+Translated" in string "<div class="h-usage-example"><i class="Hebr mention e-example" lang="fr">Original</i><dl><dd><span class="e-translation">Translated</span></dd></dl></div>" | ||
test_format_usex_adds_left_to_right_mark_after_example_inline | Module:usex/testcases:170: Failed to find pattern "‏.+Original.+‎.+Translated" in string "<span class="h-usage-example"><i class="Hebr mention e-example" lang="fr">Original</i> ― <span class="e-translation">Translated</span></span>" | ||
test_format_usex_adds_script_and_language_tag | |||
test_format_usex_example_content_is_wrapped | |||
test_format_usex_explicit_script | |||
test_format_usex_inline | |||
test_format_usex_inline_and_transliteration | |||
test_format_usex_is_wrapped_ | |||
test_format_usex_literally_is_wrapped | |||
test_format_usex_translation_is_wrapped | |||
test_format_usex_transliterated_text_is_italic | |||
test_format_usex_transliteration_is_wrapped | |||
test_format_usex_with_automatic_transliteration | |||
test_format_usex_with_dash_transliteration_parameter_disables_transliteration | |||
test_format_usex_with_embedded_wiki_link | Module:usex/testcases:47: Failed to find plain string "This is an [[example#English|example]]" in string "<div class="h-usage-example"><i class="Latn mention e-example" lang="en">This is an [[example#ඉංග්රීසි|example]]</i><dl><dd><small>(මෙම usage example සඳහා වන සිංහල පරිවර්තනය එක් කිරීමට කාරුණික වන්න)</small></dd></dl></div>" | ||
test_format_usex_with_literal_translation | |||
test_format_usex_with_manual_transliteration | |||
test_format_usex_with_noenum | Module:usex/testcases:114: Failed to find pattern "^
: " in string "<div class="h-usage-example"><i class="Latn mention e-example" lang="fr">Ceci est un exemple</i><dl><dd><small>(මෙම usage example සඳහා වන සිංහල පරිවර්තනය එක් කිරීමට කාරුණික වන්න)</small></dd></dl></div>" | ||
test_format_usex_with_ref | |||
test_format_usex_without_translation_displays_hint | Module:usex/testcases:78: Failed to find plain string "(please add an English translation of this usage example)" in string "<div class="h-usage-example"><i class="Latn mention e-example" lang="fr">Ceci est un exemple</i><dl><dd><small>(මෙම usage example සඳහා වන සිංහල පරිවර්තනය එක් කිරීමට කාරුණික වන්න)</small></dd></dl></div>" | ||
test_format_usex_without_translation_displays_usex | |||
test_format_with_translation | |||
test_format_without_usex_displays_hint | Module:usex/testcases:31: Failed to find plain string "(please add the primary text of this usage example)" in string "<div class="h-usage-example"><small>(මෙම usage example සඳහා වන ප්රාථමික පෙළ එක් කිරීමට කාරුණික වන්න)</small><dl><dd><small>(මෙම usage example සඳහා වන සිංහල පරිවර්තනය එක් කිරීමට කාරුණික වන්න)</small></dd></dl></div>" | ||
test_qualifier | Module:usex/testcases:176: Failed to find pattern "A qualifier" in string "<div class="h-usage-example"><i class="Latn mention e-example" lang="fr">Usex</i><dl><dd><small>(මෙම usage example සඳහා වන සිංහල පරිවර්තනය එක් කිරීමට කාරුණික වන්න)</small></dd></dl></div>" |
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local m_usex = require('Module:usex')
local m_languages = require("Module:languages")
local m_scripts = require("Module:scripts")
local en, fr, ko = m_languages.getByCode('en'), m_languages.getByCode('fr'), m_languages.getByCode('ko')
local rtl_script = m_scripts.getByCode('Hebr')
local translation_hint_usex = '(please add an English translation of this usage example)'
local translation_hint_quote = '(please add an English translation of this quote)'
local function format(args)
return m_usex.format_usex {
lang = args.lang or en,
sc = args.sc, -- The script code
usex = args.usex, -- The example or quote
translation = args.translation, -- The English translation for examples on foreign entries.
transliteration = args.transliteration, -- The Latin transliteration for examples in non-Latin script.
noenum = args.noenum or false, -- To use in unnumbered sections (not following a definition).
inline = args.inline or false, -- To include the translation in the same line as the example,
-- separated from the example by em dash.
ref = args.ref, -- To include a reference or link to an originating external site
quote = args.quote or false, -- Used from Template:quote
lit = args.lit, -- A literal translation.
substs = args.substs, -- Substitutions to be applied to handle irregular transliterations in certain languages
qualifiers = args.qualifier or {} -- To include qualifier for the example or quote.
}
end
function suite:test_format_without_usex_displays_hint()
local result = format {}
suite:assertStringContains('(please add the primary text of this usage example)', result, true)
end
function suite:test_format_quote_without_quote_displays_hint()
local result = format {quote=true}
suite:assertStringContains('(please add the primary text of this quote)', result, true)
end
function suite:test_format_english()
local result = format {usex='This is an example'}
suite:assertStringContains('This is an example', result, true)
suite:assertNotStringContains(translation_hint_usex, result, true)
end
function suite:test_format_usex_with_embedded_wiki_link()
local result = format {usex='This is an [[example]]'}
suite:assertStringContains('This is an [[example#English|example]]', result, true)
end
function suite:test_format_usex_adds_script_and_language_tag()
local result = format {usex='Example'}
suite:assertStringContains('<i class="Latn.*">Example</i>', result, false)
end
function suite:test_format_usex_explicit_script()
local result = format {usex='Example', sc=m_scripts.getByCode('Cyrl')}
suite:assertStringContains('<i class="Cyrl.*">Example</i>', result, false)
end
function suite:test_format_usex_adds_italic_tag_for_latn_script()
local result = format {usex='Example'}
suite:assertStringContains('<i class="Latn mention.*">Example</i>', result, false)
end
function suite:test_format_usex_adds_does_not_add_italic_tag_for_quote()
local result = format {usex='This is a quote', quote=true}
suite:assertNotStringContains('<i', result, true)
suite:assertNotStringContains('</i>', result, true)
end
function suite:test_format_usex_without_translation_displays_usex()
local result = format {lang=fr, usex='Ceci est un exemple'}
suite:assertStringContains('Ceci est un exemple', result, true)
end
function suite:test_format_usex_without_translation_displays_hint()
local result = format {lang=fr, usex='Ceci est un exemple'}
suite:assertStringContains(translation_hint_usex, result, true)
end
function suite:test_format_with_translation()
local result = format {lang=fr, usex='Ceci est un exemple',
translation='This is an example'}
suite:assertStringContains('Ceci est un exemple', result, true)
suite:assertStringContains('This is an example', result, true)
suite:assertNotStringContains(translation_hint_usex, result, true)
end
function suite:test_format_usex_with_manual_transliteration()
local result = format {lang=fr, usex='Ceci est un exemple',
translation='This is an example',
transliteration='This is the transliterated text'}
suite:assertStringContains('This is the transliterated text', result, true)
end
function suite:test_format_usex_with_automatic_transliteration()
local result = format {lang=ko, usex='초식남'}
suite:assertStringContains('chosingnam', result, true)
end
function suite:test_format_usex_transliterated_text_is_italic()
local result = format {lang=ko, usex='초식남'}
suite:assertStringContains('<i.*>chosingnam</i>', result, false)
end
-- tr=- means omit transliteration altogether
function suite:test_format_usex_with_dash_transliteration_parameter_disables_transliteration()
local result = format {lang=ko, usex='초식남', transliteration='-'}
suite:assertNotStringContains('chosingnam', result, true)
end
function suite:test_format_usex_with_noenum()
local result = format {lang=fr, usex='Ceci est un exemple', noenum=true}
suite:assertStringContains('^\n: ', result, false)
end
function suite:test_format_usex_inline()
local result = format {lang=fr,
usex='Ceci est un exemple',
transliteration='This is an example', inline=true}
suite:assertStringContains('Ceci est un exemple', result, true)
suite:assertStringContains('This is an example', result, true)
suite:assertStringContains('―', result, true)
suite:assertNotStringContains('<dl>', result, true)
suite:assertNotStringContains('<dd>', result, true)
end
function suite:test_format_usex_inline_and_transliteration()
local result = format {lang=ko, usex='초식남',
translation='This is an example', inline=true}
suite:assertStringContains('―', result, true)
suite:assertStringContains('chosingnam', result, true)
end
function suite:test_format_usex_with_ref()
local result = format {lang=fr, usex='Ceci est un exemple',
ref='<ref>http://external-ref.com</ref>'}
suite:assertStringContains('<ref>http://external-ref.com</ref>', result, true)
end
function suite:test_format_quote_without_translation_displays_hint_hint()
local result = format {lang=fr, usex='Ceci est un quote', quote=true}
suite:assertStringContains(translation_hint_quote, result, true)
end
function suite:test_format_quote_with_translation()
local result = format {lang=fr, usex='Ceci est un quote',
translation='This is a quote', quote=true}
suite:assertNotStringContains(translation_hint_quote, result, true)
suite:assertStringContains('This is a quote', result, true)
end
function suite:test_format_usex_with_literal_translation()
local result = format {lang=fr, usex='Ceci est un exemple',
translation='This is an example',
lit='This is the literal translation'}
suite:assertStringContains('This is the literal translation', result, true)
suite:assertStringContains('(literally, “.+”)', result, false)
end
function suite:test_format_usex_adds_left_to_right_mark_after_example()
local result = format {lang=fr, usex='Original', translation='Translated', sc=rtl_script}
suite:assertStringContains('‏.+Original.+‎.+Translated', result, false)
end
function suite:test_format_usex_adds_left_to_right_mark_after_example_inline()
local sc = m_scripts.getByCode('Cyrl')
local result = format {lang=fr, usex='Original', translation='Translated',
sc=rtl_script, inline=true}
suite:assertStringContains('‏.+Original.+‎.+Translated', result, false)
end
function suite:test_qualifier()
local qualifier = {'A qualifier'}
local result = format {lang=fr, usex='Usex', qualifier=qualifier}
suite:assertStringContains('A qualifier', result, false)
end
-- microformat tests
function suite:test_format_usex_is_wrapped_()
local result = format {usex='Example'}
suite:assertStringContains('<div class="h%-usage%-example">.*Example.*</div>', result, false)
end
function suite:test_format_usex_example_content_is_wrapped()
local result = format {usex='Example'}
suite:assertStringContains('<i class=".*e-example.*">Example</i>', result, false)
end
function suite:test_format_usex_translation_is_wrapped()
local result = format {usex='Example', translation='Translated'}
suite:assertStringContains('<span class="e-translation">Translated</span>', result, true)
end
function suite:test_format_usex_transliteration_is_wrapped()
local result = format {usex='Example', transliteration='Transliteration'}
suite:assertStringContains('<i lang="en-Latn" class="e-transliteration tr Latn">Transliteration</i>', result, true)
end
function suite:test_format_usex_literally_is_wrapped()
local result = format {usex='Example', lit='Literally'}
suite:assertStringContains('<span class="e-literally">Literally</span>', result, true)
end
function suite:test_format_quote_quotation_is_wrapped()
local result = format {usex='Quotation', quote=true}
suite:assertStringContains('<div class="h%-quotation">.*Quotation.*</div>', result, false)
end
function suite:test_format_quote_quotation_content_is_wrapped_()
local result = format {usex='Quotation', quote=true}
suite:assertStringContains('<span class=".*e%-quotation.*">Quotation</span>', result, false)
end
return suite