Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
local p = require('Module:UnitTests')
--[[ ==========================
--[[ -------------------------- < I T A L I C >
Tests module parameter |italic= with values 'yes', 'no', present but not set, and the invalid 'whatever'.
There is a separate test for the parameter not present.
|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.
Line 22:
self:preprocess_equals_preprocess('{{#invoke:Lang/sandbox|lang|code=ar|text=text}}', '{{#invoke:Lang|lang|code=ar|text=text}}',
{nowiki=1})
end
--[[ -------------------------- < I T A L I C
Tests module parameter |italic=yes and |italic=no when |script=arab or |script=latn is set.
|italic=yes should override whatever |script= might say.
The value assigned to |script= shall be appended to the language code; for |script=arab the module shall add
dir="rtl" to the text's enclosing <span> and insert the ‎ marker.
]]
Line 47:
{'latn'},
}, {nowiki=1})
end
--[[ -------------------------- < R T L >
Tests module parameter |rtl= with values 'yes', 'no', present but not set, and the invalid 'whatever'.
There is a separate test for the parameter not present.
|rtl=yes adds dir="rtl" to the text's enclosing <span> and inserts the ‎ marker.
]]
Line 69:
self:preprocess_equals_preprocess('{{#invoke:Lang/sandbox|lang|code=ar|text=text}}', '{{#invoke:Lang|lang|code=ar|text=text}}',
{nowiki=1})
end
--[[ -------------------------- < I E T F
Tests module parameter |code= with values that should not produce error messages:
Line 96:
{'ca-419-valencia'}, -- code-numeric reigion-variant
}, {nowiki=1})
end
--[[ ==========================
--[[ -------------------------- < I T A L I C >
Tests module parameter |italic= with values 'yes', 'no', present but not set, and the invalid 'whatever'.
There is a separate test for the parameter not present.
|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.
Line 120:
self:preprocess_equals_preprocess('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text}}',
{nowiki=1})
end
--[[ -------------------------- < I T A L I C
Tests module parameter |italic=yes and |italic=no when |script=arab or |script=latn is set.
|italic=yes should override whatever |script= might say.
The value assigned to |script= shall be appended to the language code; for |script=arab the module shall add
dir="rtl" to the text's enclosing <span> and insert the ‎ marker.
]]
Line 145:
{'latn'},
}, {nowiki=1})
end
--[[ -------------------------- < S C R I P T >
Tests module parameter |script=arab and |script=latn with |italic= preset but not set and |italic= not present.
|script=arab shall not italicize text.
|script=latn shall italicize text.
The value assigned to |script= shall be appended to the language code; for |script=arab the module shall add
dir="rtl" to the text's enclosing <span> and insert the ‎ marker.
There is no {{lang}} version of this test because {{lang}} has
parameters - those subtags can all be added to the IETF language code in the template's first positional parameter ({{{1}}}).
Line 174:
{'latn'},
}, {nowiki=1})
end
--[[ -------------------------- < R T L >
Tests module parameter |rtl= with values 'yes', 'no', present but not set, and the invalid 'whatever'.
There is a separate test for the parameter not present.
|rtl=yes adds dir="rtl" to the text's enclosing <span> and inserts the ‎ marker.
]]
Line 196:
self:preprocess_equals_preprocess('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text}}',
{nowiki=1})
end
--[[--------------------------< L A N G _ T R A N S L I T >------------------------------------------------------------------------
Tests various supported combinations of translit formats.
]]
Line 221 ⟶ 222:
{'code=ar|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-std=DIN|translit-script=arab'},
}, {nowiki=1})
end
--[[ ========================== < T R A N S L _ T E S T S > ========================== ]]
--[[ -------------------------- < T R A N S L _ F O R M A T S > --------------------------
Tests various supported combinations of translit formats.
]]
function p:test_10_transl_formats()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|transl|nocat=yes|', '}}', '{{#invoke:Lang|transl|nocat=yes|', '}}',
{
-- language with transliteration standard (std) tests:
{'ja|iso|test'}, -- get code value: x (y language) transliteration
{'kana|iso|test'}, -- get script value: x (y script) transliteration
{'oto|iso|test'}, -- get default value: x transliteration
-- code or script found in "no_std" tests:
-- TODO: no current code example {'???|test'}, -- no_std code:
{'xsux|test'}, -- no_std script: x transliteration (whatever the override value is)
-- translit-script tests:
{'Cyrl|š'}, -- script: x-script transliteration
-- no translit-script or std tests:
{'ar|test'}, -- romanization: x-language romanization
{'oto|test'}, -- romanization collective: x languages romanization
}, {nowiki=1})
end
--[[ -------------------------- < I T A L I C S > --------------------------
Tests module parameter |italic= with values 'yes', 'no', present but not set, default, unset, and the invalid 'whatever'.
There is a separate test for the parameter not present.
]]
function p:test_11_transl_italics()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|transl|nocat=yes|', '}}', '{{#invoke:Lang|transl|nocat=yes|', '}}',
{
{'ar|nasu aleunsur alnnayib|italic='},
{'ar|nasu aleunsur alnnayib|italic=yes'},
{'ar|nasu aleunsur alnnayib|italic=no'},
{'ar|nasu aleunsur alnnayib|italic=default'},
{'ar|nasu aleunsur alnnayib|italic=whatever'},
{'ar|nasu \'\'aleunsur\'\' alnnayib|italic=unset'},
{'Arab|nasu \'\'aleunsur\'\' alnnayib|italic=unset'},
}, {nowiki=1})
end
--[[ ========================== < E R R O R S > ========================== ]]
--[[--------------------------< L A N G _ E R R O R S >------------------------------------------------------------------------
Lang errors.
]]
function p:
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|nocat=yes|', '}}', '{{#invoke:Lang|lang|nocat=yes|', '}}',
{
Line 246 ⟶ 301:
{'iw|text'}, -- code: iw is deprecated
}, {nowiki=1})
end
--[[ -------------------------- < L A N G _ X X _ E R R O R S > --------------------------
Lang-xx errors.
]]
function p:test_13_lang_xx_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
Line 258 ⟶ 321:
{'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'},
{'code=fr-Latn|script=Latn|text'}, -- redundant script tag
{'code=fr|script=nonsense|text'}, -- unrecognized script: nonsense for code fr
Line 270 ⟶ 333:
{'code=es-x-419|text'}, -- unrecognized private tag: 419
{'code=ar|rtl=yes|نص العنصر النائب|nasu aleunsur alnnayib|translit-std=bob'}, --invalid |translit-std=: bob
{'code=ar|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-std=DIN|translit-script=ar'}, -- invalid |translit-script= value
}, {nowiki=1})
end
--[[ -------------------------- < T R A N S L _ E R R O R S >
]]
function p:
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|transl|nocat=yes|', '}}', '{{#invoke:Lang|transl|nocat=yes|', '}}',
{
{'al-Khwarizmi'},
{'ar'},
{'at|al-Khwarizmi'},
{'ar|AL|al-Khwarizmi'},
{'Arab|nasu \'\'aleunsur\'\' alnnayib|italic=yes|italics=no'},
}, {nowiki=1})
end
--[[ -------------------------- < N A M E _ F R O M _ T A G _ E R R O R S > --------------------------
Name_from_tag errors.
A complete list of valid tests can be found here:
* Module:Lang/testcases/ISO 639-1 name from tag
* Module:Lang/testcases/ISO 639-3-1 name from tag (A–H)
* Module:Lang/testcases/ISO 639-3-2 name from tag (I–N)
* Module:Lang/testcases/ISO 639-3-3 name from tag (O–Z)
* Module:Lang/testcases/ISO 639 deprecated and override name from tag
]]
function p:test_15_name_from_tag_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|name_from_tag|nocat=yes|', '}}', '{{#invoke:Lang|name_from_tag|nocat=yes|', '}}',
{
{'sfsfsfs'},
}, {nowiki=1})
end
--[[ -------------------------- < T A G _ F R O M _ N A M E _ E R R O R S > --------------------------
Tag_from_name errors.
A complete list of valid tests can be found here:
* Module:Lang/testcases/ISO 639-1 tag from name
* Module:Lang/testcases/ISO 639-3-1 tag from name (A–H)
* Module:Lang/testcases/ISO 639-3-2 tag from name (I–N)
* Module:Lang/testcases/ISO 639-3-3 tag from name (O–Z)
* Module:Lang/testcases/ISO 639 deprecated and override tag from name
]]
function p:test_16_category_from_tag_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|tag_from_name|nocat=yes|', '}}', '{{#invoke:Lang|tag_from_name|nocat=yes|', '}}',
{
{'sfsfsfs'},
}, {nowiki=1})
end
--[[ -------------------------- < C A T E G O R Y _ F R O M _ T A G _ E R R O R S > --------------------------
Category_from_tag errors.
A complete list of valid tests can be found here:
* Module:Lang/testcases/ISO 639-1 category from tag
* Module:Lang/testcases/ISO 639-3-1 category from tag (A–H)
* Module:Lang/testcases/ISO 639-3-2 category from tag (I–N)
* Module:Lang/testcases/ISO 639-3-3 category from tag (O–Z)
* Module:Lang/testcases/ISO 639 deprecated and override category from tag
]]
function p:test_17_category_from_tag_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|category_from_tag|nocat=yes|', '}}', '{{#invoke:Lang|category_from_tag|nocat=yes|', '}}',
{
{'
}, {nowiki=1})
end
return p
|