Module:Ustring/testcases: Difference between revisions
Appearance
Content deleted Content added
←Created page with '-- Unit tests for Module:Ustring. Click talk page to run tests. local p = require('Module:UnitTests') -- Test sub function function p:test_sub() self:preprocess_equals('{{#invoke:ustring| sub | hello | 1 | 3 }}', ' he') self:preprocess_equals('{{#invoke:ustring| sub | s1 = hello | 1 | 3 }}', 'hel') end return p' |
Test onerror and sub |
||
Line 4: | Line 4: | ||
-- Test sub function |
-- Test sub function |
||
function p:test_sub() |
function p:test_sub() |
||
self: |
self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', { |
||
{' hello | 1 | 3', ' he'}, |
|||
{' s1 = hello | 1 | 3', 'hel'}, |
|||
{' s1 = hello | 0 | 3', 'hel'}, |
|||
{' s1 = hello | -3 ', 'llo'}, |
|||
{' hello | -3 ', 'lo '}, |
|||
}) |
|||
end |
|||
-- Test error supression |
|||
function p:test_onerror() |
|||
self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', { |
|||
{' hello | 1 | 3 | onerror = foo', ' he'}, |
|||
{' s1 = hello | bar | 3 | onerror = foo', 'foo'}, |
|||
{' s1 = hello | 0 | | onerror = foo', 'foo'}, |
|||
}) |
|||
end |
end |
||
Revision as of 11:30, 14 November 2021
![]() | This is the test cases page for the module Module:Ustring. Results of the test cases. |
-- Unit tests for [[Module:Ustring]]. Click talk page to run tests.
local p = require('Module:UnitTests')
-- Test sub function
function p:test_sub()
self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', {
{' hello | 1 | 3', ' he'},
{' s1 = hello | 1 | 3', 'hel'},
{' s1 = hello | 0 | 3', 'hel'},
{' s1 = hello | -3 ', 'llo'},
{' hello | -3 ', 'lo '},
})
end
-- Test error supression
function p:test_onerror()
self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', {
{' hello | 1 | 3 | onerror = foo', ' he'},
{' s1 = hello | bar | 3 | onerror = foo', 'foo'},
{' s1 = hello | 0 | | onerror = foo', 'foo'},
})
end
return p