Difference between revisions of "Module:ISO 639 name/testcases"
Jump to navigation
Jump to search
blackwiki>Trappist the monk |
blackwiki>Trappist the monk |
||
| Line 17: | Line 17: | ||
{ | { | ||
{''}, -- no code param | {''}, -- no code param | ||
| + | {'xx'}, -- not a 639-1 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'cic'}, -- 639-2 code | {'cic'}, -- 639-2 code | ||
| Line 23: | Line 24: | ||
{'|'}, -- no code param, no 639-part param | {'|'}, -- no code param, no 639-part param | ||
| + | {'xx|1'}, -- not a 639-1 code | ||
{'nv|1'}, -- 639-1 code | {'nv|1'}, -- 639-1 code | ||
{'nav|2'}, -- 639-2 code | {'nav|2'}, -- 639-2 code | ||
| Line 67: | Line 69: | ||
{ | { | ||
{''}, -- no language param | {''}, -- no language param | ||
| + | {'xx'}, -- not a 639-1 code | ||
| + | {'xxx'}, -- not a 639-2, 3, 5 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'nav'}, -- 639-2 code | {'nav'}, -- 639-2 code | ||
| Line 95: | Line 99: | ||
{ | { | ||
{''}, -- no language param | {''}, -- no language param | ||
| + | {'xx'}, -- not a 639-1 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'nav'}, -- 639-2 code | {'nav'}, -- 639-2 code | ||
| Line 115: | Line 120: | ||
{ | { | ||
{''}, -- no language param | {''}, -- no language param | ||
| + | {'xxx'}, -- not a 639-2 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'nav'}, -- 639-2 code | {'nav'}, -- 639-2 code | ||
| Line 135: | Line 141: | ||
{ | { | ||
{''}, -- no language param | {''}, -- no language param | ||
| + | {'xxx'}, -- not a 639-3 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'nav'}, -- 639-3 code | {'nav'}, -- 639-3 code | ||
| Line 155: | Line 162: | ||
{ | { | ||
{''}, -- no language param | {''}, -- no language param | ||
| + | {'xxx'}, -- not a 639-5 code | ||
{'nv'}, -- 639-1 code | {'nv'}, -- 639-1 code | ||
{'apa'}, -- 639-5 code | {'apa'}, -- 639-5 code | ||
Revision as of 11:03, 12 August 2020
Documentation for this module may be created at Module:ISO 639 name/testcases/doc
--[=[
Unit tests for [[Module:Citation/CS1]] error messages. This is not intended to test every possible thing that
can make an error message; rather, it is to test the creation and rendering of the messages themselves.
Click talk page to run tests.
]=]
local p = require('Module:UnitTests')
--[[--------------------------< I S O _ 6 3 9 >----------------------------------------------------------------
]]
function p:test_iso_639()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639|', '}}', '{{#invoke:ISO 639 name|iso_639|', '}}',
{
{''}, -- no code param
{'xx'}, -- not a 639-1 code
{'nv'}, -- 639-1 code
{'cic'}, -- 639-2 code
{'nav'}, -- 639-3 code
{'apa'}, -- 639-5 code
{'|'}, -- no code param, no 639-part param
{'xx|1'}, -- not a 639-1 code
{'nv|1'}, -- 639-1 code
{'nav|2'}, -- 639-2 code
{'cic|3'}, -- 639-3 code
{'apa|5'}, -- 639-5 code
{'apa|6'}, -- invalid 639-part
{'el'}, -- 639-1 code in override table
{'ang'}, -- 639-2 code in override table
{'egy'}, -- 639-3 code in override table
-- {''}, -- 639-5 code at this writing override table is empty
--language names --
{'Navajo'}, -- 639-1 name
{'Navajo'}, -- 639-2 name
{'Navaho'}, -- 639-3 name
{'Apache languages'}, -- 639-5 name
{'Navajo|1'}, -- 639-1 name
{'Navajo|2'}, -- 639-2 name
{'Navaho|3'}, -- 639-3 name
{'Apache languages|5'}, -- 639-5 name
{'Navajo|5'}, -- name not in 639-5
{'Apache languages|3'}, -- name not in 639-3
{'Chickasaw|2'}, -- name not in 639-2
{'Apache languages|1'}, -- name not in 639-1
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ T O _ N A M E >--------------------------------------
cannot specify part
]]
function p:test_iso_639_code_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_name|', '}}', '{{#invoke:ISO 639 name|iso_639_name|', '}}', -- TODO: update function name to iso_639_code_to_name
{
{''}, -- no language param
{'xx'}, -- not a 639-1 code
{'xxx'}, -- not a 639-2, 3, 5 code
{'nv'}, -- 639-1 code
{'nav'}, -- 639-2 code
{'nav'}, -- 639-3 code
{'apa'}, -- 639-5 code
{'el'}, -- 639-1 code in override table
{'ang'}, -- 639-2 code in override table
{'egy'}, -- 639-3 code in override table
-- {''}, -- 639-5 code at this writing override table is empty
-- link & label
{'nv|link=yes'}, -- links to 639-1 name
{'nav|link=yes|label=Navaho'}, -- links to 639-2 name with alt spelling label
{'nav|label=Navaho'}, -- does not link; |label= is ignored
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ 1 _ T O _ N A M E >----------------------------------
]]
function p:test_iso_639_code_1_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_code_1|', '}}', '{{#invoke:ISO 639 name|iso_639_code_1|', '}}', -- TODO: update function name to iso_639_code_1_to_name
{
{''}, -- no language param
{'xx'}, -- not a 639-1 code
{'nv'}, -- 639-1 code
{'nav'}, -- 639-2 code
{'el'}, -- override 639-1 code
{'nv|link=yes'}, -- linked
{'nv|link=yes|label=Navaho'}, -- linked with alt label
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ 2 _ T O _ N A M E >----------------------------------
]]
function p:test_iso_639_code_2_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_code_2|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2|', '}}', -- TODO: update function name to iso_639_code_2_to_name
{
{''}, -- no language param
{'xxx'}, -- not a 639-2 code
{'nv'}, -- 639-1 code
{'nav'}, -- 639-2 code
{'mga'}, -- override 639-2 code
{'nav|link=yes'}, -- linked
{'nav|link=yes|label=Navaho'}, -- linked with alt label
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ 3 _ T O _ N A M E >----------------------------------
]]
function p:test_iso_639_code_3_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_code_3|', '}}', '{{#invoke:ISO 639 name|iso_639_code_3|', '}}', -- TODO: update function name to iso_639_code_3_to_name
{
{''}, -- no language param
{'xxx'}, -- not a 639-3 code
{'nv'}, -- 639-1 code
{'nav'}, -- 639-3 code
{'pms'}, -- override 639-3 code
{'nav|link=yes'}, -- linked
{'nav|link=yes|label=Navajo'}, -- linked with alt label
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ 5 _ T O _ N A M E >----------------------------------
]]
function p:test_iso_639_code_5_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_code_5|', '}}', '{{#invoke:ISO 639 name|iso_639_code_5|', '}}', -- TODO: update function name to iso_639_code_5_to_name
{
{''}, -- no language param
{'xxx'}, -- not a 639-5 code
{'nv'}, -- 639-1 code
{'apa'}, -- 639-5 code
-- {''}, -- override 639-5 code; none at this writing
{'apa|link=yes'}, -- linked
{'apa|link=yes|label=Apache'}, -- linked with alt label
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ N A M E _ T O _ C O D E >--------------------------------------
]]
function p:test_iso_639_name_to_code()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|', '}}', '{{#invoke:ISO 639 name|iso_639_name_to_code|', '}}',
{
{''}, -- no name param
{'nv'}, -- 639-1 code
--language names --
{'Navajo'}, -- 639-1 name
{'Navajo'}, -- 639-2 name
{'Navaho'}, -- 639-3 name
{'Apache languages'}, -- 639-5 name
{'Navajo|1'}, -- 639-1 name
{'Navajo|2'}, -- 639-2 name
{'Navaho|3'}, -- 639-3 name
{'Apache languages|5'}, -- 639-5 name
{'Navajo|5'}, -- 639-1 name not in 5
{'Navajo|3'}, -- 639-2 name not in 3
{'Navaho|2'}, -- 639-3 name not in 2
{'Apache languages|1'}, -- 639-5 name not in 1
{'Apache languages|6'}, -- invalid 639-part
{'Greek'}, -- only 639-1 code in override table
{'Old English'}, -- 639-2 code in override table
{'Ancient Egyptian'}, -- 639-3 code in override table
-- {''}, -- 639-5 code at this writing override table is empty
-- these should not link
{'Navajo|link=yes'}, -- 639-1 name
{'Navajo|link=yes|label=Navajo'}, -- 639-2 name
{'Navaho|label=Navajo'}, -- 639-3 name
},
{nowiki=false, templatestyles=true}
)
end
--[[--------------------------< I S O _ 6 3 9 _ C O D E _ E X I S T S >----------------------------------------
]]
function p:test_iso_639_code_exists()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_name_exists|', '}}', '{{#invoke:ISO 639 name|iso_639_name_exists|', '}}', -- TODO: update function name to iso_639_code_exists
{
{''}, -- no language param
{'nv'}, -- 639-1 code
{'apa'}, -- 639-2 code
{'nav'}, -- 639-2 code
{'el'}, -- override 639-1 code
{'mga'}, -- override 639-2 code
{'pms'}, -- override 639-3 code
},
{nowiki=false, templatestyles=true}
)
end
return p