From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-05-27T13:00:24+09:00 Subject: Re: using test::unit for C++ unit tests In article , Bob Calco wrote: >Phil: > >As a C/C++ guy at heart, I have given some thought to this problem (i.e., >that of using Ruby to generate unit tests for other languages like, oh, say >C and C++). In fact, it's one of the core themes of the book I'm working on >with Rich Kilmer and Dana Moore: Ruby as a software engineering toolsmith >language. > >One approach (the one toward which I lean) is to generate the C++ classes >using Ruby as a sort of code specification language. I'm calling the package >RuGen, and it will have an assortment of code generators one day, but >upfront I'm working on code generators for Java and C++. The beauty of this >approach is it becomes unnecessary to parse a C++ file to determine what to >test, because you already have all of the metadata about the code you need >to a.) generate the code (or at least the complete skeleton/interface >thereof) and b.) generate the test code for the generated code, treating the >interface as a "black box". (I'm writing a separate package, RuLog, to >provide the logic/inference capabilities necessary to create meaningful and >comprehensive test cases from the spec). > >RuGen is still in the design/prototype phase, but the idea is fairly clear >in my head, in terms of how it will work. Rather than create a bunch of >specific language parsers, have one specification language (in much the same >way that Ruby/DL is a specification language for dynamic loading of external >libraries) and a number of generators that are capable of translating the >spec to code in a more or less plug'n'play, or, if I ever get around to >slapping a GUI on it, a point'n'click fashion. > >Hopefully I'll have something working soon - I'm probably going to do the >Java generator first, though. But it should serve as an example to everybody >else how to build a code generator for the RuGen package (RuGen providing >the high-level abstractions needed to tie all the plug-in pieces together). > >All thoughts, comments, suggestions welcome. > >:) > Bob, RuGen sounds really interesting and potentially useful. So let me see if I understand correctly: you could write some Ruby classes/code which would act as an executable spec and then at some point you could translate the Ruby classes into C++ classes and testcases. If I'm understanding correctly, this would be a great way to prototype C++ code using Ruby. So how will you specify types for the C++ side? Any idea when we might see the inital release of RuGen? Phil