Ovid,
If you want/need to test for circular data structures, Test::Memory::Cycle does a nice job. It's bascially just a wrapper around Devel::Cycle. And if you need to test weakened ones, I am wrote a patch for both Devel::Cycle and Test::Memory::Cycle to be able to check them as well. We are waiting to release it until I put it through the wringer a few times, but I am sure Andy and Lincoln wouldn't mind if I let you test it out as well (if you need it that is).
Of course, if you really wanna do heavy-duty large-scale data structure testing, I *highly* recommend Test::Deep (which Fergal wrote). It has saved my a** many times before, and I just recently used it again, saving myself several hours and much headache. And aside from just being practical, it's got this really cool declarative interface which is fun to play with :)
- Steve
On Jan 23, 2005, at 2:13 PM, Fergal Daly wrote:
What version of Test::More? Only the most recent versions can handle
circular data structures, so I'd guess you have a circular data structure
and an older version,
Fergal
On Sun, Jan 23, 2005 at 09:22:19AM -0800, Ovid wrote:(Aargh! This time I'll send this from the correct email address.)
Hi all,
I didn't find that this is a known issue reported somewhere so I thought I would post it here.
This program hangs when it hits is_deeply. I eventually get an "out of
memory" error.
#!/usr/local/bin/perl use AI::Prolog::Parser; use AI::Prolog::Term; use AI::Prolog::Engine; use Test::More qw/no_plan/; use Test::Differences; use Clone qw/clone/;
my $database = AI::Prolog::Parser->consult(<<'END_PROLOG'); append([], X, X). append([W|X],Y,[W|Z]) :- append(X,Y,Z). END_PROLOG
my $parser = AI::Prolog::Parser->new("append([a],[b,c,d],Z)."); my $query = AI::Prolog::Term->new($parser); my $engine = AI::Prolog::Engine->new($query,$database); my $cloned_db = clone($database); eq_or_diff $cloned_db, $database, 'eq_or_diff says they are the same'; is_deeply $cloned_db, $database, '... but this hangs';
AI::Prolog is not yet on the CPAN, so if someone want's to test this, they can grab it from http://users.easystreet.com/ovid/downloads/AI-Prolog-0.01.tar.gz
I didn't do too much research into this as eq_or_diff() solves my problem, but we appear to have an infinit loop in Test::More::eq_hash.
Cheers, Ovid
=====
If this message is a response to a question on a mailing list, please send
follow up questions to the list.
Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/