Module:Lang/testcases: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
local p = require('Module:UnitTests')
 
--[[==========================<< L A N G T E S T S=========================================================]]
 
Line 11 ⟶ 12:
]]
 
function p:test_lang_italictest_01_lang_italic()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang|code=ar|text=text|italic=', '}}', '{{#invoke:langLang|lang|code=ar|text=text|italic=', '}}',
{
{'yes'}, {'no'}, {''}, {'whatever'},
}, {nowiki=1})
self:preprocess_equals_preprocess('{{#invoke:langLang/sandbox|lang|code=ar|text=text}}', '{{#invoke:langLang|lang|code=ar|text=text}}',
{nowiki=1})
end;
Line 32 ⟶ 33:
]]
 
function p:test_lang_italic_with_scripttest_02_lang_italic_with_script()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang|code=ar|text=text|italic=yes|script=', '}}', '{{#invoke:langLang|lang|code=ar|text=text|italic=yes|script=', '}}',
{
{'arab'}, {'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang|code=ar|text=text|italic=no|script=', '}}', '{{#invoke:langLang|lang|code=ar|text=text|italic=no|script=', '}}',
{
{'arab'}, {'latn'},
Line 53 ⟶ 54:
]]
 
function p:test_lang_rtltest_03_lang_rtl()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang|code=ar|text=text|rtl=', '}}', '{{#invoke:langLang|lang|code=ar|text=text|rtl=', '}}',
{
{'yes'}, {'no'}, {''}, {'whatever'},
}, {nowiki=1})
self:preprocess_equals_preprocess('{{#invoke:langLang/sandbox|lang|code=ar|text=text}}', '{{#invoke:langLang|lang|code=ar|text=text}}',
{nowiki=1})
end;
Line 70 ⟶ 71:
]]
 
function p:test_lang_ietftest_04_lang_ietf()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang|text=text|code=', '}}', '{{#invoke:langLang|lang|text=text|code=', '}}',
{
{'de'}, -- code
{'nav'}, -- code
{'1ca'}, -- non-standard code
{'cmn-Latn'}, -- code-script; shall italicize text
{'he-hebr'}, -- code-script; shall insert rtl
{'de-ch'}, -- code-region
{'de-1901'}, -- code-numeric variant
{'ru-petr1708'}, -- code-alnum variant
{'ca-valencia'}, -- code-alpha variant
{'ru-ru-petr1708'}, -- code-region-variant
{'es-419'}, -- code-numeric region
{'ru-Cyrl-RU'}, -- code-script-region
{'ca-419-valencia'}, -- code-numeric reigion-variant
}, {nowiki=1})
end;
Line 101 ⟶ 102:
]]
 
function p:test_lang_xx_italictest_05_lang_xx_italic()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|italic=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|italic=', '}}',
{
{'yes'}, {'no'}, {''}, {'whatever'},
}, {nowiki=1})
self:preprocess_equals_preprocess('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text}}',
{nowiki=1})
end;
Line 122 ⟶ 123:
]]
 
function p:test_lang_xx_italic_with_scripttest_06_lang_xx_italic_with_script()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|italic=yes|script=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|italic=yes|script=', '}}',
{
{'arab'}, {'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|italic=no|script=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|italic=no|script=', '}}',
{
{'arab'}, {'latn'},
Line 149 ⟶ 150:
]]
 
function p:test_lang_xx_scripttest_07_lang_xx_script()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|italic=|script=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|italic=|script=', '}}',
{
{'arab'}, {'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|script=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|script=', '}}',
{
{'arab'}, {'latn'},
Line 170 ⟶ 171:
]]
 
function p:test_lang_xx_rtltest_08_lang_xx_rtl()
self:preprocess_equals_preprocess_many('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text=text|rtl=', '}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text=text|rtl=', '}}',
{
{'yes'}, {'no'}, {''}, {'whatever'},
}, {nowiki=1})
self:preprocess_equals_preprocess('{{#invoke:langLang/sandbox|lang_xx_inherit|code=ar|text}}', '{{#invoke:langLang|lang_xx_inherit|code=ar|text}}',
{nowiki=1})
end;
 
 
--[[--------------------------< E R R O R S >------------------------------------------------------------------------
 
Tests module errors.
 
]]
 
function p:test_09_lang_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|nocat=yes|', '}}', '{{#invoke:Lang|lang|nocat=yes|', '}}',
{
--TODO: get error to produce no code error {''}, -- no text but probably no code error first.
{'fr'}, -- no text
{'fr|code=fr|text'}, -- conflicting |1= and |code=
{'fr|text|text=text'}, -- conflicting |2= and |text=
{'proto=proto-y-bad|text=text'},-- invalid |proto= value
{'fr|malformed\'\'\'\'\'\''}, -- text has malformed markup
{'fr|\'\'italics\'\''}, -- text has italic markup
{'1ca|text'}, -- unrecognized language tag: 1ca
--TODO: get error to work {'gfgf|text'}, -- unrecognized language code
{'glg|text'}, -- code: glg promoted to code: gl
}, {nowiki=1})
end;
 
function p:test_10_lang_xx_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
{''}, -- missing language tag
{'code=fr'}, -- no text
{'code=fr|text|text=text'}, -- conflicting {{{1}}} and |text=
{'code=fr|text|translit|translit=translit'}, -- conflicting {{{2}}} and |translit=
{'code=fr|text||lit|lit=lit'}, -- conflicting {{{3}}} and |lit= or |translation=
{'code=fr|text||translation|translation=translation'}, -- conflicting {{{3}}} and |lit= or |translation=
{'code=fr|text|||lit=lit|translation=translation'}, -- conflicting |lit= and |translation=
{'code=fr-Latn|script=Latn|text'}, -- redundant script tag
{'code=fr|script=nonsense|text'}, -- unrecognized script: nonsense for code fr
--TODO {'code=en-Latn|text'}, -- script: %s not supported for code: %s
{'code=en-US|region=US|text'}, -- redundant region tag
{'code=de-XL|text'}, -- unrecognized region: xl for code de
{'code=de-1901|variant=1901|text'}, -- redundant variant tag
{'code=de-19022|text'}, -- unrecognized variant: 19022
--TODO {'code=de-1901|script=bad|text'}, -- unrecognized variant: %s for code-%s pair: %s-%s
--TODO {'es-419|text'}, -- unrecognized variant: %s for code %s
{'code=es-x-419|text'}, -- unrecognized private tag: 419
}, {nowiki=1})
end;