On Tue, Jun 30, 2009 at 2:15 PM, Ovid<publiustemp-perl...@yahoo.com> wrote:
> Also, I think playing around with more fluent interfaces is a good idea.  If 
> my interface is great, why not?  If it's bad, what would people *love* to see 
> in a test interface which allows them to naturally write tests?

Well, if you're doing interface design, one of the first things that
comes to mind is that the name of the test should come first, not
last.

I've often taken to writing tests like this:

    is( $have, $want
      "label goes here"
    );

This means I can skim down the screen and all of the test labels line
up nicely.  So I'm in favor of something along the lines of

    test "label goes here" => is( $have, $want ) => diag $diag;

Which could work nicely for nesting, too

    test "a subtest label" => nest {
        # sub tests here
    };

It would be test( $label, @objects ), where objects are executed in
some sensible order (e.g. diag objects only called if assertion object
returns false).

It could get quite involved, if one really wanted

    test "label" => is( $have, $want ) => setup \&setup => teardown
\&teardown => diag \&diag => note \&note;

Then creating new tests is just a matter of creating assertion
classes.  (Assertion classes could return diagnostic objects as well,
perhaps).

-- David

Reply via email to