On 2011.11.30 12:28 PM, Ricardo Signes wrote:
>> You're patching Test-Simple.
> 
> Okay.  So, I want to write a third-party test output formatter that emits test
> results in the binary language of my water vaporators.  I subclass some core
> formatter with "use parent" and add some methods or something?

Sometimes.

You can treat it as a generic superclass, with these caveats.

1. You have to override defaults the ad-hoc way, by overriding new() and
   adding arguments.

2. You can't consume roles.

#2 is a problem because some of the public facing things you want to extend
are roles.  I can change all the public facing roles into classes without too
much hassle.  I'm not sure which is yickier, degrading the object design or
the classes leaking out how they're implemented.  Exposing that we're written
with Mouse welds us to Mouse.

For full control, your Formatter must be a Mouse class.

    package Format::Moisture::Vaporator;

    use Mouse;
    extends 'TB2::Formatter';  # or Format::Binary::LoadLifter

The "hitch" described in the original post.  All Mo[ou]se subclasses have to
use the same OO system if they want to take full advantage of roles and
overridable attributes.  Mouse subclasses must use Mouse.  Moose subclasses
must use Moose.  TB2::Mouse subclasses must use TB2::Mouse.

Here's the tl;dr part:

TB2 will use Mouse if Mouse is available. [1]  Otherwise it will use
TB2::Mouse, its bundled and namespace altered copy of Mouse::Tiny.  As far as
any extensions are concerned, TB2 uses Mouse since must depend on Mouse.


> I want to write a better Test::Foo library.  I'm not using "extends 'Tester'"
> or something?

Depends on what you're doing.  If you're just writing a bunch of testing
functions you write it just like you do now.  No knowledge of Mouse necessary.

If you're something like Test::Class or Test::NoWarnings that's changing the
behavior of the test you do, because you probably have to write a new event
handler.


> The only case when the programmer needs to know about the Mouse underpinnings
> is when hacking on the dist itself, not not ever reasonable extensions?

Yes, unless you consider writing a Formatter and altering the behavior of the
whole Test process to be "reasonable".


[1] Once I change it to do that.

-- 
31. Not allowed to let sock puppets take responsibility for any of my
    actions.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to