1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
|
!! Version 2
# Force the test runner to ensure the extension is loaded
!! functionhooks
time
!! endfunctionhooks
# fixme: #time seems to be accepting input as local time, which strikes me as wrong
!! article
ParserFunctions page
!! text
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.
!! endarticle
!! article
File:Dionysos-Brunnen am Kölner Dom.jpg
!! text
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
!! wikitext
{{#time:c|15 January 2001}}
!! html
<p>2001-01-15T00:00:00+00:00
</p>
!! end
!! test
Time test in traditional range...
!! wikitext
{{#time:Y|15 January 2001}}
!! html
<p>2001
</p>
!! end
!! test
Time test prior to 1970 Unix creation myth
!! wikitext
{{#time:Y|5 April 1967}}
!! html
<p>1967
</p>
!! end
!! test
Time test after the 2038 32-bit Apocalype
!! wikitext
{{#time:Y|28 July 2061}}
!! html
<p>2061
</p>
!! end
!! test
Explicitly specified timezone: UTC
!! wikitext
{{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }}
!! html
<p>2011-11-12 23:00
</p>
!! end
!! test
Explicitly specified timezone: Europe/Paris (UTC+1)
!! wikitext
{{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }}
!! html
<p>2011-11-12 22:00
</p>
!! end
!! test
Explicitly specified timezone: America/New_York (UTC-5)
!! wikitext
{{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }}
!! html
<p>2011-11-13 04:00
</p>
!! end
!! test
Explicitely specified output language (Dutch)
!! wikitext
{{#time:d F Y|1988-02-28|nl}}
!! html
<p>28 februari 1988
</p>
!! end
!! test
Preserve tags in #switch default value
!! wikitext
{{#switch:a|b|<div>c</div>}}
!! html
<div>c</div>
!! end
!! test
Bug 19093: Default values don't fall through in switch
!! wikitext
<{{#switch: foo | bar | #default = DEF }}>
<{{#switch: foo | #default | bar = DEF }}>
!! html
<p><DEF>
<DEF>
</p>
!! end
!! test
{{#ifexist}}
!! wikitext
{{#ifexist:Media:Foobar.jpg|Found|Not found}}
{{#ifexist:ParserFunctions page|Found|Not found}}
{{#ifexist:Missing|Found|Not found}}
!! html
<p>Found
Found
Not found
</p>
!! end
!! test
{{#ifexist:}} media redirect (bug 32031)
!! 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}}
!! html
<p>Found
Not found
Not found
Not found
</p>
!!end
!! test
#if
!! wikitext
{{#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}}
!! html
<p>no
yes
no
no
yes
yes
(empty)
(empty)
yes
no
</p>
!! end
!! test
#ifeq
!! 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}}
!! html
<p>yes
yes
no
no
no
</p>
!! end
!! test
#ifeq entities
!! 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}}
!! html
<p>yes
yes
no
</p>
<ul><li>no</li></ul>
!! end
!! test
#iferror
!! 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
!! html
<p>correct
error
3
error
3
empty
</p>
!! end
!! test
#ifexpr
!! 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
!! html
<p>no
yes
empty
empty
no
empty
</p>
!! end
!! test
Bug 22866: #ifexpr should evaluate "-0" as false
!! wikitext
{{#ifexpr: (-1)*0 | true | false }}
!! html
<p>false
</p>
!! end
!! test
Templates: Parser functions don't strip whitespace from positional parameters
!! wikitext
{{#if: {{foo}}
| no-pre-then
| no-pre-else
}}
!! html
<p>no-pre-then
</p>
!! end
!! test
#switch
!! 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}}
{{#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}}
!! html
<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
!! wikitext
<{{#switch: foo | #default | bar = DEF }}>
<{{#switch: foo | #default | bar = DEF | baz = GHI }}>
!! html
<p><DEF>
<DEF>
</p>
!! end
!! test
#switch should not match #default as a prefix
!! wikitext
<{{#switch: foo | #defaultWTF? = This is crazy }}>
<{{#switch: foo | #defaultWTF? | bar = This is crazy }}>
!! html
<p><>
<>
</p>
!! end
!! test
#switch Test php truthy
!! wikitext
{{#switch: 01 | 1 = yes | no}}
{{#switch: 0 | -0 = yes | no}}
{{#switch: foo | bar = yes | no}}
{{#switch: foo | Foo = yes | no}}
{{#switch: "01" | "1" = yes | no}}
{{#switch: 1 | 02 | 01 = yes | no}}
{{#switch: 1 | "01" | "1" = yes | no}}
!! html
<p>yes
yes
no
no
no
yes
no
</p>
!! end
|