2008-10-27 17:56:58 +00:00
|
|
|
# Force the test runner to ensure the extension is loaded
|
|
|
|
# fixme... this doesn't seem to work :D
|
|
|
|
#!! functionhooks
|
|
|
|
#time
|
|
|
|
#!! endfunctionhooks
|
|
|
|
|
|
|
|
# fixme: #time seems to be accepting input as local time, which strikes me as wrong
|
|
|
|
|
2010-02-13 15:49:05 +00:00
|
|
|
!! article
|
2010-02-15 14:45:33 +00:00
|
|
|
ParserFunctions page
|
2010-02-13 15:49:05 +00:00
|
|
|
!! text
|
2010-02-15 14:45:33 +00:00
|
|
|
A sample page so we can test ifexist.
|
|
|
|
|
|
|
|
This used to be a Main Page, but that caused duplicate article
|
|
|
|
warnings when running the normal tests at the same time.
|
2010-02-13 15:49:05 +00:00
|
|
|
!! endarticle
|
|
|
|
|
2010-02-13 15:08:25 +00:00
|
|
|
!! article
|
|
|
|
File:Dionysos-Brunnen am Kölner Dom.jpg
|
|
|
|
!! text
|
|
|
|
blah blah
|
|
|
|
!! endarticle
|
|
|
|
|
2008-10-27 17:56:58 +00:00
|
|
|
!! test
|
2011-12-07 20:52:41 +00:00
|
|
|
Input times are UTC, not local time
|
2008-10-27 17:56:58 +00:00
|
|
|
!! input
|
|
|
|
{{#time:c|15 January 2001}}
|
|
|
|
!!result
|
|
|
|
<p>2001-01-15T00:00:00+00:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test in traditional range...
|
|
|
|
!! input
|
|
|
|
{{#time:Y|15 January 2001}}
|
|
|
|
!! result
|
|
|
|
<p>2001
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test prior to 1970 Unix creation myth
|
|
|
|
!! input
|
|
|
|
{{#time:Y|5 April 1967}}
|
|
|
|
!! result
|
|
|
|
<p>1967
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Time test after the 2038 32-bit Apocalype
|
|
|
|
!! input
|
|
|
|
{{#time:Y|28 July 2061}}
|
|
|
|
!! result
|
|
|
|
<p>2061
|
|
|
|
</p>
|
|
|
|
!! end
|
2009-06-05 16:53:59 +00:00
|
|
|
|
2011-12-07 20:52:41 +00:00
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: UTC
|
|
|
|
!! input
|
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }}
|
|
|
|
!! result
|
|
|
|
<p>2011-11-12 23:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: Europe/Paris (UTC+1)
|
|
|
|
!! input
|
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }}
|
|
|
|
!! result
|
|
|
|
<p>2011-11-12 22:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
Explicitly specified timezone: America/New_York (UTC-5)
|
|
|
|
!! input
|
|
|
|
{{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }}
|
|
|
|
!! result
|
|
|
|
<p>2011-11-13 04:00
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2011-12-21 21:59:38 +00:00
|
|
|
!! test
|
|
|
|
Explicitely specified output language (Dutch)
|
|
|
|
!! input
|
|
|
|
{{#time:d F Y|1988-02-28|nl}}
|
|
|
|
!! result
|
|
|
|
<p>28 februari 1988
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2009-06-05 16:53:59 +00:00
|
|
|
!! test
|
|
|
|
Bug 19093: Default values don't fall through in switch
|
|
|
|
!! input
|
|
|
|
<{{#switch: foo | bar | #default = DEF }}>
|
|
|
|
<{{#switch: foo | #default | bar = DEF }}>
|
|
|
|
!! result
|
|
|
|
<p><DEF>
|
|
|
|
<DEF>
|
|
|
|
</p>
|
|
|
|
!! end
|
2010-02-13 15:08:25 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
{{#ifexist}}
|
|
|
|
!! input
|
|
|
|
{{#ifexist:Media:Foobar.jpg|Found|Not found}}
|
2010-02-15 14:45:33 +00:00
|
|
|
{{#ifexist:ParserFunctions page|Found|Not found}}
|
2010-02-13 15:08:25 +00:00
|
|
|
{{#ifexist:Missing|Found|Not found}}
|
|
|
|
!! result
|
|
|
|
<p>Found
|
|
|
|
Found
|
|
|
|
Not found
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
2010-02-13 15:49:05 +00:00
|
|
|
!! test
|
|
|
|
#if
|
|
|
|
!! input
|
|
|
|
{{#if: | yes | no}}
|
|
|
|
{{#if: string | yes | no}}
|
|
|
|
{{#if: | yes | no}}
|
|
|
|
{{#if:
|
|
|
|
|
|
|
|
|
|
|
|
| yes | no}}
|
|
|
|
{{#if: 1==2 | yes | no}}
|
|
|
|
{{#if: foo | yes }}
|
|
|
|
{{#if: | yes }}(empty)
|
|
|
|
{{#if: foo | | no}}(empty)
|
|
|
|
{{#if: {{{1}}} | yes | no}}
|
|
|
|
{{#if: {{{1|}}} | yes | no}}
|
|
|
|
!! result
|
|
|
|
<p>no
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
no
|
|
|
|
yes
|
|
|
|
yes
|
|
|
|
(empty)
|
|
|
|
(empty)
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#ifeq
|
|
|
|
!!input
|
|
|
|
{{#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
|
|
|
|
<p>yes
|
|
|
|
yes
|
|
|
|
no
|
|
|
|
no
|
|
|
|
no
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#iferror
|
|
|
|
!!input
|
|
|
|
{{#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
|
|
|
|
<p>correct
|
|
|
|
error
|
|
|
|
3
|
|
|
|
error
|
|
|
|
3
|
|
|
|
empty
|
|
|
|
</p>
|
|
|
|
!! end
|
|
|
|
|
|
|
|
|
|
|
|
!! test
|
|
|
|
#ifexpr
|
|
|
|
!! input
|
|
|
|
{{#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
|
|
|
|
<p>no
|
|
|
|
yes
|
|
|
|
empty
|
|
|
|
empty
|
|
|
|
no
|
|
|
|
empty
|
|
|
|
</p>
|
|
|
|
!! end
|
2010-03-18 16:31:51 +00:00
|
|
|
|
|
|
|
!! test
|
|
|
|
Bug 22866: #ifexpr should evaluate "-0" as false
|
|
|
|
!! input
|
|
|
|
{{#ifexpr: (-1)*0 | true | false }}
|
|
|
|
!! result
|
|
|
|
<p>false
|
|
|
|
</p>
|
|
|
|
!! end
|