Re: Test::More and 'deep' tests

2003-09-10 Thread Tony Bowden
On Tue, Sep 09, 2003 at 08:50:06PM +0100, Fergal Daly wrote: The docs for is() says it uses eq, is_deeply() says it looks inside, it doesn't say looks inside sometimes. It says it looks inside listrefs and hashrefs. That's all. Objects are not listrefs and hashrefs. They are sometimes made

Re: Test::More and 'deep' tests

2003-09-10 Thread Ilya Martynov
On Tue, 9 Sep 2003 14:40:09 -0400, Gordon Henriksen [EMAIL PROTECTED] said: GH Fergal Daly [EMAIL PROTECTED] wrote: On Tuesday 09 September 2003 19:27, Gordon Henriksen wrote: Isn't the easiest way to get a recursive-and-exact object graph match to simply use an existing serializer

Re: Test::More and 'deep' tests

2003-09-10 Thread Tony Bowden
On Wed, Sep 10, 2003 at 07:18:53AM -0400, [EMAIL PROTECTED] wrote: The fact the is_deeply currently looks inside them is a bug. The AUTHOR INTENDED IT TO and so it is not a bug. The author's intent is entirely irrelevant to whether or not something is a bug. and you want to ignore Michael's

Re: Test::More and 'deep' tests

2003-09-10 Thread [EMAIL PROTECTED]
On Tue, Sep 09, 2003 at 08:50:06PM +0100, Fergal Daly wrote: It says it looks inside listrefs and hashrefs. That's all. Objects are not listrefs and hashrefs. They are sometimes made *from* such, but they are not such. I think many people would disagree with you here but that's irrelevant

Re: Test::More and 'deep' tests

2003-09-10 Thread [EMAIL PROTECTED]
Tony Bowden wrote: The author's intent is entirely irrelevant to whether or not something is a bug. Wow. I had 2 possible responses in mind, this one was not on my radar at all. That was top left corner in the last second of extra time but we appear to be playing on 2 different pitches.

Re: Test::More and 'deep' tests

2003-09-10 Thread Michael G Schwern
On Tue, Sep 09, 2003 at 08:39:21PM +0200, Tels wrote: Real world example: [*] [EMAIL PROTECTED]:~ perl -MTest::More -MMath::String -wle 'plan tests = 1; $a = Math::String-new(abc); $b = $a-copy()-bneg(); ok $a,$b; print $a != $b (, $a-as_number(), != , $b-as_number(),);' 1..1 ok 1 - abc

Re: Test::More and 'deep' tests

2003-09-10 Thread Michael G Schwern
On Tue, Sep 09, 2003 at 09:26:23AM -0700, Ovid wrote: This is fine: isa_ok($str2, ref $str1, '... and the object'); This is (almost) not fine: is($str2, $str1, '... and the strings are equal'); However, the latter (and is_deeply()) should work *If and Only If* that comparison is

Re: Test::More and 'deep' tests

2003-09-10 Thread Michael G Schwern
On Wed, Sep 10, 2003 at 07:18:53AM -0400, [EMAIL PROTECTED] wrote: The AUTHOR INTENDED IT TO and so it is not a bug. If you don't believe me and you want to ignore Michael's previous mail on it then look at the source code where you will see if( UNIVERSAL::isa($e1, 'ARRAY') and

Re: Test::More and 'deep' tests

2003-09-09 Thread Ovid
My opinion: those is_deeply() tests should probably not pass. While on the surface it may appear that they should, I would argue that this is a case where the programmer writing the tests needs to know enough about the system he or she is building to create tests that accurately reflect how

Re: Test::More and 'deep' tests

2003-09-09 Thread Fergal Daly
The question needs changing. Both versions of is_deeply will give the same answer on these tests. I was going to say: What you need is package MyOtherString; use overload '' = sub { shift-[0] }, fallback = 1; sub new { my ($class, $val) = @_; bless [ $val ], $class; } But actually

Re: Test::More and 'deep' tests

2003-09-09 Thread Tony Bowden
On Tue, Sep 09, 2003 at 01:07:00PM +0100, Fergal Daly wrote: The question needs changing. Both versions of is_deeply will give the same answer on these tests. But do you agree that they should all pass? If so I've completely misunderstood your earlier arguments. They certainly aren't deeply

Re: Test::More and 'deep' tests

2003-09-09 Thread Tony Bowden
On Tue, Sep 09, 2003 at 01:25:22PM +0100, Adrian Howard wrote: 1) ok $str1 eq $str2; 2) is $str1, $str2; 3) is_deeply [$str1], [$str2]; 4) is_deeply $str1, $str2; All should pass as far as I am concerned. OK - what if it was slightly more complex: package MyString; use overload '' =

Re: Test::More and 'deep' tests

2003-09-09 Thread Adrian Howard
On Tuesday, Sep 9, 2003, at 10:52 Europe/London, Tony Bowden wrote: [snip] 1) ok $str1 eq $str2; 2) is $str1, $str2; 3) is_deeply [$str1], [$str2]; 4) is_deeply $str1, $str2; All should pass as far as I am concerned. The Test::More deeply behaviour matches my intuitions, and I would have tests

Re: Test::More and 'deep' tests

2003-09-09 Thread Tels
-BEGIN PGP SIGNED MESSAGE- Moin, On Tuesday 09 September 2003 16:29, Tony Bowden wrote: On Tue, Sep 09, 2003 at 01:25:22PM +0100, Adrian Howard wrote: 1) ok $str1 eq $str2; 2) is $str1, $str2; 3) is_deeply [$str1], [$str2]; 4) is_deeply $str1, $str2; All should pass as far

Re: Test::More and 'deep' tests

2003-09-09 Thread Fergal Daly
On Tuesday 09 September 2003 15:29, Tony Bowden wrote: On Tue, Sep 09, 2003 at 01:25:22PM +0100, Adrian Howard wrote: 1) ok $str1 eq $str2; 2) is $str1, $str2; 3) is_deeply [$str1], [$str2]; 4) is_deeply $str1, $str2; All should pass as far as I am concerned. I agree. There is no

Re: Test::More and 'deep' tests

2003-09-09 Thread Tony Bowden
On Tue, Sep 09, 2003 at 05:49:47PM +0100, Fergal Daly wrote: my $str1 = MyString-new(foo, bar); my $str2 = MyOtherString-new(foo, baz); Now they _do_ differ by more than just class and it should be a fail, although I must admit that even with the current is_deeply it will be a pass. I

Re: Test::More and 'deep' tests

2003-09-09 Thread Andrew Wilson
On Tue, Sep 09, 2003 at 05:49:47PM +0100, Fergal Daly wrote: On Tuesday 09 September 2003 15:29, Tony Bowden wrote: my $str1 = MyString-new(foo, bar); my $str2 = MyOtherString-new(foo, baz); Now they _do_ differ by more than just class and it should be a fail, although I must admit that

Re: Test::More and 'deep' tests

2003-09-09 Thread chromatic
On Tuesday, September 9, 2003, at 11:23 AM, Tels wrote: From my point of view is_deeply() is an extended ok(), which also walks arrays, hashes and other (possible nested) structures, and then compares _each_ element. This is how I've always seen it, assuming Tels meant is() instead of ok()

RE: Test::More and 'deep' tests

2003-09-09 Thread Gordon Henriksen
Fergal Daly [EMAIL PROTECTED] wrote: On Tuesday 09 September 2003 19:27, Gordon Henriksen wrote: Isn't the easiest way to get a recursive-and-exact object graph match to simply use an existing serializer (FreezeThaw, Data::Dumper)? If you want a yes/no answer then it probably is but

Re: Test::More and 'deep' tests

2003-09-09 Thread Fergal Daly
On Tuesday 09 September 2003 19:23, Tels wrote: I agree. For instance, ok() just looks at the outside, and if it compares ok, the objects are considered equal. After all, this is the entire point behind overloading and tie, to fake something. For instance, this feature of ok() makes it