Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Problem defining a Test::Deep structure to match this arrayref

by mje (Curate)
on May 12, 2010 at 11:19 UTC ( #839660=note: print w/replies, xml ) Need Help??


in reply to Re: Problem defining a Test::Deep structure to match this arrayref
in thread Problem defining a Test::Deep structure to match this arrayref

JavaFan yes it does. I guess I just got lost trying to do it with one structure. Would still be interested if anyone spots a way of doing it without specifying two patterns.

Working version using JavaFan's suggestion:

use Test::More tests => 2; use Test::Deep; my $id_re = re('^\d+$'); my $vpt_re = re('^-?1$'); my $x = [ '11', '22', [ [ '-1', ], [ # '1', # only present if '22' above present ] # ] ]; my $y = [ '11', [ [ '-1', ], ] ]; my $comp1 = [ $id_re, [[$vpt_re]] ]; my $comp2 = [ $id_re, $id_re, [[$vpt_re], [$vpt_re]] ]; cmp_deeply($x, any($comp1, $comp2), 'test1'); cmp_deeply($y, any($comp1, $comp2), 'test2');
  • Comment on Re^2: Problem defining a Test::Deep structure to match this arrayref
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://839660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2019-10-23 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?