Re: is_deeply() and code refs

2005-07-01 Thread demerphq
On 7/1/05, Michael G Schwern [EMAIL PROTECTED] wrote: On Thu, Jun 30, 2005 at 09:44:06AM +0200, demerphq wrote: Out of curiousity, if Data::Dumper::Streamer can handle closures why not fix B::Deparse? I'm not really sure what you mean by fix B::Deparse. B::Deparse does exactly what it

is_deeply() and code refs

2005-06-30 Thread demerphq
Hi, Yitzchak pointed me to this thread. I thought I'd add that Data::Dump::Streamer v1.14 has the capability to Dump closures properly, that is including bound lexical state. (Albeit with a few minor caveats, its possible to deliberately construct pathological closures that wont be eval'able,

Re: is_deeply() and code refs

2005-06-30 Thread Michael G Schwern
On Thu, Jun 30, 2005 at 08:03:32AM +0200, demerphq wrote: Yitzchak pointed me to this thread. I thought I'd add that Data::Dump::Streamer v1.14 has the capability to Dump closures properly, that is including bound lexical state. Interesting. is_deeply() can try to use Data::Dumper::Streamer

Re: is_deeply() and code refs

2005-06-30 Thread demerphq
On 6/30/05, Michael G Schwern [EMAIL PROTECTED] wrote: On Thu, Jun 30, 2005 at 08:03:32AM +0200, demerphq wrote: Yitzchak pointed me to this thread. I thought I'd add that Data::Dump::Streamer v1.14 has the capability to Dump closures properly, that is including bound lexical state.

Re: is_deeply() and code refs

2005-06-30 Thread demerphq
On 6/30/05, demerphq [EMAIL PROTECTED] wrote: Incidentally this is a pretty common mistake when handling REF's. Data::Dumper does it as does YAML and pretty much all the other storage tools that i have looked at, although Storable gets it right. Also, i should say that while this circular ref

Re: is_deeply() and code refs

2005-06-30 Thread Michael G Schwern
On Thu, Jun 30, 2005 at 09:44:06AM +0200, demerphq wrote: Out of curiousity, if Data::Dumper::Streamer can handle closures why not fix B::Deparse? I'm not really sure what you mean by fix B::Deparse. B::Deparse does exactly what it says it does: it deparses code. We can't consider it

Re: is_deeply() and code refs

2005-06-28 Thread Fergal Daly
On 6/27/05, Michael G Schwern [EMAIL PROTECTED] wrote: On Mon, Jun 27, 2005 at 11:20:07AM +0100, Fergal Daly wrote: I'm perfectly happy to punt this problem over to B::Deparse and let them figure it out. As it stands B::Deparse is the best we can do with code refs. What's the

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Mon, Jun 27, 2005 at 11:20:07AM +0100, Fergal Daly wrote: I'm perfectly happy to punt this problem over to B::Deparse and let them figure it out. As it stands B::Deparse is the best we can do with code refs. What's the alternative? I'd argue that currently the best you can do is ==

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Mon, Jun 27, 2005 at 11:34:58PM +0100, Fergal Daly wrote: Forgetting philosphical arguments about what's the right thing to do, I think the strongest point against this is that there may be people out there who expect the current behaviour The current behavior is to vomit all over the

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Tue, Jun 28, 2005 at 12:21:48AM +0100, Fergal Daly wrote: That's only 2 months old (according to CPAN) before that it would have just failed or passed (failed in this case). Is it in bleadperl? I'd be amazed if no one anywhere was using is_deeply with coderefs. It was undefined, accidental

Re: is_deeply() and code refs

2005-06-26 Thread Tels
-BEGIN PGP SIGNED MESSAGE- Moin, On Sunday 26 June 2005 07:18, Collin Winter wrote: My initial quick-glance at B::Deparse's documentation mentions something about perl optimising certain constants away, which could well throw a spanner into the works. Storable uses B::Deparse

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 10:25:51AM +0200, Tels wrote: After tinkering with B::Deparse for a bit, I think this particular oddity may just be a result of poorly-written docs (or, more probably, poorly-read on my part). The module seems to do the right thing in all cases I could come up with

Re: is_deeply() and code refs

2005-06-26 Thread David Landgren
Tels wrote : -BEGIN PGP SIGNED MESSAGE- Moin, On Sunday 26 June 2005 07:18, Collin Winter wrote: [...] After tinkering with B::Deparse for a bit, I think this particular oddity may just be a result of poorly-written docs (or, more probably, poorly-read on my part). The module seems

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 12:06:47PM +0200, David Landgren wrote: What it *shouldn't* do is what Test.pm does, namely execute the code ref and compare the values returned. It would just compare the refernces. Why should it not do that? Is this because of subs with side effects? Isn't

Re: is_deeply() and code refs

2005-06-26 Thread Fergal Daly
You have 3 situations 1 the refs came from \somefunc 2 the refs come from evaling strings of code 3 the refs are closures and therefore have some data associated with them For 3, it looks like B::Deparse does't handle the data at all so even if the deparsed subs are identical they may behave

Re: is_deeply() and code refs

2005-06-26 Thread Smylers
David Landgren writes: Michael Schwern wrote at the beginning of this thread: What it *shouldn't* do is what Test.pm does, namely execute the code ref and compare the values returned. It would just compare the refernces. Why should it not do that? Is this because of subs with side

Re: is_deeply() and code refs

2005-06-26 Thread Collin Winter
On 6/26/05, Fergal Daly [EMAIL PROTECTED] wrote: You have 3 situations 1 the refs came from \somefunc 2 the refs come from evaling strings of code 3 the refs are closures and therefore have some data associated with them For 3, it looks like B::Deparse does't handle the data at all so

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 12:57:05PM +0100, Fergal Daly wrote: 1 the refs came from \somefunc 2 the refs come from evaling strings of code 3 the refs are closures and therefore have some data associated with them For 3, it looks like B::Deparse does't handle the data at all so even if the

is_deeply() and code refs

2005-06-25 Thread Michael G Schwern
Currently, throwing is_deeply() a code ref causes it to barf. perl -MTest::More -wle 'print is_deeply sub {}, sub {}' WHOA! No type in _deep_check This should never happen! Please contact the author immediately! # Looks like your test died before it could output anything. is_deeply() doesn't

Re: is_deeply() and code refs

2005-06-25 Thread Collin Winter
I'll chime in, as I'm the one who initially raised the idea : ) I'll start with a use-case: my initial motivation for having is_deeply handle coderefs came up while building certain unit tests for a rewrite of DBD::Mock. Several of the worker functions return complex data structures -- which may

Re: is_deeply() and code refs

2005-06-25 Thread Collin Winter
My initial quick-glance at B::Deparse's documentation mentions something about perl optimising certain constants away, which could well throw a spanner into the works. Storable uses B::Deparse when serialising coderefs, though, so I'm certain there's a way around this. That shouldn't