mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-23 15:57:10 +00:00
Update parserTests to v2 (tidy by default)
Bug: T249138 Change-Id: I663c3919e08688354d68ced6945f6eb40265d2ac
This commit is contained in:
parent
d6bb7a91dd
commit
16c50e014e
|
@ -1,8 +1,8 @@
|
|||
!! Version 2
|
||||
# Force the test runner to ensure the extension is loaded
|
||||
# fixme... this doesn't seem to work :D
|
||||
#!! functionhooks
|
||||
#time
|
||||
#!! endfunctionhooks
|
||||
!! functionhooks
|
||||
time
|
||||
!! endfunctionhooks
|
||||
|
||||
# fixme: #time seems to be accepting input as local time, which strikes me as wrong
|
||||
|
||||
|
@ -35,90 +35,90 @@ File:Redirect_to_nowhere.jpg
|
|||
|
||||
!! test
|
||||
Input times are UTC, not local time
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:c|15 January 2001}}
|
||||
!!result
|
||||
!! html
|
||||
<p>2001-01-15T00:00:00+00:00
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Time test in traditional range...
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y|15 January 2001}}
|
||||
!! result
|
||||
!! html
|
||||
<p>2001
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Time test prior to 1970 Unix creation myth
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y|5 April 1967}}
|
||||
!! result
|
||||
!! html
|
||||
<p>1967
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Time test after the 2038 32-bit Apocalype
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y|28 July 2061}}
|
||||
!! result
|
||||
!! html
|
||||
<p>2061
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Explicitly specified timezone: UTC
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }}
|
||||
!! result
|
||||
!! html
|
||||
<p>2011-11-12 23:00
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Explicitly specified timezone: Europe/Paris (UTC+1)
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }}
|
||||
!! result
|
||||
!! html
|
||||
<p>2011-11-12 22:00
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Explicitly specified timezone: America/New_York (UTC-5)
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }}
|
||||
!! result
|
||||
!! html
|
||||
<p>2011-11-13 04:00
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Explicitely specified output language (Dutch)
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#time:d F Y|1988-02-28|nl}}
|
||||
!! result
|
||||
!! html
|
||||
<p>28 februari 1988
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Preserve tags in #switch default value
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#switch:a|b|<div>c</div>}}
|
||||
!! result
|
||||
!! html
|
||||
<div>c</div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Bug 19093: Default values don't fall through in switch
|
||||
!! input
|
||||
!! wikitext
|
||||
<{{#switch: foo | bar | #default = DEF }}>
|
||||
<{{#switch: foo | #default | bar = DEF }}>
|
||||
!! result
|
||||
!! html
|
||||
<p><DEF>
|
||||
<DEF>
|
||||
</p>
|
||||
|
@ -126,11 +126,11 @@ Bug 19093: Default values don't fall through in switch
|
|||
|
||||
!! test
|
||||
{{#ifexist}}
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#ifexist:Media:Foobar.jpg|Found|Not found}}
|
||||
{{#ifexist:ParserFunctions page|Found|Not found}}
|
||||
{{#ifexist:Missing|Found|Not found}}
|
||||
!! result
|
||||
!! html
|
||||
<p>Found
|
||||
Found
|
||||
Not found
|
||||
|
@ -139,12 +139,12 @@ Not found
|
|||
|
||||
!! test
|
||||
{{#ifexist:}} media redirect (bug 32031)
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#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
|
||||
!! html
|
||||
<p>Found
|
||||
Not found
|
||||
Not found
|
||||
|
@ -154,7 +154,7 @@ Not found
|
|||
|
||||
!! test
|
||||
#if
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#if: | yes | no}}
|
||||
{{#if: string | yes | no}}
|
||||
{{#if: | yes | no}}
|
||||
|
@ -168,7 +168,7 @@ Not found
|
|||
{{#if: foo | | no}}(empty)
|
||||
{{#if: {{{1}}} | yes | no}}
|
||||
{{#if: {{{1|}}} | yes | no}}
|
||||
!! result
|
||||
!! html
|
||||
<p>no
|
||||
yes
|
||||
no
|
||||
|
@ -184,13 +184,13 @@ no
|
|||
|
||||
!! test
|
||||
#ifeq
|
||||
!!input
|
||||
!! wikitext
|
||||
{{#ifeq: 01 | 1 | yes | no}}
|
||||
{{#ifeq: 0 | -0 | yes | no}}
|
||||
{{#ifeq: foo | bar | yes | no}}
|
||||
{{#ifeq: foo | Foo | yes | no}}
|
||||
{{#ifeq: "01" | "1" | yes | no}}
|
||||
!! result
|
||||
!! html
|
||||
<p>yes
|
||||
yes
|
||||
no
|
||||
|
@ -201,12 +201,12 @@ no
|
|||
|
||||
!! test
|
||||
#ifeq entities
|
||||
!!input
|
||||
!! wikitext
|
||||
{{#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
|
||||
!! html
|
||||
<p>yes
|
||||
yes
|
||||
no
|
||||
|
@ -217,14 +217,14 @@ no
|
|||
|
||||
!! test
|
||||
#iferror
|
||||
!!input
|
||||
!! wikitext
|
||||
{{#iferror: {{#expr: 1 + 2 }} | error | correct }}
|
||||
{{#iferror: {{#expr: 1 + X }} | error | correct }}
|
||||
{{#iferror: {{#expr: 1 + 2 }} | error }}
|
||||
{{#iferror: {{#expr: 1 + X }} | error }}
|
||||
{{#iferror: {{#expr: 1 + 2 }} }}
|
||||
{{#iferror: {{#expr: 1 + X }} }}empty
|
||||
!! result
|
||||
!! html
|
||||
<p>correct
|
||||
error
|
||||
3
|
||||
|
@ -237,14 +237,14 @@ empty
|
|||
|
||||
!! test
|
||||
#ifexpr
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#ifexpr: | yes | no}}
|
||||
{{#ifexpr: 1 > 0 | yes }}
|
||||
{{#ifexpr: 1 < 0 | yes }}empty
|
||||
{{#ifexpr: 1 > 0 | | no}}empty
|
||||
{{#ifexpr: 1 < 0 | | no}}
|
||||
{{#ifexpr: 1 > 0 }}empty
|
||||
!! result
|
||||
!! html
|
||||
<p>no
|
||||
yes
|
||||
empty
|
||||
|
@ -256,28 +256,28 @@ empty
|
|||
|
||||
!! test
|
||||
Bug 22866: #ifexpr should evaluate "-0" as false
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#ifexpr: (-1)*0 | true | false }}
|
||||
!! result
|
||||
!! html
|
||||
<p>false
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Templates: Parser functions don't strip whitespace from positional parameters
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#if: {{foo}}
|
||||
| no-pre-then
|
||||
| no-pre-else
|
||||
}}
|
||||
!! result
|
||||
!! html
|
||||
<p>no-pre-then
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
#switch
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#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}}
|
||||
|
@ -285,7 +285,7 @@ Templates: Parser functions don't strip whitespace from positional parameters
|
|||
{{#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
|
||||
!! html
|
||||
<p>yes
|
||||
yes
|
||||
no
|
||||
|
@ -299,10 +299,10 @@ a&#39;b
|
|||
|
||||
!! test
|
||||
#switch #default should match next and not last named parameter
|
||||
!! input
|
||||
!! wikitext
|
||||
<{{#switch: foo | #default | bar = DEF }}>
|
||||
<{{#switch: foo | #default | bar = DEF | baz = GHI }}>
|
||||
!! result
|
||||
!! html
|
||||
<p><DEF>
|
||||
<DEF>
|
||||
</p>
|
||||
|
@ -310,10 +310,10 @@ a&#39;b
|
|||
|
||||
!! test
|
||||
#switch should not match #default as a prefix
|
||||
!! input
|
||||
!! wikitext
|
||||
<{{#switch: foo | #defaultWTF? = This is crazy }}>
|
||||
<{{#switch: foo | #defaultWTF? | bar = This is crazy }}>
|
||||
!! result
|
||||
!! html
|
||||
<p><>
|
||||
<>
|
||||
</p>
|
||||
|
@ -321,7 +321,7 @@ a&#39;b
|
|||
|
||||
!! test
|
||||
#switch Test php truthy
|
||||
!!input
|
||||
!! wikitext
|
||||
{{#switch: 01 | 1 = yes | no}}
|
||||
{{#switch: 0 | -0 = yes | no}}
|
||||
{{#switch: foo | bar = yes | no}}
|
||||
|
@ -329,7 +329,7 @@ a&#39;b
|
|||
{{#switch: "01" | "1" = yes | no}}
|
||||
{{#switch: 1 | 02 | 01 = yes | no}}
|
||||
{{#switch: 1 | "01" | "1" = yes | no}}
|
||||
!! result
|
||||
!! html
|
||||
<p>yes
|
||||
yes
|
||||
no
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
# @todo expand
|
||||
!! Version 2
|
||||
# Force the test runner to ensure the extension is loaded
|
||||
# Use '#switch' to do the detection, since we might not have
|
||||
# string functions enabled (yet) -- they are force-enabled on a per-test
|
||||
# basis by the ParserTestGlobals hook.
|
||||
!! functionhooks
|
||||
len
|
||||
switch
|
||||
!! endfunctionhooks
|
||||
|
||||
# @todo expand
|
||||
|
||||
!! test
|
||||
#len
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#len:}}
|
||||
{{#len:0}}
|
||||
{{#len:test}}
|
||||
!!result
|
||||
!! html
|
||||
<p>0
|
||||
1
|
||||
4
|
||||
|
@ -18,12 +24,12 @@ len
|
|||
|
||||
!! test
|
||||
#urldecode
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#urldecode:}}
|
||||
{{#urldecode:foo%20bar}}
|
||||
{{#urldecode:%D0%9C%D0%B5%D0%B4%D0%B8%D0%B0%D0%92%D0%B8%D0%BA%D0%B8}}
|
||||
{{#urldecode: some unescaped string}}
|
||||
!! result
|
||||
!! html
|
||||
<p>foo bar
|
||||
МедиаВики
|
||||
some unescaped string
|
||||
|
@ -32,10 +38,10 @@ some unescaped string
|
|||
|
||||
!! test
|
||||
#pos
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#pos:Žmržlina|žlina}}
|
||||
{{#pos:stringstring|str|4}}
|
||||
!! result
|
||||
!! html
|
||||
<p>3
|
||||
6
|
||||
</p>
|
||||
|
@ -43,8 +49,8 @@ some unescaped string
|
|||
|
||||
!! test
|
||||
#pos with too large offset (T209600)
|
||||
!! input
|
||||
!! wikitext
|
||||
{{#pos:FooBar|Foo|32}}
|
||||
!! result
|
||||
!! html
|
||||
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue