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 possible to run all Math::BigInt tests with an empty subclass. 
> The (from external view) tests should not care whether it is Math::BigInt or 
> Math::BigInt::Subclass.

I think you mean is() when you say ok() here, ok() doesn't compare anything to 
anything else.

The docs for is() says it uses eq, is_deeply() says it looks inside, it 
doesn't say "looks inside sometimes".

A test that sometimes tests one thing and sometimes tests another and no way 
to know which it did is kind of pointless. When it says "OK", what's it 
saying OK to?

A _crucial_ point is that the test author has no control over when the walking 
and comparing get swapped. The data you are trying to test actually controls 
it.

You wouldn't trust security at an airport that asks you "metal detector or 
paddown today sir?" and so you can't trust a test function that lets the 
tested data control the test.

> - 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. If said element is an overloaded/tied object that "fakes" 

Let me change the emphasis slightly in your sentence

  which also walks arrays, hashes ... and *then* compares each element.

Even _you_ put the walking before the comparing. You have to put the walking 
before the comparing, otherwise you'll think $ref=[] and "$ref" are the same 
and you're think [] and [] are different

> is_deeply() shouldn't look at the single elements differently than ok() or 
> is() do. (Well, my theorie :)

But it has to look at them differently otherwise how can it figure out if it 
needs to walk into them?

You may be thinking of is_deeply as something that just looks inside the first 
level and then applies is() to everything it finds. That's not what it is and 
that's not what it's supposed to be,

F

Reply via email to