in reply to Code Generation from Test Suites

I think this is a really interesting and novel idea, and I can't say that I've heard of it before from anyone else.

I think it also might just work.

Now obviously, as you say, there's only so much you can do.

But I don't see why you couldn't at least stub out the classes and methods you see mentioned, and get at least the package, strict, $VERSION, sub new, sub whateveryousee, and so on in place, based soley on what you see in the tests.

You wouldn't get a lot, but you might just get enough to make it interesting and worth while.

I say go for it.

Start with PPI for the parsing, and then build up a simple model of the classes based on what you see.

Then genenerate the basics for a class and write the files to an appropriately named file, in a position relative to the test file based on normal dist structure.

Replies are listed 'Best First'.
Re^2: Code Generation from Test Suites
by reneeb (Chaplain) on Sep 14, 2006 at 09:35 UTC
    I would use the method names used for can_ok to generate the method stubs.

    But there are several problems:
    • what if you have typos (in method names) in the test
    • you correct them, is it a new sub or is it possible to identify the misspelled sub in the generated code?
    • ...