On 5/30/06, Andrew Gianni <[EMAIL PROTECTED]> 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.

Reply via email to