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
> consider that a bug and it's something I avoided in Test::Deep by using
> Scalar::Util::refaddr, I just never backported that to Test::More.
This, coupled with the post to p5p, makes me think that the main issue
here has nothing to do with overloading at all, but as to whether
is_deeply is meant to descend into an object that happens to be
implemented via a blessed datastructure.
I don't believe it should - if you need that there should another
method.
> The reason I want it to fail is because if I pass these objects (and they are
> definitely objects, they're only strings if you squint)
This is where we differ in opinion as well.
It's not a matter of squinting. In the case of overload::string, and
similarly with tie(), the user may not even know that these are objects.
When asked to be a string they'll act as one, and that's good enough for
most uses. That's the point of providing this functionality in perl.
> Or if I pass them to a function that behaves differently for strings
> and objects, I'll get the object behaviour, not the string behaviour.
Depending on the behaviour, that's probably a bug in that function...
> "Mr deeply please check that datastructure and tell me if it's an array of a
> type 5 widgets"
> "I checked and it's exactly what you asked for no way could it be anything
> different"
>
> Scenario B:
> "Mr deeply please check that datastructure and tell me if it's an array of a
> type 5 widgets"
> "Well, some of them definitely were and some of them had labels on them that
> said they were so I didn't bother checking those"
> "which ones has labels?"
> "none of them, all of them, some of them, I can't remember. Relax it's only
> testing. Look at them yourself if you want to be sure"
Most of the time people shouldn't care. If the thing is sufficiently
masquerading as a type 5 widget you shouldn't care - that's purely an
implementation detail.
If you *really* need to care then you should use something other than
is_deeply.
Tony