[grammarians] ruby grammar unit testing

MenTaLguY mental at rydia.net
Fri Dec 23 19:46:01 EST 2005


I've finished the first round of work on a unit testing framework for
our grammar(s).  I took the guts of the dump-ruby.rb script and turned
it into generate.rb, which parses and dumps s-expressions for ruby files
in the samples/ directory into
exemplars/ruby-{RUBY_MAJOR_VERSION}.{RUBY_MINOR_VERSION}.

Depending on whether or not a sample parsed or failed, the script will
generate either an .sexp file (Lisp s-expressions, with the original
Ruby at the top as comments), or a .failed file which is simply a copy
of the original sample.

Right now the exemplar trees are more or less direct from Ryan's
ParseTree library, but I'm going to start "normalizing" them, stripping
out the bits which reflect implementation details of the interpreter
rather than syntax of the language.  Eventually we'll be left with
exemplar trees which represent "platonic" Ruby parsing product.

The idea is this: those of us doing grammars can set up test harnesses
which output .sexp and .failed files, run them against the samples, and
compare the output against the contents of the appropriate exemplar
directory.

-mental
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rubygrammar-grammarians/attachments/20051223/d37ed5ec/attachment.bin


More information about the Rubygrammar-grammarians mailing list