diff options
Diffstat (limited to 'extensions/ParserFunctions/funcsParserTests.txt')
-rw-r--r-- | extensions/ParserFunctions/funcsParserTests.txt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/extensions/ParserFunctions/funcsParserTests.txt b/extensions/ParserFunctions/funcsParserTests.txt index 2ff7ba3d..06224bad 100644 --- a/extensions/ParserFunctions/funcsParserTests.txt +++ b/extensions/ParserFunctions/funcsParserTests.txt @@ -21,6 +21,18 @@ File:Dionysos-Brunnen am Kölner Dom.jpg blah blah !! endarticle +!! article +File:Redirect_to_Foobar.jpg +!! text +#REDIRECT[[File:Foobar.jpg]] +!! endarticle + +!! article +File:Redirect_to_nowhere.jpg +!! text +#REDIRECT[[File:Missing target file.jpg]] +!! endarticle + !! test Input times are UTC, not local time !! input @@ -127,6 +139,21 @@ Not found !! end !! test +{{#ifexist:}} media redirect (bug 32031) +!! input +{{#ifexist:Media:Redirect_to_Foobar.jpg|Found|Not found}} +{{#ifexist:Media:Redirect_to_nowhere.jpg|Found|Not found}} +{{#ifexist:Media:Missing file.jpg|Found|Not found}} +{{#ifexist:Media:Dionysos-Brunnen am Kölner Dom.jpg|Found|Not found}} +!!result +<p>Found +Not found +Not found +Not found +</p> +!!end + +!! test #if !! input {{#if: | yes | no}} @@ -174,6 +201,23 @@ no !! end !! test +#ifeq entities +!!input +{{#ifeq: {{PAGENAME:*foo&bar}} | *foo&bar | yes | no}} +{{#ifeq: a'b | a'b | yes | no}} +{{#ifeq: a'b | a&#39;b | yes | no}} +{{#ifeq: foo | Foo | *yes | *no}} +!! result +<p>yes +yes +no +</p> +<ul><li>no</li></ul> + +!! end + + +!! test #iferror !!input {{#iferror: {{#expr: 1 + 2 }} | error | correct }} @@ -232,3 +276,47 @@ Templates: Parser functions don't strip whitespace from positional parameters <p>no-pre-then </p> !! end + +!! test +#switch +!! input +{{#switch:foo&bar|foo&bar=yes|no}} +{{#switch:foo&bar|fred=1|foo&bar|g=yes|no}} +{{#switch:foo&bar|fred=1|foo&'bar|g=yes|no}} +{{#switch:foo|bar|baz=no|*default}} +{{#switch:none|foo=1|bar=2|#default=no match|baz=3}} +{{#switch:none|foo=1|bar=2|#default=ignored|baz=3|Second default}} +{{#switch:|a&#39;b}} +!! result +<p>yes +yes +no +</p> +<ul><li>default</li></ul> +<p>no match +Second default +a&#39;b +</p> +!!end + +!! test +#switch #default should match next and not last named parameter +!! input +<{{#switch: foo | #default | bar = DEF }}> +<{{#switch: foo | #default | bar = DEF | baz = GHI }}> +!! result +<p><DEF> +<DEF> +</p> +!! end + +!! test +#switch should not match #default as a prefix +!! input +<{{#switch: foo | #defaultWTF? = This is crazy }}> +<{{#switch: foo | #defaultWTF? | bar = This is crazy }}> +!! result +<p><> +<> +</p> +!! end |