[Imps] Test cases for parsing spec

James Graham jg307 at cam.ac.uk
Thu Dec 7 03:59:29 PST 2006


FWIW, I've started writing tokenizer testcases that are simply one-line 
eval-able python expressions of the form:
[input, expected output, description]
e.g. ["<h a='b'>", [["StartTag", "h", {'a':'b'}]], "Start Tag w/attribute"]

This form is clearly suboptimal (it's verbose, has lots of line noise, requires 
everything to be on a single line) but hopefully, since it can be parsed easily, 
we will be able to convert it to a better format in the future.

For parser testcases, I think having, as at least as one mode of operation, a 
pretty-printed dump of the parse tree like Hixie's example:

> Data: Line1<br>Line2<br>Line3<br>Line4
> 7: Parse error: missing document type declaration. (3)
> #document
> | <html>
> |   <head>
> |   <body>
> |     "Line1"
> |     <br>
> |     "Line2"
> |     <br>
> |     "Line3"
> |     <br>
> |     "Line4"

would be good - maybe with the addition of multi-line data something like:

#description: Line breaks, no head or body
#data:
Line1
<br>Line2
<br>Line3
<br>Line4
#errors:
7: Parse error: missing document type declaration. (3)
#document:
| <html>
|   <head>
|   <body>
|     "Line1"
|     <br>
|     "Line2"
|     <br>
|     "Line3"
|     <br>
|     "Line4"

This doesn't exclude the possibility of using the same input data and testing 
the output with Sam's expect:xpath style expressions - but not embedded in a 
leading comment.

-- 
"Eternity's a terrible thought. I mean, where's it all going to end?"
  -- Tom Stoppard, Rosencrantz and Guildenstern are Dead



More information about the Implementors mailing list