On Tue, 9 Apr 2002, Michael G Schwern wrote:

> On Tue, Apr 09, 2002 at 03:26:21PM +0100, Mark Fowler wrote:
> > There's a lot of other problems like that. So I was thinking of writing 
> > Test::Sloppy (aka Test::Fuzzy, aka...)
> 
> What would it do?
>
> (I can show you lots of sloppy tests if you like. :)

Sorry, maybe it wasn't clear from the example.  sort of like eq_set meets 
is_deeply.

Let's drag the example out again:

 wanted                           got

 [                                [
   { a => "foo", b => "bar" },      { a => "baz", b => "qux" },
   { a => "baz", b => "qux" },      { a => "foo", b => "bar" },
 ]                                ]

This will of course fail with eq_set which just uses eq to compare items
(which won't work for hashes), so although it'll cope happly with the fact
that the elements aren't in the same order, it'll still fail.

(I got around this in my actual tests I just wrote by freezing the hashes 
to flatten them then comparing both lists with eq_set)

Sloppy/Fuzzy would attempt to do away with such problems by sorting all 
lists down to a defined level first.  Off the top of my head

   list_cmp_fuzzy($list1, $list2, 3)

would ignore all lists down to 3 levels.

Added other functionality to be introduced at a later date:

 a) Treating lists as hashes (i.e. they can be reordered at will but 
    elements must be paired)
 b) Doing proper set comparison (not bags)
 c) Better handling of overloaded objects

And more ideas, if I can think of them.  Or more importantly, if you can.

Later.

Mark.

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}


Reply via email to