Jump to content

Module:String2/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 22: Line 22:
end
end


function p:test_sentence()
--[[ function p:test_sentence()
self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain falls <nowiki>mainly</nowiki> on THE PLANE.}}',
self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain falls <nowiki>mainly</nowiki> on THE PLANE.}}',
'The rain in spain falls <nowiki>mainly</nowiki> on the plane.',
'The rain in spain falls <nowiki>mainly</nowiki> on the plane.',
Line 28: Line 28:
self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain <ref>falls</ref> mainly on THE PLANE.}}',
self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain <ref>falls</ref> mainly on THE PLANE.}}',
'The rain in spain <ref>falls</ref> mainly on the plane.', { stripmarker = true })
'The rain in spain <ref>falls</ref> mainly on the plane.', { stripmarker = true })
end
end ]]--


return p
return p

Revision as of 17:21, 12 May 2022

-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_ucfirst()
	self:preprocess_equals_sandbox_many('{{#invoke:String2', 'ucfirst', {
        {'*test', '\n*Test'},
        {'[[test]]', '[[Test]]'},
        {'[[test|pipetest]]', '[[test|Pipetest]]'},
        {'32nd', '32nd'},
        {'3 &times;', '3 &times;'},
        {'<li>test</li>', '<li>Test</li>'},
        {'1900 &ndash; 2000', '1900 &ndash; 2000'},
    })
end

function p:test_matchAny()
    self:preprocess_equals_sandbox_many('{{#invoke:String2','matchAny', {
    	{'123|abc|source=adc 123', '1'},
    	{'123|abc|source=adc 124', ''},
    	{'123|abc|source=abc 124', '2'},
     },{nowiki=1})
end

--[[ function p:test_sentence()
	self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain falls <nowiki>mainly</nowiki> on THE PLANE.}}',
		'The rain in spain falls <nowiki>mainly</nowiki> on the plane.',
		{ stripmarker = true })
	self:preprocess_equals_preprocess('{{#invoke:String2|sentence|ThE RaIN In Spain <ref>falls</ref> mainly on THE PLANE.}}',
		'The rain in spain <ref>falls</ref> mainly on the plane.', { stripmarker = true })
end ]]--

return p