stevieb has asked for the wisdom of the Perl Monks concerning the following question:
Hey all,
Is there an is_deeply()-esque function somewhere that does not belong to a test module? It works perfectly for what I'm trying to do, but I can't get the test output to redirect properly, and it interferes with my actual unit tests.
I've put some code I was toying with for testing below, just because it's the right thing to do on PerlMonks when asking a question. It's awful for many reasons, fails unsafely, and uses experimental features. I'm sure things will click together when I look at it tomorrow, but the ol' brain has given up thinking with it being Friday afternoon and all.
In the code, I've shortened certain things to fit reasonably nicely... s/current/c/, s/previous/p/. The structure is a hash ref that contains either strings or arrays.
self->{cache_safe} = 1; my @unsafe_cache_params = qw(file extensions include exclude search); my $c = $self->{params}; my $p = $self->{p_run_config}; { no warnings 'uninitialized'; for (@unsafe_cache_params){ if (defined $c->{$_} || defined $p->{$_}){ if (ref $c->{$_} eq 'ARRAY' || ref $p->{$_} eq 'ARRAY'){ if (! (@{$c->{$_}} ~~ @{$p->{$_}})){ $self->{cache_safe} = 0; last; } } elsif ($c->{$_} ne $p->{$_}){ $self->{cache_safe} = 0; last; } } } }
All I need to do is verify whether certain portions of the data structure that is the configuration of the last run are the same as this run.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there an is_deeply() outside of Test::More?
by stevieb (Canon) on Aug 14, 2015 at 21:00 UTC | |
by Your Mother (Archbishop) on Aug 14, 2015 at 22:57 UTC | |
by afoken (Chancellor) on Aug 15, 2015 at 09:20 UTC | |
by stevieb (Canon) on Aug 15, 2015 at 17:24 UTC | |
by thargas (Deacon) on Aug 17, 2015 at 18:17 UTC | |
by stevieb (Canon) on Aug 14, 2015 at 23:44 UTC | |
by Hermano23 (Beadle) on Aug 14, 2015 at 21:06 UTC | |
by stevieb (Canon) on Aug 14, 2015 at 21:14 UTC |