模組:Lang/testcases
外观
這是Module:Lang的測試樣例頁,測試結果請見討論頁。 |
local p = require('Module:UnitTests')
--[[ ========================== < L A N G _ T E S T S > ========================== ]]
--[[ -------------------------- < I T A L I C > --------------------------
Tests module parameter |italic= with values:
- 'yes',
- 'no',
- 'invert',
- 'italic',
- present but not set,
- invalid 'whatever',
- parameter not present.
|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.
]]
function p:test_01_lang_italic()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|code=ar|text=text|italic=', '}}', '{{#invoke:Lang|lang|code=ar|text=text|italic=', '}}',
{
{'yes'},
{'no'},
{'invert'},
{'italic'},
{''},
{'whatever'},
}, {nowiki=1})
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 _ W I T H _ S C R I P T > --------------------------
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.
2024-11-13: rewritten; {{lang}} does not support |script= or |region= or |variant= (never has) so these subtags
must be included in |code=
]]
function p:test_02_lang_italic_with_script()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|text=text|italic=yes|code=ar-', '}}', '{{#invoke:Lang|lang|text=text|italic=yes|code=ar-', '}}',
{
{'Cyrl'},
{'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|text=text|italic=no|code=ar-', '}}', '{{#invoke:Lang|lang|text=text|italic=no|code=ar-', '}}',
{
{'Cyrl'},
{'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.
]]
function p:test_03_lang_rtl()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|code=ar|text=text|rtl=', '}}', '{{#invoke:Lang|lang|code=ar|text=text|rtl=', '}}',
{
{'yes'},
{'no'},
{''},
{'whatever'},
}, {nowiki=1})
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 _ 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_04_lang_ietf()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|text=text|code=', '}}', '{{#invoke:Lang|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
{'cel-x-proto'}, -- private-use
}, {nowiki=1})
end
--[[ -------------------------- < I N V E R T _ I T A L I C S > --------------------------
Tests text ouput with |italic=invert set.
]]
function p:test_05_lang_invert_italics()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|code=ar', '}}', '{{#invoke:Lang|lang|code=ar', '}}',
{
{'|text=text|italic=invert'},
{"|text=''text''|italic=invert"},
{"|text='''''text'''''|italic=invert"},
{"|text='''text'''|italic=invert"},
{"|text=''text's''|italic=invert"},
{"|text=text's|italic=invert"},
}, {nowiki=1})
end
--[[ ========================== < L A N G _ X X _ T E S T S > ========================== ]]
--[[ -------------------------- < I T A L I C > --------------------------
- 'yes',
- 'no',
- 'invert',
- 'italic',
- present but not set,
- invalid 'whatever',
- parameter not present.
|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.
]]
function p:test_06_lang_xx_italic()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|italic=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|italic=', '}}',
{
{'yes'},
{'no'},
{'invert'},
{'italic'},
{''},
{'whatever'},
}, {nowiki=1})
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 _ W I T H _ S C R I P T > --------------------------
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.
]]
function p:test_07_lang_xx_italic_with_script()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|italic=yes|script=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|italic=yes|script=', '}}',
{
{'arab'},
{'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|italic=no|script=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|italic=no|script=', '}}',
{
{'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 <span> and insert the ‎ marker.
There is no {{lang}} version of this test because {{lang}} has no 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_08_lang_xx_script()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|italic=|script=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|italic=|script=', '}}',
{
{'arab'},
{'latn'},
}, {nowiki=1})
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|script=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|script=', '}}',
{
{'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 <span> and inserts the ‎ marker.
]]
function p:test_09_lang_xx_rtl()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar|text=text|rtl=', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar|text=text|rtl=', '}}',
{
{'yes'},
{'no'},
{''},
{'whatever'},
}, {nowiki=1})
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.
]]
function p:test_10_lang_xx_translit()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-script=Arab'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-std=DIN'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-std=ALA'},
{'code=ar|عربى|translit=ʿarabī'},
{'code=ar|عربى|translit=ʿarabī|lit=Arabic'},
{'code=ar|عربى|translit=ʿarabī|translation=Arabic'},
{'code=ar|عربى|translit=ʿarabī|lit=Arabic|links=no'},
{'code=ar|عربى|translation=Arabic'},
{'code=ar|عربى|translation=Arabic|links=no'},
{'code=ff|text=𞤁𞤢𞤲𞤣𞤢𞤴𞤯𞤫|translit=something|translit-script=Adlm'},
{'code=ff|text=𞤁𞤢𞤲𞤣𞤢𞤴𞤯𞤫|translit=something|translit-script=Adlm|translit-std=ALA'},
{'code=ar|text=نص العنصر النائب|translit=nasu aleunsur alnnay|translit-std=DIN|translit-script=arab'},
{'code=gem|text=test|translit=ʿarabī|translation=Arabic'}, -- not valid translations, the test is here to see the link with a collective langauge
{'code=ath|text=test|translit=ʿarabī|translation=Arabic'}, -- not valid translations, the test is here to see the link with a collective langauge
}, {nowiki=1})
end
--[[--------------------------< E N G V A R >------------------------------------------------------------------
Tests various supported and unsupported values assigned to |engvar=
]]
function p:test_11_lang_xx_engvar()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay'}, -- |engvar= omitted
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar='}, -- |engvar= empty
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=au'}, -- valid engvar language tags
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=ca'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=gb'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=ie'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=in'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=nz'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=us'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=za'},
{'code=ar|rtl=yes|text=نص العنصر النائب|translit=nasu aleunsur alnnay|engvar=nv'}, -- invalid engvar language tag
}, {nowiki=1})
end
--[[--------------------------< L I N K _ A N D _ L A B E L >--------------------------------------------------
Tests various supported combinations of |link= and |label= combinations.
]]
function p:test_12_lang_xx_link_and_label()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
{'code=uk|морити голодом|lit=to kill by starvation|translit=moryty holodom|label=none'},
{'code=uk|морити голодом|lit=to kill by starvation|translit=moryty holodom|label=none|link=no'},
{'code=ff|text=test|translit=something|translit-script=Adlm|label=none'},
{'code=ff|text=test|translit=something|translit-script=Adlm|label=test label'},
}, {nowiki=1})
end
--[[ -------------------------- < I N V E R T _ I T A L I C S > --------------------------
Tests text ouput with |italic=invert set.
]]
function p:test_13_lang_xx_invert_italics()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|code=ar', '}}', '{{#invoke:Lang|lang_xx_inherit|code=ar', '}}',
{
{'|text=text|italic=invert'},
{"|text=''text''|italic=invert"},
{"|text='''''text'''''|italic=invert"},
{"|text='''text'''|italic=invert"},
{"|text=''text's''|italic=invert"},
{"|text=text's|italic=invert"},
}, {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_14_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_15_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 N G V A R >----------------------------------------------------------------
Tests module parameter |engvar= with various legitimate values and translit standards and engvar spelling in the
tooltip
]]
function p:test_16_transl_engvar()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|transl|nocat=yes|', '}}', '{{#invoke:Lang|transl|nocat=yes|', '}}',
{
{'ja|Tōkyō tawā'}, -- generic |engvar= omitted: Japanese-language romanization
{'ja|Tōkyō tawā|envar='}, -- generic |engvar= empty: Japanese-language romanization
{'ja|Tōkyō tawā|engvar=ca'}, -- generic with american-english spelling: Japanese-language romanization
{'ja|Tōkyō tawā|engvar=ie'}, -- generic with british-english spelling: Japanese-language romanisation
{'ko|rr|seongmyeong'}, -- tooltip= Revised Romanization of Korean transliteration; default engvar spelling
{'ko|rr|seongmyeong|engvar='}, -- tooltip= default engvar spelling
{'ko|rr|seongmyeong|engvar=us'}, -- tooltip= default engvar spelling
{'ko|rr|seongmyeong|engvar=in'}, -- tooltip= Revised Romanisation of Korean transliteration
-- at this writing (2024-08-30) yaleko romanization not use at en.wiki
{'ko|yaleko|seongmyeong'}, -- tooltip= Yale romanization of Korean; default engvar spelling
{'ko|yaleko|seongmyeong|engvar='}, -- tooltip= default engvar spelling
{'ko|yaleko|seongmyeong|engvar=us'}, -- tooltip= default engvar spelling
{'ko|yaleko|seongmyeong|engvar=in'}, -- tooltip= Yale romanisation of Korean
}, {nowiki=1})
end
--[[ ========================== < C A T E G O R Y _ F R O M _ T A G _ T E S T S > ========================== ]]
--[[ -------------------------- < C A T E G O R Y _ F R O M _ T A G > --------------------------
Returns category links from IETF tags.
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()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|category_from_tag|nocat=yes|', '}}', '{{#invoke:Lang|category_from_tag|nocat=yes|', '}}',
{
{'fr|link=yes'},
{'ber|link=yes'},
{'en|link=yes'},
{'en-gb|link=yes'},
{'fr'},
{'FR'},
{'ber'},
{'BER'},
{'en'},
{'EN'},
{'en-gb'},
{'EN-GB'},
})
end
--[[ ========================== < N A M E _ F R O M _ T A G _ T E S T S > ========================== ]]
--[[ -------------------------- < N A M E _ F R O M _ T A G > --------------------------
Returns language names from IETF tags.
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_18_name_from_tag()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|name_from_tag|nocat=yes|', '}}', '{{#invoke:Lang|name_from_tag|nocat=yes|', '}}',
{
{'fr|link=yes'},
{'ber|link=yes'},
{'en|link=yes'},
{'en-gb|link=yes'},
{'fr'},
{'FR'},
{'ber'},
{'BER'},
{'en'},
{'EN'},
{'en-gb'},
{'EN-GB'},
})
end
--[[ ========================== < T A G _ F R O M _ N A M E _ T E S T S > ========================== ]]
--[[ -------------------------- < T A G _ F R O M _ N A M E > --------------------------
Returns language IETF tags from language names.
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_19_tag_from_name()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|tag_from_name|nocat=yes|', '}}', '{{#invoke:Lang|tag_from_name|nocat=yes|', '}}',
{
{'french'},
{'French'},
{'FRENCH'},
{'Berber Languages'},
{'Berber languages'},
{'British English'},
{'en'},
{'EN'},
})
end
--[[ ========================== < I S _ I E T F _ T A G _ T E S T S > ========================== ]]
--[[ -------------------------- < I S _ I E T F _ T A G > --------------------------
Returns true if valid IETF tag.
]]
function p:test_20_is_ietf_tag()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|is_ietf_tag|nocat=yes|', '}}', '{{#invoke:Lang|is_ietf_tag|nocat=yes|', '}}',
{
{'french'},
{'French'},
{'FRENCH'},
{'Berber Languages'},
{'Berber languages'},
{'British English'},
{'fr'},
{'FR'},
{'ber'},
{'BER'},
{'en'},
{'EN'},
{'en-gb'},
{'EN-GB'},
})
end
--[[ ========================== < I S _ L A N G _ N A M E _ T E S T S > ========================== ]]
--[[ -------------------------- < I S _ L A N G _ N A M E > --------------------------
Returns true if valid language name.
]]
function p:test_21_is_lang_name()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|is_lang_name|nocat=yes|', '}}', '{{#invoke:Lang|is_lang_name|nocat=yes|', '}}',
{
{'french'},
{'French'},
{'FRENCH'},
{'Berber Languages'},
{'Berber languages'},
{'British English'},
{'fr'},
{'FR'},
{'ber'},
{'BER'},
{'en'},
{'EN'},
{'en-gb'},
{'EN-GB'},
})
end
--[[ ========================== < E R R O R S > ========================== ]]
--[[--------------------------< L A N G _ E R R O R S >------------------------------------------------------------------------
Lang errors.
]]
function p:test_22_lang_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang|nocat=yes|', '}}', '{{#invoke:Lang|lang|nocat=yes|', '}}',
{
{''}, -- no text
{'fr'}, -- no text
{'text=text'}, -- missing language tag
{'fr|code=fr|text'}, -- conflicting |1= and |code=
{'fr|text|text=text'}, -- conflicting |2= and |text=
{'proto=proto-y-bad|text=text'}, -- invalid |proto=
{'fr|\'\'italics\'\''}, -- text has italic markup
{'fr|text={{lang|fr|text=text}}'}, -- text already uses lang attribute
{'fr|malformed\'\'\'\'\'\''}, -- text has malformed markup
{'1ca|text'}, -- unrecognized language tag: 1ca
{'zz|text'}, -- unrecognized language code
{'glg|text'}, -- code: glg promoted to code: gl
{'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_23_lang_xx_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|lang_xx_inherit|nocat=yes|', '}}', '{{#invoke:Lang|lang_xx_inherit|nocat=yes|', '}}',
{
{''}, -- no text
{'code=fr'}, -- no text
{'text=text'}, -- missing language tag
{'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|{{lang|fr|text}}'}, -- text already uses lang attribute
{'code=fr-Latn|script=Latn|text'}, -- redundant script tag
{'code=fr|script=nonsense|text'}, -- unrecognized script: nonsense for code fr
{'code=ar|script=Arab|text'}, -- script: script: arab not supported for code: ar
{'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
{'code=de|script=Armn|variant=1901|text'}, -- unrecognized variant: 1901 for code-script pair: de-armn
{'code=en|variant=1901|text'}, -- unrecognized variant: 1901 for code: en
{'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 > --------------------------
Transl errors.
]]
function p:test_24_transl_errors()
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
--[[ -------------------------- < 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.
]]
function p:test_25_category_from_tag_errors()
self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|category_from_tag|nocat=yes|', '}}', '{{#invoke:Lang|category_from_tag|nocat=yes|', '}}',
{
{'sfsfsfs'},
}, {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_26_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_27_tag_from_name_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
--[[ -------------------------- < H T M L _ T A G _ S E L E C T > --------------------------
html_tag_select errors.
]]
function p:test_28_html_tag_select()
implied_para_content = [[
Text with...
implied paragraph breaks.]]
self:preprocess_equals_preprocess_many(
'{{#invoke:Lang/sandbox|lang_xx_inherit|', '}}',
'{{#invoke:Lang|lang_xx_inherit|', '}}',
{
{'code=ar|نص العنصر النائب'},
{'code=ar|rtl=yes|نص العنصر النائب'},
{'code=ar|{{rtl-para|نص العنصر النائب}}'},
{'code=ar|rtl=yes|{{rtl-para|نص العنصر النائب}}'},
{'code=en|<poem>a test fails<br>Lua</poem>'},
{'code=en|' .. implied_para_content},
}, {nowiki=1, stripmarker=1})
end
return p