summaryrefslogtreecommitdiff
path: root/extensions/ParserFunctions/funcsParserTests.txt
blob: ef2c1f3875c9f47f9d7b1dc50d4f60699ef792be (plain)
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
# 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

!! 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

!! test
Input times should probably be UTC, not local time
!! 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

!! test
Bug 19093: Default values don't fall through in switch
!! input
<{{#switch: foo | bar | #default = DEF }}>
<{{#switch: foo | #default | bar = DEF }}>
!! result
<p>&lt;DEF&gt;
&lt;DEF&gt;
</p>
!! end

!! test
{{#ifexist}}
!! input
{{#ifexist:Media:Foobar.jpg|Found|Not found}}
{{#ifexist:ParserFunctions page|Found|Not found}}
{{#ifexist:Missing|Found|Not found}}
!! result
<p>Found
Found
Not found
</p>
!! end

!! 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

!! test
Bug 22866: #ifexpr should evaluate "-0" as false
!! input
{{#ifexpr: (-1)*0 | true | false }}
!! result
<p>false
</p>
!! end