Difference between revisions of "Module:ISO 639 name/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Gonnym
blackwiki>Trappist the monk
Line 20: Line 20:
 
{'nv'}, -- 639-1 code
 
{'nv'}, -- 639-1 code
 
{'cic'}, -- 639-2 code
 
{'cic'}, -- 639-2 code
 +
{'ice'}, -- 639-2B code
 
{'nav'}, -- 639-3 code
 
{'nav'}, -- 639-3 code
 
{'apa'}, -- 639-5 code
 
{'apa'}, -- 639-5 code
Line 27: Line 28:
 
{'nv|1'}, -- 639-1 code
 
{'nv|1'}, -- 639-1 code
 
{'nav|2'}, -- 639-2 code
 
{'nav|2'}, -- 639-2 code
 +
{'ice|2B'}, -- 639-2B code
 
{'cic|3'}, -- 639-3 code
 
{'cic|3'}, -- 639-3 code
 
{'apa|5'}, -- 639-5 code
 
{'apa|5'}, -- 639-5 code
Line 34: Line 36:
 
{'el'}, -- 639-1 code in override table
 
{'el'}, -- 639-1 code in override table
 
{'ang'}, -- 639-2 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
 
{'egy'}, -- 639-3 code in override table
 
-- {''}, -- 639-5 code at this writing override table is empty
 
-- {''}, -- 639-5 code at this writing override table is empty
Line 45: Line 48:
 
{'Navajo|1'}, -- 639-1 name
 
{'Navajo|1'}, -- 639-1 name
 
{'Navajo|2'}, -- 639-2 name
 
{'Navajo|2'}, -- 639-2 name
 +
{'Icelandic|2B'}, -- 639-2B name
 
{'Navaho|3'}, -- 639-3 name
 
{'Navaho|3'}, -- 639-3 name
 
{'Apache languages|5'}, -- 639-5 name
 
{'Apache languages|5'}, -- 639-5 name
Line 50: Line 54:
 
{'Navajo|5'}, -- name not in 639-5
 
{'Navajo|5'}, -- name not in 639-5
 
{'Apache languages|3'}, -- name not in 639-3
 
{'Apache languages|3'}, -- name not in 639-3
 +
{'Chickasaw|2B'}, -- name not in 639-2B
 
{'Chickasaw|2'}, -- name not in 639-2
 
{'Chickasaw|2'}, -- name not in 639-2
 
{'Apache languages|1'}, -- name not in 639-1
 
{'Apache languages|1'}, -- name not in 639-1
Line 78: Line 83:
 
{'el'}, -- 639-1 code in override table
 
{'el'}, -- 639-1 code in override table
 
{'ang'}, -- 639-2 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
 
{'egy'}, -- 639-3 code in override table
 
-- {''}, -- 639-5 code at this writing override table is empty
 
-- {''}, -- 639-5 code at this writing override table is empty
Line 84: Line 90:
 
{'nv|link=yes'}, -- links to 639-1 name
 
{'nv|link=yes'}, -- links to 639-1 name
 
{'nav|link=yes|label=Navaho'}, -- links to 639-2 name with alt spelling label
 
{'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
 
{'nav|label=Navaho'}, -- does not link; |label= is ignored
 
},
 
},
Line 127: Line 134:
 
{'nv'}, -- 639-1 code
 
{'nv'}, -- 639-1 code
 
{'nav'}, -- 639-2 code
 
{'nav'}, -- 639-2 code
 +
{'ice'}, -- 639-2B code
 
{'mga'}, -- override 639-2 code
 
{'mga'}, -- override 639-2 code
  
 
{'nav|link=yes'}, -- linked
 
{'nav|link=yes'}, -- linked
 
{'nav|link=yes|label=Navaho'}, -- linked with alt label
 
{'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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2B_to_name|', '}}',
 +
{
 +
{''}, -- 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
 +
-- {''}, -- 639-2B override code; at this writing override table is empty
 +
 +
{'ice|link=yes'}, -- linked
 +
{'ice|link=yes|label=Frozen North'}, -- linked with alt label
 
},
 
},
 
{nowiki=false, templatestyles=true}
 
{nowiki=false, templatestyles=true}
Line 195: Line 227:
 
{'Navajo'}, -- 639-1 name
 
{'Navajo'}, -- 639-1 name
 
{'Navajo'}, -- 639-2 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
 
{'Navaho'}, -- 639-3 name
 
{'Apache languages'}, -- 639-5 name
 
{'Apache languages'}, -- 639-5 name
  
 
{'Navajo|1'}, -- 639-1 name
 
{'Navajo|1'}, -- 639-1 name
{'Navajo|2'}, -- 639-2 name
+
{'Icelandic|2'}, -- 639-2 name
 +
{'Icelandic|2B'}, -- 639-2B name
 
{'Navaho|3'}, -- 639-3 name
 
{'Navaho|3'}, -- 639-3 name
 
{'Apache languages|5'}, -- 639-5 name
 
{'Apache languages|5'}, -- 639-5 name
Line 205: Line 239:
 
{'Navajo|5'}, -- 639-1 name not in 5
 
{'Navajo|5'}, -- 639-1 name not in 5
 
{'Navajo|3'}, -- 639-2 name not in 3
 
{'Navajo|3'}, -- 639-2 name not in 3
 +
{'Navaho|2B'}, -- 639-3 name not in 2B
 
{'Navaho|2'}, -- 639-3 name not in 2
 
{'Navaho|2'}, -- 639-3 name not in 2
 
{'Apache languages|1'}, -- 639-5 name not in 1
 
{'Apache languages|1'}, -- 639-5 name not in 1
Line 212: Line 247:
 
{'Greek'}, -- only 639-1 code in override table
 
{'Greek'}, -- only 639-1 code in override table
 
{'Old English'}, -- 639-2 code in override table
 
{'Old English'}, -- 639-2 code in override table
 +
-- {''}, -- 639-2B code at this writing override table is empty
 
{'Ancient Egyptian'}, -- 639-3 code in override table
 
{'Ancient Egyptian'}, -- 639-3 code in override table
 
-- {''}, -- 639-5 code at this writing override table is empty
 
-- {''}, -- 639-5 code at this writing override table is empty
Line 238: Line 274:
 
{'nv'}, -- 639-1 code
 
{'nv'}, -- 639-1 code
 
{'apa'}, -- 639-2 code
 
{'apa'}, -- 639-2 code
 +
{'ice'}, -- 639-2B code
 
{'nav'}, -- 639-2 code
 
{'nav'}, -- 639-2 code
  

Revision as of 00:22, 1 September 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
			{'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|', '}}', '{{#invoke:ISO 639 name|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
--			{''},																-- 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

-- 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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_1_to_name|', '}}',
		{
			{''},																-- 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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2_to_name|', '}}',
		{
			{''},																-- 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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_2B_to_name|', '}}',
		{
			{''},																-- 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
--			{''},																-- 639-2B override code; at this writing override table is empty

			{'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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_3_to_name|', '}}',
		{
			{''},																-- 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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_5_to_name|', '}}',
		{
			{''},																-- 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|', '}}', '{{#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
--			{''},																-- 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
--			{''},																-- 639-2B code at this writing override table is empty
			{'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|', '}}', '{{#invoke:ISO 639 name|iso_639_code_exists|', '}}',
		{
			{''},																-- 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