Content deleted Content added
fix |
Add tests for sentence |
||
Line 2:
local p = require('Module:UnitTests')
function p:preprocess_equal_stripmarkers(test, expected)
local frame = mw.getCurrentFrame()
test = frame:preprocess(test ):gsub('(\127\'"`UNIQ%-%-[a-z]+%-)[0-9A-Fa-f]+(%-QINU`"\'\127)', '%100000000%2')
expected = frame:preprocess(expected):gsub('(\127\'"`UNIQ%-%-[a-z]+%-)[0-9A-Fa-f]+(%-QINU`"\'\127)', '%100000000%2')
return self:equals(test, expected)
end
function p:test_matchAny()
self:preprocess_equals('{{#invoke:String2|matchAny|123|abc|source=adc 123}}', '1')
Line 8 ⟶ 14:
self:preprocess_equals('{{#invoke:String2|matchAny|123|abc|source=abc 124}}', '2')
self:preprocess_equals('{{#invoke:String2|matchAny|12[3-6]|a[b-e]c|source=adc 129|plain=false}}', '2')
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
|