Difference between revisions of "Module:Lang/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Trappist the monk
blackwiki>Trappist the monk
Line 1: Line 1:
 
local p = require('Module:UnitTests')
 
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', present but not set, and the invalid 'whatever'.  There
 +
is a separate test for the parameter not present.
 +
 +
|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.
 +
 +
]]
 +
 +
function p:test_lang_italic()
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=', '}}',
 +
    {
 +
    {'yes'}, {'no'}, {''}, {'whatever'},
 +
    }, {nowiki=1})
 +
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang|code=ar|text}}', '{{#invoke:lang|lang|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 when |script=arab or |script=latn
 +
 +
|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 &lrm; marker
 +
 +
]]
 +
 +
function p:test_lang_italic_with_script()
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=yes|script=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=yes|script=', '}}',
 +
    {
 +
    {'arab'}, {'latn'},
 +
    }, {nowiki=1})
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=no|script=', '}}', '{{#invoke:lang|lang|code=ar|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 &lrm; marker
 +
 +
]]
 +
 +
function p:test_lang_script()
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=|script=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=|script=', '}}',
 +
    {
 +
    {'arab'}, {'latn'},
 +
    }, {nowiki=1})
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|script=', '}}', '{{#invoke:lang|lang|code=ar|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 &lrm; marker
 +
 +
]]
 +
 +
function p:test_lang_rtl()
 +
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|rtl=', '}}', '{{#invoke:lang|lang|code=ar|text|rtl=', '}}',
 +
    {
 +
    {'yes'}, {'no'}, {''}, {'whatever'},
 +
    }, {nowiki=1})
 +
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang|code=ar|text}}', '{{#invoke:lang|lang|code=ar|text}}',
 +
{nowiki=1})
 +
end;
 +
 +
 +
--[[==========================<< L A N G _ X X  T E S T S===================================================]]
  
 
--[[--------------------------< I T A L I C >------------------------------------------------------------------
 
--[[--------------------------< I T A L I C >------------------------------------------------------------------
Line 84: Line 172:
 
{nowiki=1})
 
{nowiki=1})
 
end;
 
end;
 
  
 
return p
 
return p

Revision as of 23:32, 19 November 2017

Documentation for this module may be created at Module:Lang/testcases/doc

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', present but not set, and the invalid 'whatever'.  There
is a separate test for the parameter not present.

|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.

]]

function p:test_lang_italic()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=', '}}',
    	{
    	{'yes'}, {'no'}, {''}, {'whatever'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang|code=ar|text}}', '{{#invoke:lang|lang|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 when |script=arab or |script=latn

|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 &lrm; marker

]]

function p:test_lang_italic_with_script()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=yes|script=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=yes|script=', '}}',
    	{
    	{'arab'}, {'latn'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=no|script=', '}}', '{{#invoke:lang|lang|code=ar|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 &lrm; marker

]]

function p:test_lang_script()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|italic=|script=', '}}', '{{#invoke:lang|lang|code=ar|text|italic=|script=', '}}',
    	{
    	{'arab'}, {'latn'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|script=', '}}', '{{#invoke:lang|lang|code=ar|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 &lrm; marker

]]

function p:test_lang_rtl()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang|code=ar|text|rtl=', '}}', '{{#invoke:lang|lang|code=ar|text|rtl=', '}}',
    	{
    	{'yes'}, {'no'}, {''}, {'whatever'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang|code=ar|text}}', '{{#invoke:lang|lang|code=ar|text}}',
		{nowiki=1})
end;


--[[==========================<< L A N G _ X X   T E S T S===================================================]]

--[[--------------------------< I T A L I C >------------------------------------------------------------------

Tests module parameter |italic= with values 'yes', 'no', present but not set, and the invalid 'whatever'.  There
is a separate test for the parameter not present.

|italic=yes or |italic=no overrides every other parameter that might set the rendered text's font.

]]

function p:test_lang_xx_italic()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|italic=', '}}', '{{#invoke:lang|lang_xx|code=ar|text|italic=', '}}',
    	{
    	{'yes'}, {'no'}, {''}, {'whatever'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang_xx|code=ar|text}}', '{{#invoke:lang|lang_xx|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 when |script=arab or |script=latn

|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 &lrm; marker

]]

function p:test_lang_xx_italic_with_script()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|italic=yes|script=', '}}', '{{#invoke:lang|lang_xx|code=ar|text|italic=yes|script=', '}}',
    	{
    	{'arab'}, {'latn'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|italic=no|script=', '}}', '{{#invoke:lang|lang_xx|code=ar|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 &lrm; marker

]]

function p:test_lang_xx_script()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|italic=|script=', '}}', '{{#invoke:lang|lang_xx|code=ar|text|italic=|script=', '}}',
    	{
    	{'arab'}, {'latn'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|script=', '}}', '{{#invoke:lang|lang_xx|code=ar|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 &lrm; marker

]]

function p:test_lang_xx_rtl()
    self:preprocess_equals_preprocess_many('{{#invoke:lang/sandbox|lang_xx|code=ar|text|rtl=', '}}', '{{#invoke:lang|lang_xx|code=ar|text|rtl=', '}}',
    	{
    	{'yes'}, {'no'}, {''}, {'whatever'},
    	}, {nowiki=1})
    self:preprocess_equals_preprocess('{{#invoke:lang/sandbox|lang_xx|code=ar|text}}', '{{#invoke:lang|lang_xx|code=ar|text}}',
		{nowiki=1})
end;

return p