Module:Phab.T151715:string.gsub.Test
La documentation pour ce module peut être créée à Module:Phab.T151715:string.gsub.Test/Documentation
-- Module:T151715:string.gsub.Test to test bug {{phab:T151715}}
-- t = t .. one_task(short, "T151715", 0, "Open", 'string.gsub( s, "%%1", repl) fails as "invalid capture index"', 'string.gsub(s,"%%1",r) fails')
local p = {}
function p.initS9(text, v1, v2, v3, v4)
-- To debug T151715, 'string.gsub( s, "%%1", repl) fails as "invalid capture index"'
if type(text) ~= "string" then text = " " end
text = string.gsub(text, "%%4", (v4 or "*") )
text = string.gsub(text, "%%3", (v3 or "*") )
text = string.gsub(text, "%%2", (v2 or "*") )
local j = string.find(text, "%", 1, true)
local k = string.find(text, "1", 1, true)
if j and k and ( j + 1 == k ) then text = string.sub(text, 1, j-1) .. v1 .. string.sub(text, k+1, -1) end
return text
end -- function p.initS9(text, v1, v2, v3, v4, v5, v6, v7, v8, v9)
function p.test(frame)
local t = "Module:T151715:string.gsub.Test to test bug {{phab:T151715}}"
-- %2 %3 %4 without error
t = t .. "\n* %2 normal : " .. string.gsub( "ab %2 cd", "%%2", " 2 " )
-- %1 WITH ERROR
t = t .. "\n* %1 ERROR? : " .. string.gsub( "ab %1 cd", "%%1", " 1 " )
-- %1 WITH ERROR
t = t .. "\n* %1 ERROR? : " .. string.gsub( "ab %1 cd", "%%1", " 1 " , " 2 " )
-- %1 %2 %3 %4 with debug
t = t .. "\n* %1 debug in p.initS9() : " .. p.initS9( "ab %1 cd %2 ef %3 cd %4 ef", " 1 " , " 2 ", " 3 ", " 4 " )
t = t .. '\n* Test but no fails ? probably a missing "rep = nil" somewhere in Module:Central '
return t
end -- function p.tests(frame)
return p