Fix t/08helper.t with Data::Dumper >= 2.151 (RT#94599)
Dagfinn Ilmari Mannsåker [Mon, 5 May 2014 21:52:27 +0000 (22:52 +0100)]
This version should be robust against future changes regex in
serialisation, both on perl's and Data::Dumper's part.

Changes
t/08helper.t

diff --git a/Changes b/Changes
index fb5ec02..8ef538a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema
 
 0.63
         - Make MooseX::MarkAsMethods a hard prerequisite (RT#94923)
+        - Fix t/08helper.t with Data::Dumper >= 2.151 (RT#94599)
 
 0.62  2014-01-06 12:32:27
         - Don't ship MYMETA.* files (RT#91808)
index 09ae5eb..0a08aae 100644 (file)
@@ -8,6 +8,7 @@ use Test::More;
 use Test::Exception;
 use Catalyst::Helper::Model::DBIC::Schema;
 use Storable 'dclone';
+use Data::Dumper;
 use Test::Requires qw(Catalyst::Helper DBIx::Class::Schema::Loader);
 
 my $helper      = Catalyst::Helper->new;
@@ -72,12 +73,13 @@ $i = instance(args => [$static, q{components=TimeStamp,Foo}]);
 is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp', 'Foo'],
     'two extra components';
 
-my $flags = qr// =~ /\^/ ? '^' : "-xism";
+# Different versions of perl and Data::Dumper serialise regexes differently
+my ($flagstart, $flagend, $postflag) = Dumper(qr//) =~ m{qr/(.*?)(\)?)/([a-z]*)};
 $i = instance(args => [$static, q{constraint=^(foo|bar)$}]);
 is $i->loader_args->{constraint}, qr/^(foo|bar)$/,
     'constraint loader arg';
 is $i->helper->{loader_args}{constraint},
-    qq{qr/(?$flags:^(foo|bar)\$)/},
+    qq{qr/$flagstart^(foo|bar)\$$flagend/$postflag},
     'constraint loader arg as string';
 
 $i = instance(args => [$static, q{exclude=^(foo|bar)$}]);