Module:LC zh/testcases
Appearance
From mediawiki.org
All tests passed.
test_main:
| Text | Expected | Actual | |
|---|---|---|---|
| Yes | {{#invoke:LC zh|main}} | An error | Caught expected error: Lua error: Unknown content type code "nil". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}}} | An error | Caught expected error: Lua error: Unknown content type code "nil". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N}} | An error | Caught expected error: Lua error: Missing parameter "ns". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = }} | ||
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = User}} | User | User |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = N|ns = Help}} | Help | Help |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User}} | An error | Caught expected error: Lua error in Module:LC_zh at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} | User:Example | User:Example |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} | Help:示例 | Help:示例 |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} | Help:範例 | Help:範例 |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} | 示例 | 示例 |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H}} | An error | Caught expected error: Lua error in Module:LC_zh at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} | 用户 | 用户 |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type = C}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{#invoke:LC zh|main|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} | 示例 | 示例 |
test_template:
| Text | Expected | Actual | |
|---|---|---|---|
| Yes | {{LC zh}} | An error | Caught expected error: Lua error: Unknown content type code "nil". |
| Yes | {{LC zh|lang = {{{lang|}}}}} | An error | Caught expected error: Lua error: Unknown content type code "nil". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = N}} | An error | Caught expected error: Lua error: Missing parameter "ns". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = N|ns = }} | ||
| Yes | {{LC zh|lang = {{{lang|}}}|type = N|ns = User}} | User | User |
| Yes | {{LC zh|lang = {{{lang|}}}|type = N|ns = Help}} | Help | Help |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|ns = User}} | An error | Caught expected error: Lua error in Module:LC_zh at line 591: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example}} | User:Example | User:Example |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例}} | Help:示例 | Help:示例 |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例}} | Help:範例 | Help:範例 |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例}} | 示例 | 示例 |
| Yes | {{LC zh|lang = {{{lang|}}}|type = H}} | An error | Caught expected error: Lua error in Module:LC_zh at line 620: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{LC zh|lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶}} | 用户 | 用户 |
| Yes | {{LC zh|lang = {{{lang|}}}|type = C}} | An error | Caught expected error: Lua error: Require at least one of the parameter: "zh-hans", "zh-hant", "zh-hk". |
| Yes | {{LC zh|lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例}} | 示例 | 示例 |
test_template_localized_link:
| Text | Expected | Actual | |
|---|---|---|---|
| Yes | {{Localized link}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |
test_template_localized_link_sandbox:
| Text | Expected | Actual | |
|---|---|---|---|
| Yes | {{Localized link/sandbox}} | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> | [[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style="display:none">[[:{{{1}}}| ]]</span> |
The above documentation is transcluded from Module:LC zh/testcases/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (edit) pages.
Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (edit) pages.
Subpages of this module.
--- Unit tests for [[Module:LC zh]]. Click talk page to run tests. -- -- self:preprocess_equals( "{{#invoke:LC zh|main}}", "" ) -- -- self:preprocess_equals_many( -- "{{#invoke:LC zh|main|", "}}", -- { -- { "", "" }, -- } -- ) -- -- @var table localp=require([[Module:UnitTests]]) localcurrent_frame=mw.getCurrentFrame() -- Title.pageLang.code is an expensive function in Scribunto, thus not using -- pageLang.code here -- -- @var string localpage_lang_code=current_frame:preprocess("{{PAGELANGUAGE}}") -- @var string localui_lang_code=current_frame:callParserFunction{ name="int",args={"lang"} } -- @var string localfunctionlang_code_type(lang_code) iflang_code=="zh"then return"zh" elseif( lang_code=="zh-hans"or lang_code=="zh-cn"or lang_code=="zh-my"or lang_code=="zh-sg" )then return"zh-hans" elseif( lang_code=="zh-hant"or lang_code=="zh-tw" )then return"zh-hant" elseif( lang_code=="zh-hk"or lang_code=="zh-mo" )then return"zh-hk" else returnnil end end -- @var string localfunctionui_lang_code_type() returnlang_code_type(ui_lang_code) end -- @return table localfunctionprovide_test_main() return{ {"lang = {{{lang|}}}",error=true}, {"lang = {{{lang|}}}|type = N",error=true}, {"lang = {{{lang|}}}|type = N|ns = ",""}, { "lang = {{{lang|}}}|type = N|ns = User", page_lang_code=="zh"and "-{zh:User; zh-hans:用户; zh-hant:使用者; zh-hk:用戶;}-"or ui_lang_code_type()=="zh"and"User"or ui_lang_code_type()=="zh-hans"and"用户"or ui_lang_code_type()=="zh-hant"and"使用者"or ui_lang_code_type()=="zh-hk"and"用戶"or "User" }, { "lang = {{{lang|}}}|type = N|ns = Help", page_lang_code=="zh"and "-{zh:Help; zh-hans:帮助; zh-hant:說明;}-"or ui_lang_code_type()=="zh"and"Help"or ui_lang_code_type()=="zh-hans"and"帮助"or ui_lang_code_type()=="zh-hant"and"說明"or ui_lang_code_type()=="zh-hk"and"說明"or "Help" }, {"lang = {{{lang|}}}|type = T",error=true}, {"lang = {{{lang|}}}|type = T|ns = User",error=true}, { "lang = {{{lang|}}}|type = T|ns = User|zh-hans = Example|zh-hant = Example", page_lang_code=="zh"and "-{zh:User; zh-hans:用户; zh-hant:使用者; zh-hk:用戶;}-:".. "-{zh-hans:Example; zh-hant:Example;}-"or ui_lang_code_type()=="zh-hans"and"用户:Example"or ui_lang_code_type()=="zh-hant"and"使用者:Example"or ui_lang_code_type()=="zh-hk"and"用戶:Example"or "User:Example" }, { "lang = {{{lang|}}}|type = T|ns = Help|zh-hans = 示例|zh-hant = 範例", page_lang_code=="zh"and "-{zh:Help; zh-hans:帮助; zh-hant:說明;}-:".. "-{zh-hans:示例; zh-hant:範例;}-"or ui_lang_code_type()=="zh-hans"and"帮助:示例"or ui_lang_code_type()=="zh-hant"and"說明:範例"or ui_lang_code_type()=="zh-hk"and"說明:範例"or "Help:示例" }, { "lang = {{{lang|}}}|type = T|ns = Help|zh-hant = 範例", page_lang_code=="zh"and "-{zh:Help; zh-hans:帮助; zh-hant:說明;}-:".. "範例"or ui_lang_code_type()=="zh-hans"and"帮助:範例"or ui_lang_code_type()=="zh-hant"and"說明:範例"or ui_lang_code_type()=="zh-hk"and"說明:範例"or "Help:範例" }, {"lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help",error=true}, { "lang = {{{lang|}}}|type = T|hide_ns = 1|ns = Help|zh-hans = 示例|zh-hant = 範例", page_lang_code=="zh"and "-{zh-hans:示例; zh-hant:範例;}-"or ui_lang_code_type()=="zh-hans"and"示例"or ui_lang_code_type()=="zh-hant"and"範例"or ui_lang_code_type()=="zh-hk"and"範例"or "示例" }, {"lang = {{{lang|}}}|type = H",error=true}, { "lang = {{{lang|}}}|type = H|zh-hans = 用户|zh-hant = 使用者|zh-hk = 用戶", page_lang_code=="zh"and "<span id=\"用户\"></span>".. "<span id=\"使用者\"></span>".. "<span id=\"用戶\"></span>".. "-{zh-hans:用户; zh-hant:使用者; zh-hk:用戶;}-"or ui_lang_code_type()=="zh-hans"and "<span id=\"用户\"></span>".. "<span id=\"使用者\"></span>".. "<span id=\"用戶\"></span>".. "用户"or ui_lang_code_type()=="zh-hant"and "<span id=\"用户\"></span>".. "<span id=\"使用者\"></span>".. "<span id=\"用戶\"></span>".. "使用者"or ui_lang_code_type()=="zh-hk"and "<span id=\"用户\"></span>".. "<span id=\"使用者\"></span>".. "<span id=\"用戶\"></span>".. "用戶"or "<span id=\"用户\"></span>".. "<span id=\"使用者\"></span>".. "<span id=\"用戶\"></span>".. "用户" }, {"lang = {{{lang|}}}|type = C",error=true}, { "lang = {{{lang|}}}|type=C|zh-hans=示例|zh-hant=範例", page_lang_code=="zh"and "-{zh-hans:示例; zh-hant:範例;}-"or ui_lang_code_type()=="zh-hans"and"示例"or ui_lang_code_type()=="zh-hant"and"範例"or ui_lang_code_type()=="zh-hk"and"範例"or "示例" }, } end functionp:test_main() self:preprocess_expect_error("{{#invoke:LC zh|main}}") self:preprocess_equals_many( "{{#invoke:LC zh|main|","}}",provide_test_main() ) end functionp:test_template() self:preprocess_expect_error("{{LC zh}}") self:preprocess_equals_many("{{LC zh|","}}",provide_test_main()) end -- TODO functionp:test_template_localized_link() self:preprocess_equals("{{Localized link}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) ifpage_lang_code=="zh"andui_lang_code_type()~=nilthen ifui_lang_code_type()=="zh"then self:preprocess_equals("{{Localized link}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hans"then self:preprocess_equals("{{Localized link}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hant"then self:preprocess_equals("{{Localized link}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hk"then self:preprocess_equals("{{Localized link}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) end end end functionp:test_template_localized_link_sandbox() self:preprocess_equals("{{Localized link/sandbox}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) ifpage_lang_code=="zh"andui_lang_code_type()~=nilthen ifui_lang_code_type()=="zh"then self:preprocess_equals("{{Localized link/sandbox}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hans"then self:preprocess_equals("{{Localized link/sandbox}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hant"then self:preprocess_equals("{{Localized link/sandbox}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) elseifui_lang_code_type()=="zh-hk"then self:preprocess_equals("{{Localized link/sandbox}}","[[Special:MyLanguage/{{{1}}}|{{{1}}}]]<span style=\"display:none\">[[:{{{1}}}| ]]</span>",{nowiki=true}) end end end returnp