I'm using Test::More in my module test scripts. In testing the ways one can create a copy of an object, I use the eq_hash utility function to compare two objects (since they are hash based objects). This works fine except for one niggling detail.
A couple of the attributes are computed on the fly as needed and cached in the object. Other operations invalidate that cache as appropriate. One of the copy methods is a full copy, but the other only copies the data that must be saved, ignoring the cached data.
I'm thinking that it would be useful to have a version of eq_hash that takes a list of hash keys to ignore in the comparison.
I envision something like:
ok eq_hash($hashref1, $hashref2, [qw/key1 key2/]), 'partial hash compa +rison';
I'm open to suggestions, etc.
yours,
Michael
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test::More extension idea
by chromatic (Archbishop) on Oct 16, 2001 at 07:52 UTC | |
by herveus (Prior) on Oct 16, 2001 at 21:54 UTC |