Modulo:Lang/pangsubok
From Wikipedia, the free encyclopedia
local p = require('Modulo:UnitTests') --[[==========================<< L A N G T E S T S=========================================================]]
--[[--------------------------< 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.
]]
function p:test_lang_italic() self:preprocess_equals_preprocess_many('text', 'text', { {'yes'}, {'no'}, {}, {'whatever'}, }, {nowiki=1}) self:preprocess_equals_preprocess('text', 'text', {nowiki=1}) end;
--[[--------------------------< I T A L I C W I T H S C R I P T >------------------------------------------
Tests module parameter |italic=yes when |script=arab or |script=latn
|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 and insert the marker
]]
function p:test_lang_italic_with_script() self:preprocess_equals_preprocess_many('text', 'text', { {'arab'}, {'latn'}, }, {nowiki=1}) self:preprocess_equals_preprocess_many('text', 'text', { {'arab'}, {'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 and inserts the marker
]]
function p:test_lang_rtl() self:preprocess_equals_preprocess_many('text', 'text', { {'yes'}, {'no'}, {}, {'whatever'}, }, {nowiki=1}) self:preprocess_equals_preprocess('text', 'text', {nowiki=1}) end;
--[[--------------------------< I E T F D E C O D I N G >----------------------------------------------------
Tests module parameter |code= with values that should not produce error messages: 'de', 'de-ch', 'de-CH-1901', 'ru-RU-petr1708', '1ca', es-419.
]]
function p:test_lang_ietf() self:preprocess_equals_preprocess_many('[text] Biddut: {{lang}}: di mabigbigan nga etiketa ti pagsasao ti: ', ' (tulong)', '[text] Biddut: {{lang}}: di mabigbigan nga etiketa ti pagsasao ti: ', ' (tulong)', { {'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;
--[[==========================<< L A N G _ X X T E S T S===================================================]]
--[[--------------------------< 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.
]]
function p:test_lang_xx_italic() self:preprocess_equals_preprocess_many('Arabiko: text', 'Arabiko: text', { {'yes'}, {'no'}, {}, {'whatever'}, }, {nowiki=1}) self:preprocess_equals_preprocess('Arabiko: text', 'Arabiko: text', {nowiki=1}) end;
--[[--------------------------< I T A L I C W I T H S C R I P T >------------------------------------------
Tests module parameter |italic=yes when |script=arab or |script=latn
|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 and insert the marker
]]
function p:test_lang_xx_italic_with_script() self:preprocess_equals_preprocess_many('[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', '[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', { {'arab'}, {'latn'}, }, {nowiki=1}) self:preprocess_equals_preprocess_many('[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', '[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', { {'arab'}, {'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 and insert the marker
There is no [undefined] Biddut: {{lang}}: awan ti teksto (tulong) version of this test because [undefined] Biddut: {{lang}}: awan ti teksto (tulong) has not need for separate |script=, |region=, and |variant= parameters - those subtags can all be added to the IETF language code in the template's first positional parameter ({{{1}}}).
]]
function p:test_lang_xx_script() self:preprocess_equals_preprocess_many('[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', '[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', { {'arab'}, {'latn'}, }, {nowiki=1}) self:preprocess_equals_preprocess_many('[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', '[text] Biddut: {{lang-xx}}: di mabigbigan a sinuratan ti: ', ' para iti kodigo ti: ar (tulong)', { {'arab'}, {'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 and inserts the marker
]]
function p:test_lang_xx_rtl() self:preprocess_equals_preprocess_many('Arabiko: text', 'Arabiko: text', { {'yes'}, {'no'}, {}, {'whatever'}, }, {nowiki=1}) self:preprocess_equals_preprocess('Arabiko: text', 'Arabiko: text', {nowiki=1}) end;
return p