logo       

Re: Is_deeply and closure-driven coderefs: msg#00076

Subject: Re: Is_deeply and closure-driven coderefs
On 5/30/06, Andrew Gianni <agianni@xxxxxxxxxxx> wrote:

I have a subroutine that populates a hash of arrays with coderefs by
calling
closures. I'm trying to call Test::More::is_deeply to compare two
structures
that should be identical and I'm running into trouble. When none of the
closures take arguments, everything is fine, but when one of the closure
subroutines takes an argument to generate the code, is_deeply fails.


          is_deeply() current has very limited handling of function
reference
          and globs.  It merely checks if they have the same referent.
This
          may improve in the future.

closure_no_args() is always returning the same code reference since its not
really a closure, its just a plain anonymous function.  closure_args() is
returning a real closure and apparently a different code ref.

At this time all is_deeply() will check is that the code references are the
same.


I suppose that the important thing is not the content of the coderefs, but
that their return values are equal, but I'm not sure what would really
make
a valid test in this case or what the best means of comparing those would
be. Any assistance would be appreciated.


The trick is what does "equal" mean for code refs?

If you want to test that the code refs are functionally equivalent, call
them with various arguments and test the results.

If you want to test that the code the code refs refer to is equivalent use
something like Data::Dump::Streamer which can deparse a closure back to its
original code and values.  Compare the dumped output.
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe