Module:ISO 639 name/testcases
Appearance
![]() | This is the test cases page for the module Module:ISO 639 name. Results of the test cases. |
--[=[
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|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639|cat=no|', '}}',
{
{''}, -- no code param
{'xx'}, -- not a 639-1 code
{'nv'}, -- 639-1 code
{'cic'}, -- 639-2 code
{'ice'}, -- 639-2B 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
{'ice|2B'}, -- 639-2B 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
-- {''}, -- 639-2B code at this writing override table is empty
{'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
{'Icelandic|2B'}, -- 639-2B 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|2B'}, -- name not in 639-2B
{'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_code_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|cat=no|', '}}',
{
{''}, -- 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
{'tib'}, -- 639-2B 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
{'ice|link=yes|label=Frozen North'}, -- links to 639-2B 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_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_1_to_name|cat=no|', '}}',
{
{''}, -- no language param
{'xx'}, -- not a 639-1 code
{'xx|hide-err=yes'}, -- not a 639-1 code
{'nv-Latn'}, -- ietf tag
{'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_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2_to_name|cat=no|', '}}',
{
{''}, -- no language param
{'xxx'}, -- not a 639-2 code
{'xxx|hide-err=yes'}, -- not a 639-2 code
{'nav-Latn'}, -- ietf tag
{'nv'}, -- 639-1 code
{'nav'}, -- 639-2 code
{'ice'}, -- 639-2B 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 _ 2 B _ T O _ N A M E >--------------------------------
]]
function p:test_iso_639_code_2B_to_name()
self:preprocess_equals_preprocess_many(
'{{#invoke:ISO 639 name/sandbox|iso_639_code_2B_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2B_to_name|cat=no|', '}}',
{
{''}, -- no language param
{'xxx'}, -- not a 639-2 code
{'xxx|hide-err=yes'}, -- not a 639-2 code
{'nav-Latn'}, -- ietf tag
{'nv'}, -- 639-1 code
{'nav'}, -- 639-2T code
{'ice'}, -- 639-2B code
{'tib'}, -- 639-2B code in override table
{'ice|link=yes'}, -- linked
{'ice|link=yes|label=Frozen North'}, -- 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_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_3_to_name|cat=no|', '}}',
{
{''}, -- no language param
{'xxx'}, -- not a 639-3 code
{'xxx|hide-err=yes'}, -- not a 639-3 code
{'nav-Latn'}, -- ietf tag
{'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_to_name|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_5_to_name|cat=no|', '}}',
{
{''}, -- no language param
{'xxx'}, -- not a 639-5 code
{'xxx|hide-err=yes'}, -- not a 639-5 code
{'nav-Latn'}, -- ietf tag
{'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|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_name_to_code|cat=no|', '}}',
{
{''}, -- no name param
{'nv'}, -- 639-1 code
--language names --
{'Navajo'}, -- 639-1 name
{'Navajo'}, -- 639-2 name
-- {''}, -- 639-2B names same as -1, -2T names so -1 name will be used for this test
{'Navaho'}, -- 639-3 name
{'Apache languages'}, -- 639-5 name
{'Navajo|1'}, -- 639-1 name
{'Icelandic|2'}, -- 639-2 name
{'Icelandic|2B'}, -- 639-2B 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|2B'}, -- 639-3 name not in 2B
{'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
{'Standard Tibetan'}, -- 639-2B code in override table; same as -1 and -2 so -1 code is returned
{'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_code_exists|cat=no|', '}}', '{{#invoke:ISO 639 name|iso_639_code_exists|cat=no|', '}}',
{
{''}, -- no code param
{'xx'}, -- not a 639-1 code
{'xxx'}, -- not a 639-2, 3, 5 code
{'nv'}, -- 639-1 code
{'apa'}, -- 639-2 code
{'ice'}, -- 639-2B 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