Module:Error/testcases: Difference between revisions
Appearance
Content deleted Content added
Not an example |
cleanup tests |
||
Line 3: | Line 3: | ||
function p:test_error() |
function p:test_error() |
||
self:preprocess_equals_sandbox_many('{{#invoke:Error', 'error', { |
|||
-- Minimal parameter input |
-- Minimal parameter input |
||
{'', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error}}', '{{Error}}') |
|||
{'', '<strong class="error"></strong>', {nowiki = 'yes'}}, |
|||
{' ', '<strong class="error"> </strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|}}', '{{Error|}}') |
|||
{' ', '<strong class="error"> </strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error| }}', '{{Error| }}') -- space   |
|||
{'{{!}}', '<strong class="error">|</strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|{{!}}}}', '{{Error|{{!}}}}') |
|||
{'|tag=p', '<p class="error"></p>', {nowiki = 'yes'}}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|{{!}}tag=p}}', '{{Error|{{!}}tag=p}}') |
|||
{'|message=', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=}}', '{{Error|message=}}') |
|||
{'|message=', '<strong class="error"></strong>', {nowiki = 'yes'}}, |
|||
{'|message=|tag=p', '<p class="error"></p>', {nowiki = 'yes'}}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=|tag=p}}', '{{Error|message=|tag=p}}') |
|||
{'|1', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=}}', '{{Error|1=}}') |
|||
{'|1=', '<strong class="error"></strong>', {nowiki = 'yes'}}, |
|||
{'|1=|tag=p', '<p class="error"></p>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=|tag=p}}', '{{Error|1=|tag=p}}') |
|||
-- Plain message |
-- Plain message |
||
{'|Example error message', '<strong class="error"></strong>'}, |
|||
{'| Example error message ', '<strong class="error"></strong>'}, |
|||
{'|message=Example error message', '<strong class="error">Example error message</strong>'}, |
|||
{'|message = Example error message ', '<strong class="error">Example error message</strong>'}, |
|||
-- tag |
-- tag |
||
{'|Example error message|tag=p', '<p class="error"></p>'}, |
|||
{'|tag=p', '<p class="error"></p>'}, -- no message |
|||
{'|Example error message| tag = p', '<p class="error"></p>', {nowiki = 'yes'}}, |
|||
{'|Example error message|tag=div', '<div class="error"></div>'}, |
|||
{'|Example error message|tag=div', '<div class="error"></div>'}, |
|||
{'|Example error message|tag=span', '<span class="error"></span>'}, |
|||
{'|Example error message|tag=adsf', '<strong class="error"></strong>'}, |
|||
{'|Example error message|tag=strong', '<strong class="error"></strong>'}, |
|||
{'|Example error message|tag=�', '<strong class="error"></strong>'}, -- ASCII nul |
|||
{'|Example error message|tag= ', '<strong class="error"></strong>'}, -- nbsp |
|||
{'|Example error message|tag={{!}}', '<strong class="error"></strong>'}, |
|||
-- Use numbered parameter |
-- Use numbered parameter |
||
{'|1=Example error message', '<strong class="error">Example error message</strong>'}, |
|||
{'|1= Example error message ', '<strong class="error">Example error message</strong>'}, |
|||
{'|Example = message', '<strong class="error"></strong>'}, |
|||
{'|1= Example = message ', '<strong class="error">Example = message</strong>'}, |
|||
-- More extreme input options |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error| }}', '{{Error| }}') -- nbsp |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|<br/>}}', '{{Error|<br/>}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|\n}}', '{{Error|\n}}', {nowiki = 'yes'}) |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|�}}', '{{Error|�}}') -- ASCII nul |
|||
-- Tricky input options |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|0}}', '{{Error|0}}') -- nbsp |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|false}}', '{{Error|false}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|tag=tag}}', '{{Error|tag=tag}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1}}', '{{Error|1}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|true}}', '{{Error|true}}') |
|||
end |
|||
function p:test_error_sandbox() |
|||
-- Minimal parameter input |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error}}', '{{Error/sandbox}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error}}', '{{Error/sandbox}}', {nowiki = 'yes'}) |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|}}', '{{Error/sandbox|}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error| }}', '{{Error/sandbox| }}') -- space   |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|{{!}}}}', '{{Error/sandbox|{{!}}}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|{{!}}tag=p}}', '{{Error/sandbox|{{!}}tag=p}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=}}', '{{Error/sandbox|message=}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=}}', '{{Error/sandbox|message=}}', {nowiki = 'yes'}) |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=|tag=p}}', '{{Error/sandbox|message=|tag=p}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=}}', '{{Error/sandbox|1=}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=}}', '{{Error/sandbox|1=}}', {nowiki = 'yes'}) |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=|tag=p}}', '{{Error/sandbox|1=|tag=p}}') |
|||
-- Plain message |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message}}', '{{Error/sandbox|Example error message}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error| Example error message }}', '{{Error/sandbox| Example error message }}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message=Example error message}}', '{{Error/sandbox|message=Example error message}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|message = Example error message }}', '{{Error/sandbox|message = Example error message }}') |
|||
-- tag |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=p}}', '{{Error/sandbox|Example error message|tag=p}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|tag=p}}', '{{Error/sandbox|tag=p}}') -- no message |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message| tag = p}}', '{{Error/sandbox|Example error message| tag = p}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=div}}', '{{Error/sandbox|Example error message|tag=div}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=div}}', '{{Error/sandbox|Example error message|tag=div}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=span}}', '{{Error/sandbox|Example error message|tag=span}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=adsf}}', '{{Error/sandbox|Example error message|tag=asdf}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=strong}}', '{{Error/sandbox|Example error message|tag=strong}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag=�}}', '{{Error/sandbox|Example error message|tag=�}}') -- ASCII nul |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag= }}', '{{Error/sandbox|Example error message|tag= }}') -- nbsp |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example error message|tag={{!}}}}', '{{Error/sandbox|Example error message|tag={{!}}}}') |
|||
-- Use numbered parameter |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1=Example error message}}', '{{Error/sandbox|1=Example error message}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1= Example error message }}', '{{Error/sandbox|1= Example error message }}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|Example = message}}', '{{Error/sandbox|Example = message}}') |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1= Example = message }}', '{{Error/sandbox|1= Example = message }}') |
|||
-- More extreme input options |
-- More extreme input options |
||
{'| ', '<strong class="error"></strong>'}, -- nbsp |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error| }}', '{{Error/sandbox| }}') -- nbsp |
|||
{'|<br/>', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|<br/>}}', '{{Error/sandbox|<br/>}}') |
|||
{'|\n', '<strong class="error"></strong>', {nowiki = 'yes'}}, |
|||
{'|�', '<strong class="error"></strong>'}, -- ASCII nul |
|||
-- Tricky input options |
-- Tricky input options |
||
{'|0', '<strong class="error"></strong>'}, -- nbsp |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|0}}', '{{Error/sandbox|0}}') |
|||
{'|false', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|false}}', '{{Error/sandbox|false}}') |
|||
{'|tag=tag', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|tag=tag}}', '{{Error/sandbox|tag=tag}}', {nowiki = 'yes'}) |
|||
{'|1', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|1}}', '{{Error/sandbox|1}}') |
|||
{'|true', '<strong class="error"></strong>'}, |
|||
self:preprocess_equals_preprocess('{{#invoke:Error|error|true}}', '{{Error/sandbox|true}}') |
|||
}, {nowiki=1}) |
|||
end |
end |
||
Revision as of 17:41, 23 March 2022
![]() | This is the test cases page for the module Module:Error. Results of the test cases. |
-- Unit tests for [[Module:Error]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_error()
self:preprocess_equals_sandbox_many('{{#invoke:Error', 'error', {
-- Minimal parameter input
{'', '<strong class="error"></strong>'},
{'', '<strong class="error"></strong>', {nowiki = 'yes'}},
{' ', '<strong class="error"> </strong>'},
{' ', '<strong class="error"> </strong>'},
{'{{!}}', '<strong class="error">|</strong>'},
{'|tag=p', '<p class="error"></p>', {nowiki = 'yes'}},
{'|message=', '<strong class="error"></strong>'},
{'|message=', '<strong class="error"></strong>', {nowiki = 'yes'}},
{'|message=|tag=p', '<p class="error"></p>', {nowiki = 'yes'}},
{'|1', '<strong class="error"></strong>'},
{'|1=', '<strong class="error"></strong>', {nowiki = 'yes'}},
{'|1=|tag=p', '<p class="error"></p>'},
-- Plain message
{'|Example error message', '<strong class="error"></strong>'},
{'| Example error message ', '<strong class="error"></strong>'},
{'|message=Example error message', '<strong class="error">Example error message</strong>'},
{'|message = Example error message ', '<strong class="error">Example error message</strong>'},
-- tag
{'|Example error message|tag=p', '<p class="error"></p>'},
{'|tag=p', '<p class="error"></p>'}, -- no message
{'|Example error message| tag = p', '<p class="error"></p>', {nowiki = 'yes'}},
{'|Example error message|tag=div', '<div class="error"></div>'},
{'|Example error message|tag=div', '<div class="error"></div>'},
{'|Example error message|tag=span', '<span class="error"></span>'},
{'|Example error message|tag=adsf', '<strong class="error"></strong>'},
{'|Example error message|tag=strong', '<strong class="error"></strong>'},
{'|Example error message|tag=�', '<strong class="error"></strong>'}, -- ASCII nul
{'|Example error message|tag= ', '<strong class="error"></strong>'}, -- nbsp
{'|Example error message|tag={{!}}', '<strong class="error"></strong>'},
-- Use numbered parameter
{'|1=Example error message', '<strong class="error">Example error message</strong>'},
{'|1= Example error message ', '<strong class="error">Example error message</strong>'},
{'|Example = message', '<strong class="error"></strong>'},
{'|1= Example = message ', '<strong class="error">Example = message</strong>'},
-- More extreme input options
{'| ', '<strong class="error"></strong>'}, -- nbsp
{'|<br/>', '<strong class="error"></strong>'},
{'|\n', '<strong class="error"></strong>', {nowiki = 'yes'}},
{'|�', '<strong class="error"></strong>'}, -- ASCII nul
-- Tricky input options
{'|0', '<strong class="error"></strong>'}, -- nbsp
{'|false', '<strong class="error"></strong>'},
{'|tag=tag', '<strong class="error"></strong>'},
{'|1', '<strong class="error"></strong>'},
{'|true', '<strong class="error"></strong>'},
}, {nowiki=1})
end
return p