| 1 |
!! options |
| 2 |
parsoid-compatible |
| 3 |
version=2 |
| 4 |
!! end |
| 5 |
|
| 6 |
# Force the test runner to ensure the extension is loaded |
| 7 |
!! functionhooks |
| 8 |
invoke |
| 9 |
!! endfunctionhooks |
| 10 |
|
| 11 |
!! article |
| 12 |
Module:Test |
| 13 |
!! text |
| 14 |
local p = {} |
| 15 |
|
| 16 |
local isoTestData = '' |
| 17 |
|
| 18 |
local bit = require('bit') |
| 19 |
|
| 20 |
function p.tooFewArgs() |
| 21 |
require() |
| 22 |
end |
| 23 |
|
| 24 |
function p.getAllArgs( frame ) |
| 25 |
local buf = {} |
| 26 |
local names = {} |
| 27 |
local values = {} |
| 28 |
for name, value in pairs( frame.args ) do |
| 29 |
table.insert(names, name) |
| 30 |
values[name] = value |
| 31 |
end |
| 32 |
table.sort(names, function (a, b) return tostring(a) < tostring(b) end) |
| 33 |
for index, name in ipairs(names) do |
| 34 |
if #buf ~= 0 then |
| 35 |
table.insert( buf, ', ' ) |
| 36 |
end |
| 37 |
table.insert( buf, name .. '=' .. values[name] ) |
| 38 |
end |
| 39 |
return table.concat( buf ) |
| 40 |
end |
| 41 |
|
| 42 |
function p.getAllArgs2( frame ) |
| 43 |
local buf = {} |
| 44 |
local names = {} |
| 45 |
local values = {} |
| 46 |
for name, value in frame:argumentPairs() do |
| 47 |
table.insert(names, name) |
| 48 |
values[name] = value |
| 49 |
end |
| 50 |
table.sort(names, function (a, b) return tostring(a) < tostring(b) end) |
| 51 |
for index, name in ipairs(names) do |
| 52 |
if #buf ~= 0 then |
| 53 |
table.insert( buf, ', ' ) |
| 54 |
end |
| 55 |
table.insert( buf, name .. '=' .. values[name] ) |
| 56 |
end |
| 57 |
return table.concat( buf ) |
| 58 |
end |
| 59 |
|
| 60 |
function p.getNumericArgs( frame ) |
| 61 |
local buf = {} |
| 62 |
for index, value in ipairs(frame.args) do |
| 63 |
if #buf ~= 0 then |
| 64 |
table.insert( buf, ', ' ) |
| 65 |
end |
| 66 |
table.insert( buf, index .. '=' .. value ) |
| 67 |
end |
| 68 |
return table.concat( buf ) |
| 69 |
end |
| 70 |
|
| 71 |
function p.getArg( frame ) |
| 72 |
local name = frame.args[1] |
| 73 |
return frame:getArgument( name ):expand() |
| 74 |
end |
| 75 |
|
| 76 |
function p.getArgLength( frame ) |
| 77 |
local name = frame.args[1] |
| 78 |
return #(frame.args[name]) |
| 79 |
end |
| 80 |
|
| 81 |
function p.getArgType( frame ) |
| 82 |
local name = frame.args[1] |
| 83 |
return type( frame.args[name] ) |
| 84 |
end |
| 85 |
|
| 86 |
function p.hello() |
| 87 |
return 'hello' |
| 88 |
end |
| 89 |
|
| 90 |
function p.emptyTable() |
| 91 |
return {} |
| 92 |
end |
| 93 |
|
| 94 |
function p.import() |
| 95 |
return require('Module:Test2').countBeans() |
| 96 |
end |
| 97 |
|
| 98 |
function p.bitop() |
| 99 |
return bit.bor(1, bit.bor(2, bit.bor(4, 8))) |
| 100 |
end |
| 101 |
|
| 102 |
function p.isolationTestUpvalue( frame ) |
| 103 |
isoTestData = isoTestData .. frame.args[1] |
| 104 |
return isoTestData |
| 105 |
end |
| 106 |
|
| 107 |
function p.isolationTestGlobal( frame ) |
| 108 |
if isoTestDataGlobal == nil then |
| 109 |
isoTestDataGlobal = '' |
| 110 |
end |
| 111 |
isoTestDataGlobal = isoTestDataGlobal .. frame.args[1] |
| 112 |
return isoTestDataGlobal |
| 113 |
end |
| 114 |
|
| 115 |
function p.getParentArgs( frame ) |
| 116 |
return p.getAllArgs( frame:getParent() ) |
| 117 |
end |
| 118 |
|
| 119 |
function p.testExpandTemplate( frame ) |
| 120 |
return frame:expandTemplate{ |
| 121 |
title = 'Scribunto_all_args', |
| 122 |
args = { x = 1, y = 2, z = '|||' } |
| 123 |
} |
| 124 |
end |
| 125 |
|
| 126 |
function p.testExpandTemplateWithHeaders( frame ) |
| 127 |
return frame:expandTemplate{ |
| 128 |
title = 'Scribunto_template_with_headers' |
| 129 |
} |
| 130 |
end |
| 131 |
|
| 132 |
function p.testNewTemplateParserValue( frame ) |
| 133 |
return |
| 134 |
frame:newTemplateParserValue{ |
| 135 |
title = 'Scribunto_all_args', |
| 136 |
args = { x = 1, y = 2, z = 'blah' } |
| 137 |
} : expand() |
| 138 |
end |
| 139 |
|
| 140 |
function p.testPreprocess( frame ) |
| 141 |
return frame:preprocess( '{{Scribunto_all_args|{{{1}}}}}|x=y' ) |
| 142 |
end |
| 143 |
|
| 144 |
function p.testNewParserValue( frame ) |
| 145 |
return frame:newParserValue( '{{Scribunto_all_args|{{{1}}}}}|x=y' ):expand() |
| 146 |
end |
| 147 |
|
| 148 |
function p.null( frame ) |
| 149 |
return '\0' |
| 150 |
end |
| 151 |
|
| 152 |
function p.isSubsting( frame ) |
| 153 |
return tostring( mw.isSubsting() ) |
| 154 |
end |
| 155 |
|
| 156 |
function p.getFrameTitle( frame ) |
| 157 |
return frame:getTitle() |
| 158 |
end |
| 159 |
|
| 160 |
p['test=InFunctionName'] = function( frame ) |
| 161 |
return frame.args[1] |
| 162 |
end |
| 163 |
|
| 164 |
function p.testStrippedCss( frame ) |
| 165 |
return mw.html.create( 'div' ):css( 'color', frame.args[1] ) |
| 166 |
end |
| 167 |
|
| 168 |
function p.testFrameCaching( frame ) |
| 169 |
return string.format( |
| 170 |
'Parent frame is the root: %s. Child frame is the root: %s.', |
| 171 |
frame:getParent():preprocess('<includeonly>no</includeonly><noinclude>yes</noinclude>'), |
| 172 |
frame:preprocess('<includeonly>no</includeonly><noinclude>yes</noinclude>') |
| 173 |
) |
| 174 |
end |
| 175 |
|
| 176 |
function p.testIsRedirect( frame ) |
| 177 |
local name = frame.args[1] |
| 178 |
local title = mw.title.new( name ) |
| 179 |
if title.redirectTarget then |
| 180 |
return string.format( "redirects to %s", title.redirectTarget.prefixedText ) |
| 181 |
else |
| 182 |
return "not a redirect" |
| 183 |
end |
| 184 |
end |
| 185 |
|
| 186 |
return p |
| 187 |
!! endarticle |
| 188 |
|
| 189 |
|
| 190 |
!! article |
| 191 |
Module:Test2 |
| 192 |
!! text |
| 193 |
return { |
| 194 |
countBeans = function () |
| 195 |
return 3 |
| 196 |
end |
| 197 |
} |
| 198 |
!! endarticle |
| 199 |
|
| 200 |
!! article |
| 201 |
Module:Metatables |
| 202 |
!! text |
| 203 |
local p, mt1, mt2 = {}, {}, {} |
| 204 |
|
| 205 |
mt1.__index = {} |
| 206 |
|
| 207 |
function p.zero(frame) |
| 208 |
return 'You called the zero method from p' |
| 209 |
end |
| 210 |
|
| 211 |
function mt1.__index.one(frame) |
| 212 |
return 'You called the one method from mt1' |
| 213 |
end |
| 214 |
|
| 215 |
function mt2.__index(t, k) |
| 216 |
return function(frame) |
| 217 |
return 'You called the ' .. k .. ' method from mt2' |
| 218 |
end |
| 219 |
end |
| 220 |
|
| 221 |
setmetatable(mt1.__index, mt2) |
| 222 |
setmetatable(p, mt1) |
| 223 |
|
| 224 |
return p |
| 225 |
!! endarticle |
| 226 |
|
| 227 |
!! article |
| 228 |
Module:Redirected |
| 229 |
!! text |
| 230 |
return require [[Module:Test]] |
| 231 |
!! endarticle |
| 232 |
|
| 233 |
!! article |
| 234 |
Module:Test "with" quotes |
| 235 |
!! text |
| 236 |
return require [[Module:Test]] |
| 237 |
!! endarticle |
| 238 |
|
| 239 |
!! article |
| 240 |
Module:Redirected "with" quotes |
| 241 |
!! text |
| 242 |
return require [[Module:Test "with" quotes]] |
| 243 |
!! endarticle |
| 244 |
|
| 245 |
!! article |
| 246 |
Template:Scribunto_all_args |
| 247 |
!! text |
| 248 |
{{#invoke:test|getParentArgs}} |
| 249 |
!! endarticle |
| 250 |
|
| 251 |
!! article |
| 252 |
Template:Scribunto_template_with_headers |
| 253 |
!! text |
| 254 |
== bar == |
| 255 |
!! endarticle |
| 256 |
|
| 257 |
!! article |
| 258 |
Template:Scribunto_frame_caching |
| 259 |
!! text |
| 260 |
{{#invoke:test|testFrameCaching}} |
| 261 |
!! endarticle |
| 262 |
|
| 263 |
!! test |
| 264 |
Scribunto: no such module |
| 265 |
!! options |
| 266 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 267 |
cat |
| 268 |
extension=ScribuntoErrors-5e10d413 |
| 269 |
!! wikitext |
| 270 |
{{#invoke:foo|bar}} |
| 271 |
!! metadata |
| 272 |
cat=Pages_with_script_errors sort= |
| 273 |
extension[ScribuntoErrors-5e10d413]="<p>Script error: No such module \"foo\".</p><p>No further details are available.</p>" |
| 274 |
!! html/php |
| 275 |
<p><strong class="error"><span class="scribunto-error mw-scribunto-error-5e10d413">Script error: No such module "foo".</span></strong> |
| 276 |
</p> |
| 277 |
!! html/parsoid |
| 278 |
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:foo","function":"invoke"},"params":{"1":{"wt":"bar"}},"i":0}}]}'><span class="scribunto-error mw-scribunto-error-5e10d413">Script error: No such module <span typeof="mw:Entity">"</span>foo<span typeof="mw:Entity">"</span>.</span></strong></p> |
| 279 |
!! end |
| 280 |
|
| 281 |
!! test |
| 282 |
Scribunto: no such function |
| 283 |
!! options |
| 284 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 285 |
cat |
| 286 |
extension=ScribuntoErrors-d64a22ba |
| 287 |
!! wikitext |
| 288 |
{{#invoke:test|blah}} |
| 289 |
!! metadata |
| 290 |
cat=Pages_with_script_errors sort= |
| 291 |
extension[ScribuntoErrors-d64a22ba]="<p>Script error: The function \"blah\" does not exist.</p><p>No further details are available.</p>" |
| 292 |
!! html/php |
| 293 |
<p><strong class="error"><span class="scribunto-error mw-scribunto-error-d64a22ba">Script error: The function "blah" does not exist.</span></strong> |
| 294 |
</p> |
| 295 |
!! html/parsoid |
| 296 |
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"blah"}},"i":0}}]}'><span class="scribunto-error mw-scribunto-error-d64a22ba">Script error: The function <span typeof="mw:Entity">"</span>blah<span typeof="mw:Entity">"</span> does not exist.</span></strong></p> |
| 297 |
!! end |
| 298 |
|
| 299 |
!! test |
| 300 |
Scribunto: hello world |
| 301 |
!! options |
| 302 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 303 |
!! wikitext |
| 304 |
{{#invoke:test|hello}} |
| 305 |
!! html |
| 306 |
<p>hello |
| 307 |
</p> |
| 308 |
!! end |
| 309 |
|
| 310 |
!! test |
| 311 |
Scribunto: redirect to hello world |
| 312 |
!! options |
| 313 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 314 |
!! wikitext |
| 315 |
{{#invoke:redirected|hello}} |
| 316 |
{{#invoke:redirected "with" quotes|hello}} |
| 317 |
{{#invoke:redirected|testIsRedirect|Module:Redirected}} |
| 318 |
{{#invoke:redirected "with" quotes|testIsRedirect|Module:Test "with" quotes}} |
| 319 |
{{#invoke:redirected "with" quotes|testIsRedirect|Module:Redirected "with" quotes}} |
| 320 |
!! html |
| 321 |
<p>hello |
| 322 |
hello |
| 323 |
redirects to Module:Test |
| 324 |
redirects to Module:Test |
| 325 |
redirects to Module:Test "with" quotes |
| 326 |
</p> |
| 327 |
!! end |
| 328 |
|
| 329 |
!! test |
| 330 |
Scribunto: getAllArgs |
| 331 |
!! options |
| 332 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 333 |
!! wikitext |
| 334 |
{{#invoke:test|getAllArgs|x|y|z|a=1|b=2|c=3|7=?}} |
| 335 |
!! html |
| 336 |
<p>1=x, 2=y, 3=z, 7=?, a=1, b=2, c=3 |
| 337 |
</p> |
| 338 |
!! end |
| 339 |
|
| 340 |
!! test |
| 341 |
Scribunto: getAllArgs, deprecated style |
| 342 |
!! options |
| 343 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 344 |
!! wikitext |
| 345 |
{{#invoke:test|getAllArgs2|x|y|z|a=1|b=2|c=3|7=?}} |
| 346 |
!! html |
| 347 |
<p>1=x, 2=y, 3=z, 7=?, a=1, b=2, c=3 |
| 348 |
</p> |
| 349 |
!! end |
| 350 |
|
| 351 |
!! test |
| 352 |
Scribunto: getNumericArgs |
| 353 |
!! options |
| 354 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 355 |
!! wikitext |
| 356 |
{{#invoke:test|getNumericArgs|x|y|z|a=1|b=2|c=3|7=?}} |
| 357 |
!! html |
| 358 |
<p>1=x, 2=y, 3=z |
| 359 |
</p> |
| 360 |
!! end |
| 361 |
|
| 362 |
!! test |
| 363 |
Scribunto: named numeric parameters |
| 364 |
!! options |
| 365 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 366 |
!! wikitext |
| 367 |
{{#invoke:test|getArg|2|a|2=b}} |
| 368 |
{{#invoke:test|getArg|2|2=a|b}} |
| 369 |
!! html/php |
| 370 |
<p>b |
| 371 |
b |
| 372 |
</p> |
| 373 |
!! html/parsoid |
| 374 |
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArg"},"2":{"wt":"b"},"3":{"wt":"a"}},"i":0}}]}'>b</span> |
| 375 |
<span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArg"},"2":{"wt":"a"},"3":{"wt":"b"}},"i":0}}]}'>b</span></p> |
| 376 |
!! end |
| 377 |
|
| 378 |
!! test |
| 379 |
Scribunto: template-style argument trimming |
| 380 |
!! options |
| 381 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 382 |
!! wikitext |
| 383 |
{{#invoke:test|getArgLength|2| x }} |
| 384 |
{{#invoke:test|getArgLength|2|2= x }} |
| 385 |
!! html/php |
| 386 |
<p>3 |
| 387 |
1 |
| 388 |
</p> |
| 389 |
!! html/parsoid |
| 390 |
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArgLength"},"2":{"wt":"2"},"3":{"wt":" x "}},"i":0}}]}'>3</span> |
| 391 |
<span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"getArgLength"},"2":{"wt":"x"}},"i":0}}]}'>1</span></p> |
| 392 |
!! end |
| 393 |
|
| 394 |
!! test |
| 395 |
Scribunto: missing argument |
| 396 |
!! options |
| 397 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 398 |
!! wikitext |
| 399 |
{{#invoke:test|getArgType|2}} |
| 400 |
{{#invoke:test|getArgType|blah}} |
| 401 |
!! html |
| 402 |
<p>nil |
| 403 |
nil |
| 404 |
</p> |
| 405 |
!! end |
| 406 |
|
| 407 |
!! test |
| 408 |
Scribunto: parent frame access |
| 409 |
!! options |
| 410 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 411 |
!! wikitext |
| 412 |
{{Scribunto_all_args|x|y|z|a = 1|b = 2|c = 3}} |
| 413 |
!! html |
| 414 |
<p>1=x, 2=y, 3=z, a=1, b=2, c=3 |
| 415 |
</p> |
| 416 |
!! end |
| 417 |
|
| 418 |
!! test |
| 419 |
Scribunto: expandTemplate |
| 420 |
!! options |
| 421 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 422 |
!! wikitext |
| 423 |
{{#invoke:test|testExpandTemplate}} |
| 424 |
!! html |
| 425 |
<p>x=1, y=2, z=||| |
| 426 |
</p> |
| 427 |
!! end |
| 428 |
|
| 429 |
!! test |
| 430 |
Scribunto: expandTemplate with headers |
| 431 |
!! options |
| 432 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 433 |
!! config |
| 434 |
wgParserEnableLegacyHeadingDOM=false |
| 435 |
!! wikitext |
| 436 |
==foo== |
| 437 |
{{#invoke:test|testExpandTemplateWithHeaders}} |
| 438 |
!! html/php |
| 439 |
<div class="mw-heading mw-heading2"><h2 id="foo">foo</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo">edit</a><span class="mw-editsection-bracket">]</span></span></div> |
| 440 |
<div class="mw-heading mw-heading2"><h2 id="bar">bar</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Scribunto_template_with_headers&action=edit&section=T-1" title="Edit section: bar">edit</a><span class="mw-editsection-bracket">]</span></span></div> |
| 441 |
!! html/parsoid |
| 442 |
<h2 id="foo">foo</h2> |
| 443 |
<h2 typeof="mw:Transclusion" id="bar" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"testExpandTemplateWithHeaders"}},"i":0}}]}'>bar</h2> |
| 444 |
!! end |
| 445 |
|
| 446 |
!! test |
| 447 |
Scribunto: newTemplateParserValue |
| 448 |
!! options |
| 449 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 450 |
!! wikitext |
| 451 |
{{#invoke:test|testNewTemplateParserValue}} |
| 452 |
!! html |
| 453 |
<p>x=1, y=2, z=blah |
| 454 |
</p> |
| 455 |
!! end |
| 456 |
|
| 457 |
!! test |
| 458 |
Scribunto: preprocess |
| 459 |
!! options |
| 460 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 461 |
!! wikitext |
| 462 |
{{#invoke:test|testPreprocess|foo}} |
| 463 |
!! html |
| 464 |
<p>1=foo|x=y |
| 465 |
</p> |
| 466 |
!! end |
| 467 |
|
| 468 |
!! test |
| 469 |
Scribunto: newParserValue |
| 470 |
!! options |
| 471 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 472 |
!! wikitext |
| 473 |
{{#invoke:test|testNewParserValue|foo}} |
| 474 |
!! html |
| 475 |
<p>1=foo|x=y |
| 476 |
</p> |
| 477 |
!! end |
| 478 |
|
| 479 |
!! test |
| 480 |
Scribunto: table return |
| 481 |
!! options |
| 482 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 483 |
!! wikitext |
| 484 |
{{#invoke:test|emptyTable}} |
| 485 |
!! html |
| 486 |
<p>table |
| 487 |
</p> |
| 488 |
!! end |
| 489 |
|
| 490 |
!! test |
| 491 |
Scribunto: require |
| 492 |
!! options |
| 493 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 494 |
!! wikitext |
| 495 |
{{#invoke:test|import}} |
| 496 |
!! html |
| 497 |
<p>3 |
| 498 |
</p> |
| 499 |
!! end |
| 500 |
|
| 501 |
!! test |
| 502 |
Scribunto: access to a module imported at the chunk level |
| 503 |
!! options |
| 504 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 505 |
!! wikitext |
| 506 |
{{#invoke:test|bitop}} |
| 507 |
!! html |
| 508 |
<p>15 |
| 509 |
</p> |
| 510 |
!! end |
| 511 |
|
| 512 |
!! test |
| 513 |
Scribunto: invoke instance upvalue isolation |
| 514 |
!! options |
| 515 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 516 |
!! wikitext |
| 517 |
{{#invoke:test|isolationTestUpvalue|1}} |
| 518 |
{{#invoke:test|isolationTestUpvalue|2}} |
| 519 |
{{#invoke:test|isolationTestUpvalue|3}} |
| 520 |
!! html |
| 521 |
<p>1 |
| 522 |
2 |
| 523 |
3 |
| 524 |
</p> |
| 525 |
!! end |
| 526 |
|
| 527 |
!! test |
| 528 |
Scribunto: invoke instance global isolation |
| 529 |
!! options |
| 530 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 531 |
!! wikitext |
| 532 |
{{#invoke:test|isolationTestGlobal|1}} |
| 533 |
{{#invoke:test|isolationTestGlobal|2}} |
| 534 |
{{#invoke:test|isolationTestGlobal|3}} |
| 535 |
!! html |
| 536 |
<p>1 |
| 537 |
2 |
| 538 |
3 |
| 539 |
</p> |
| 540 |
!! end |
| 541 |
|
| 542 |
!! test |
| 543 |
Scribunto: ASCII null |
| 544 |
!! options |
| 545 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 546 |
!! wikitext |
| 547 |
{{#invoke:test|null}} |
| 548 |
!! html |
| 549 |
<p>� |
| 550 |
</p> |
| 551 |
!! end |
| 552 |
|
| 553 |
!! test |
| 554 |
Scribunto: isSubsting during PST |
| 555 |
!! options |
| 556 |
pst |
| 557 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 558 |
!! wikitext |
| 559 |
{{safesubst:#invoke:test|isSubsting}} |
| 560 |
!! html |
| 561 |
true |
| 562 |
!! end |
| 563 |
|
| 564 |
!! test |
| 565 |
Scribunto: isSubsting during normal parse |
| 566 |
!! options |
| 567 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 568 |
!! wikitext |
| 569 |
{{safesubst:#invoke:test|isSubsting}} |
| 570 |
!! html |
| 571 |
<p>false |
| 572 |
</p> |
| 573 |
!! end |
| 574 |
|
| 575 |
!! test |
| 576 |
Scribunto: frame:getTitle |
| 577 |
!! options |
| 578 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 579 |
!! wikitext |
| 580 |
{{#invoke:test|getFrameTitle}} |
| 581 |
!! html |
| 582 |
<p>Module:Test |
| 583 |
</p> |
| 584 |
!! end |
| 585 |
|
| 586 |
!! test |
| 587 |
Scribunto: Metatable on export table |
| 588 |
!! options |
| 589 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 590 |
!! wikitext |
| 591 |
{{#invoke:Metatables|zero}} |
| 592 |
{{#invoke:Metatables|one}} |
| 593 |
{{#invoke:Metatables|two}} |
| 594 |
!! html |
| 595 |
<p>You called the zero method from p |
| 596 |
You called the one method from mt1 |
| 597 |
You called the two method from mt2 |
| 598 |
</p> |
| 599 |
!! end |
| 600 |
|
| 601 |
!! test |
| 602 |
Scribunto: Correct argument numbering with equals sign in function name |
| 603 |
!! options |
| 604 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 605 |
!! wikitext |
| 606 |
{{#invoke:test|test=InFunctionName|good|bad}} |
| 607 |
!! html |
| 608 |
<p>good |
| 609 |
</p> |
| 610 |
!! end |
| 611 |
|
| 612 |
!! test |
| 613 |
Scribunto: Strip markers in CSS |
| 614 |
!! options |
| 615 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 616 |
!! wikitext |
| 617 |
{{#invoke:test|testStrippedCss|<nowiki>#ff0000</nowiki>}} |
| 618 |
!! html |
| 619 |
<div style="color:#ff0000"></div> |
| 620 |
!! end |
| 621 |
|
| 622 |
!! test |
| 623 |
Scribunto: Parser output isn't incorrectly cached across frames |
| 624 |
!! options |
| 625 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 626 |
!! wikitext |
| 627 |
Root: {{#invoke:test|testFrameCaching}} Template: {{Scribunto frame caching}} |
| 628 |
!! html |
| 629 |
<p>Root: Parent frame is the root: yes. Child frame is the root: no. Template: Parent frame is the root: no. Child frame is the root: no. |
| 630 |
</p> |
| 631 |
!! end |
| 632 |
|
| 633 |
# Tests for T272507 |
| 634 |
!! article |
| 635 |
Module:EchoTest |
| 636 |
!! text |
| 637 |
local p = {} |
| 638 |
function p.echo(frame) |
| 639 |
return frame.args[1] |
| 640 |
end |
| 641 |
return p |
| 642 |
!! end |
| 643 |
|
| 644 |
!! article |
| 645 |
Module:UnstripTest |
| 646 |
!! text |
| 647 |
local p = {} |
| 648 |
function p.unstrip(frame) |
| 649 |
return mw.text.nowiki(mw.text.unstripNoWiki(frame.args[1])) |
| 650 |
end |
| 651 |
return p |
| 652 |
!! end |
| 653 |
|
| 654 |
!! test |
| 655 |
Scribunto: Test unstripNowiki behavior |
| 656 |
!! options |
| 657 |
parsoid={ "modes": ["wt2html","wt2wt"] } |
| 658 |
!! wikitext |
| 659 |
{{#invoke:EchoTest|echo|<nowiki>foo</nowiki>}} |
| 660 |
{{#invoke:EchoTest|echo|<nowiki>[[Foo]]</nowiki>}} |
| 661 |
|
| 662 |
{{#invoke:UnstripTest|unstrip|<nowiki>foo</nowiki>}} |
| 663 |
{{#invoke:UnstripTest|unstrip|<nowiki>[[Foo]]</nowiki>}} |
| 664 |
!! html/php |
| 665 |
<p>foo |
| 666 |
[[Foo]] |
| 667 |
</p><p>foo |
| 668 |
[[Foo]] |
| 669 |
</p> |
| 670 |
!! html/parsoid |
| 671 |
<p><span typeof="mw:Nowiki mw:Transclusion" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:EchoTest","function":"invoke"},"params":{"1":{"wt":"echo"},"2":{"wt":"<nowiki>foo</nowiki>"}},"i":0}}]}'>foo</span> |
| 672 |
<span typeof="mw:Nowiki mw:Transclusion" about="#mwt6" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:EchoTest","function":"invoke"},"params":{"1":{"wt":"echo"},"2":{"wt":"<nowiki>[[Foo]]</nowiki>"}},"i":0}}]}'>[[Foo]]</span></p> |
| 673 |
|
| 674 |
<p><span about="#mwt10" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:UnstripTest","function":"invoke"},"params":{"1":{"wt":"unstrip"},"2":{"wt":"<nowiki>foo</nowiki>"}},"i":0}}]}'>foo</span> |
| 675 |
<span typeof="mw:Transclusion mw:Entity" about="#mwt12" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:UnstripTest","function":"invoke"},"params":{"1":{"wt":"unstrip"},"2":{"wt":"<nowiki>[[Foo]]</nowiki>"}},"i":0}}]}'>[</span><span typeof="mw:Entity" about="#mwt12">[</span><span about="#mwt12">Foo</span><span typeof="mw:Entity" about="#mwt12">]</span><span typeof="mw:Entity" about="#mwt12">]</span></p> |
| 676 |
!! end |