Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -146,12 +146,13 @@ |
147 | 147 | .innerHTML; |
148 | 148 | } catch(e) { |
149 | 149 | console.log("normalizeHTML failed:" + e); |
| 150 | + console.trace(); |
150 | 151 | return source; |
151 | 152 | } |
152 | 153 | |
153 | 154 | } |
154 | 155 | |
155 | | -// Specialized normalization of the parser output, mostly to ignore a few |
| 156 | +// Specialized normalization of the wiki parser output, mostly to ignore a few |
156 | 157 | // known-ok differences. |
157 | 158 | function normalizeOut ( out ) { |
158 | 159 | // TODO: Do not strip newlines in pre and nowiki blocks! |
— | — | @@ -159,11 +160,15 @@ |
160 | 161 | } |
161 | 162 | |
162 | 163 | function formatHTML ( source ) { |
163 | | - // Quick hack to insert newlines before block level start tags! |
164 | | - return source.replace(/(?!^)<((dd|dt|li|p|table|tr|td|tbody|dl|ol|ul)[^>]*)>/g, |
| 164 | + // Quick hack to insert newlines before some block level start tags |
| 165 | + return source.replace(/(?!^)<((div|dd|dt|li|p|table|tr|td|tbody|dl|ol|ul)[^>]*)>/g, |
165 | 166 | '\n<$1>'); |
166 | 167 | } |
167 | 168 | |
| 169 | +var passedTests = 0, |
| 170 | + failParseTests = 0, |
| 171 | + failTreeTests = 0, |
| 172 | + failOutputTests = 0; |
168 | 173 | |
169 | 174 | function processTest(item) { |
170 | 175 | var tokenizer = new FauxHTML5.Tokenizer(); |
— | — | @@ -191,6 +196,7 @@ |
192 | 197 | parser.parseToTree(item.input + "\n", function(tokens, err) { |
193 | 198 | if (err) { |
194 | 199 | printTitle(); |
| 200 | + failParseTests++; |
195 | 201 | console.log('PARSE FAIL', err); |
196 | 202 | } else { |
197 | 203 | var environment = new MWParserEnvironment({ |
— | — | @@ -208,9 +214,11 @@ |
209 | 215 | |
210 | 216 | if ( err ) { |
211 | 217 | printTitle(); |
| 218 | + failTreeTests++; |
212 | 219 | console.log('RENDER FAIL', err); |
213 | 220 | } else if ( normalizeOut(out) !== normalizeHTML(item.result) ) { |
214 | 221 | printTitle(); |
| 222 | + failOutputTests++; |
215 | 223 | console.log('RAW EXPECTED:'); |
216 | 224 | console.log(item.result + "\n"); |
217 | 225 | |
— | — | @@ -231,6 +239,7 @@ |
232 | 240 | console.log('DIFF:'); |
233 | 241 | console.log(patch.replace(/^[^\n]*\n[^\n]*\n[^\n]*\n[^\n]*\n/, '')); |
234 | 242 | } else { |
| 243 | + passedTests++; |
235 | 244 | console.log( 'PASS: ' + item.title ); |
236 | 245 | } |
237 | 246 | } |
— | — | @@ -270,4 +279,14 @@ |
271 | 280 | } |
272 | 281 | } |
273 | 282 | }); |
| 283 | + |
| 284 | +console.log( "=========================================================="); |
| 285 | +console.log( "SUMMARY: "); |
| 286 | +console.log( passedTests + " passed"); |
| 287 | +console.log( failParseTests + " parse failures"); |
| 288 | +console.log( failTreeTests + " tree build failures"); |
| 289 | +console.log( failOutputTests + " output differences"); |
| 290 | +console.log( "\n" + (failParseTests + failTreeTests + failOutputTests) + " total failures"); |
| 291 | +console.log( "=========================================================="); |
| 292 | + |
274 | 293 | })(); |