Index: trunk/extensions/NaturalLanguageList/nllParserTests.txt |
— | — | @@ -53,8 +53,98 @@ |
54 | 54 | !! end |
55 | 55 | |
56 | 56 | !! test |
| 57 | +Blanks not allowed |
| 58 | +!! input |
| 59 | +{{#list:1||3| |4| |5|}} |
| 60 | +!! result |
| 61 | +<p>1, 3, 4 and 5 |
| 62 | +</p> |
| 63 | +!! end |
| 64 | + |
| 65 | +!! test |
| 66 | +Blanks allowed |
| 67 | +!! input |
| 68 | +{{#list:blanks=true|1||3| |4| |5|}} |
| 69 | +!! result |
| 70 | +<p>1, , 3, , 4, , 5 and |
| 71 | +</p> |
| 72 | +!! end |
| 73 | + |
| 74 | +!! test |
| 75 | +Blanks allowed, but no duplicates |
| 76 | +!! input |
| 77 | +{{#list:blanks=true|duplicates=false|1||3| |4| |5|}} |
| 78 | +!! result |
| 79 | +<p>1, , 3, 4 and 5 |
| 80 | +</p> |
| 81 | +!! end |
| 82 | + |
| 83 | +!! test |
| 84 | +Output separator, basic with spaces |
| 85 | +!! input |
| 86 | +{{#list:separator= @ |1|2|3|4}} |
| 87 | +!! result |
| 88 | +<p>1 @ 2 @ 3 @ 4 |
| 89 | +</p> |
| 90 | +!! end |
| 91 | + |
| 92 | +!! test |
| 93 | +Output separator, basic without spaces |
| 94 | +!! input |
| 95 | +{{#list:separator=X|1|2|3|4}} |
| 96 | +!! result |
| 97 | +<p>1X2X3X4 |
| 98 | +</p> |
| 99 | +!! end |
| 100 | + |
| 101 | +!! test |
| 102 | +Output separator, together with rawlist |
| 103 | +!! input |
| 104 | +{{#rawlist:X|{{#list:separator=X|1|2|3|4}}}} |
| 105 | +!! result |
| 106 | +<p>1, 2, 3 and 4 |
| 107 | +</p> |
| 108 | +!! end |
| 109 | + |
| 110 | +!! test |
| 111 | +Output separator with different last separator |
| 112 | +!! input |
| 113 | +{{#list:separator=@ |lastseparator= or |1|2|3|4}} |
| 114 | +!! result |
| 115 | +<p>1@ 2@ 3 or 4 |
| 116 | +</p> |
| 117 | +!! end |
| 118 | + |
| 119 | +!! test |
| 120 | +Only last separator |
| 121 | +!! input |
| 122 | +{{#list:lastseparator= or |1|2|3|4}} |
| 123 | +!! result |
| 124 | +<p>1, 2, 3 or 4 |
| 125 | +</p> |
| 126 | +!! end |
| 127 | + |
| 128 | +!! test |
| 129 | +Sophisticated separator input |
| 130 | +!! input |
| 131 | +{{#list:lastseparator=<span class="serial-comma">,</span> <span class="serial-and">and</span> |1|2|3|4}} |
| 132 | +!! result |
| 133 | +<p>1, 2, 3<span class="serial-comma">,</span> <span class="serial-and">and</span> 4 |
| 134 | +</p> |
| 135 | +!! end |
| 136 | + |
| 137 | +!! test |
57 | 138 | Basic format |
58 | 139 | !! input |
| 140 | +{{#list:format='''$1'''|1|2|3|4}} |
| 141 | +!! result |
| 142 | +<p><b>1</b>, <b>2</b>, <b>3</b> and <b>4</b> |
| 143 | +</p> |
| 144 | +!! end |
| 145 | + |
| 146 | +!! test |
| 147 | +Basic format with link |
| 148 | +!! input |
59 | 149 | {{#list:format=[[$1]]|Main page}} |
60 | 150 | !! result |
61 | 151 | <p><a href="https://www.mediawiki.org/index.php?title=Main_page&action=edit&redlink=1" class="new" title="Main page (page does not exist)">Main page</a> |
— | — | @@ -62,6 +152,15 @@ |
63 | 153 | !! end |
64 | 154 | |
65 | 155 | !! test |
| 156 | +Set fieldsperitem |
| 157 | +!! input |
| 158 | +{{#list:fieldsperitem=2|1|2|3|4}} |
| 159 | +!! result |
| 160 | +<p>1 and 3 |
| 161 | +</p> |
| 162 | +!! end |
| 163 | + |
| 164 | +!! test |
66 | 165 | Calculate fieldsperitem |
67 | 166 | !! input |
68 | 167 | {{#list:format='''$1'''<sup>$2</sup>|hi|world|world|hi}} |
— | — | @@ -69,3 +168,93 @@ |
70 | 169 | <p><b>hi</b><sup>world</sup> and <b>world</b><sup>hi</sup> |
71 | 170 | </p> |
72 | 171 | !! end |
| 172 | + |
| 173 | +!! test |
| 174 | +Calculate fieldsperitem; 3 |
| 175 | +!! input |
| 176 | +{{#list:format='''$1'''<sup>$2+$3</sup>|1|2|3|4|5|6}} |
| 177 | +!! result |
| 178 | +<p><b>1</b><sup>2+3</sup> and <b>4</b><sup>5+6</sup> |
| 179 | +</p> |
| 180 | +!! end |
| 181 | + |
| 182 | +!! test |
| 183 | +Overwritted calculated fieldsperitem input upward |
| 184 | +!! input |
| 185 | +{{#list:format=$1<sup>$2</sup>|fieldsperitem=3|1|2|3|4|5|6}} |
| 186 | +!! result |
| 187 | +<p>1<sup>2</sup> and 4<sup>5</sup> |
| 188 | +</p> |
| 189 | +!! end |
| 190 | + |
| 191 | +!! test |
| 192 | +Overwritted calculated fieldsperitem input downward |
| 193 | +!! input |
| 194 | +{{#list:format=$1<sup>$2+$3</sup>|fieldsperitem=2|1|2|3|4|5|6}} |
| 195 | +!! result |
| 196 | +<p>1<sup>2+$3</sup>, 3<sup>4+$3</sup> and 5<sup>6+$3</sup> |
| 197 | +</p> |
| 198 | +!! end |
| 199 | + |
| 200 | +!! test |
| 201 | +Basic rawlist input |
| 202 | +!! input |
| 203 | +{{#rawlist:,|1,2,3,4,5}} |
| 204 | +!! result |
| 205 | +<p>1, 2, 3, 4 and 5 |
| 206 | +</p> |
| 207 | +!! end |
| 208 | + |
| 209 | +!! test |
| 210 | +Basic rawlist input with ignore |
| 211 | +!! input |
| 212 | +{{#rawlist:,|1,2,3,4,5|ignore=4}} |
| 213 | +!! result |
| 214 | +<p>1, 2, 3 and 5 |
| 215 | +</p> |
| 216 | +!! end |
| 217 | + |
| 218 | +!! test |
| 219 | +Rawlist input in two elements |
| 220 | +!! input |
| 221 | +{{#rawlist:,|1,2,3|4,5}} |
| 222 | +!! result |
| 223 | +<p>1, 2, 3, 4 and 5 |
| 224 | +</p> |
| 225 | +!! end |
| 226 | + |
| 227 | +!! test |
| 228 | +Rawlist input in two elements with two ignored elements |
| 229 | +!! input |
| 230 | +{{#rawlist:,|1,2,3|4,5|ignore=2,4}} |
| 231 | +!! result |
| 232 | +<p>1, 3 and 5 |
| 233 | +</p> |
| 234 | +!! end |
| 235 | + |
| 236 | +!! test |
| 237 | +Basic ignore scenario |
| 238 | +!! input |
| 239 | +{{#list:1|2|3|4|ignore=3}} |
| 240 | +!! result |
| 241 | +<p>1, 2 and 4 |
| 242 | +</p> |
| 243 | +!! end |
| 244 | + |
| 245 | +!! test |
| 246 | +Ignoring wikilinks |
| 247 | +!! input |
| 248 | +{{#list: [[Foo]] | [[Bar]] | ignore=[[Foo]] }} |
| 249 | +!! result |
| 250 | +<p><a href="https://www.mediawiki.org/index.php?title=Bar&action=edit&redlink=1" class="new" title="Bar (page does not exist)">Bar</a> |
| 251 | +</p> |
| 252 | +!! end |
| 253 | + |
| 254 | +!! test |
| 255 | +Overwriting ignore with data |
| 256 | +!! input |
| 257 | +{{#list: [[Foo]] | [[Bar]] | data=ignore=[[Foo]] }} |
| 258 | +!! result |
| 259 | +<p><a href="https://www.mediawiki.org/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">Foo</a>, <a href="https://www.mediawiki.org/index.php?title=Bar&action=edit&redlink=1" class="new" title="Bar (page does not exist)">Bar</a> and ignore=<a href="https://www.mediawiki.org/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">Foo</a> |
| 260 | +</p> |
| 261 | +!! end |
\ No newline at end of file |