From: Peter Rabbitson Date: Sat, 25 Oct 2014 12:34:28 +0000 (+0200) Subject: (internal) Introduce an extra utility function, essentially a ( >= , < ) test X-Git-Tag: v0.082820~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a3d73e9f21ef4ebd892eb8186234c1d248dd035;p=dbsrgits%2FDBIx-Class.git (internal) Introduce an extra utility function, essentially a ( >= , < ) test (cherry pick of d634850b) --- diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index ab1f6ed..be34bc6 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -78,7 +78,7 @@ sub qsub ($) { goto "e_sub } # no point depping on new Moo just for this use base 'Exporter'; our @EXPORT_OK = qw( - sigwarn_silencer modver_gt_or_eq + sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt fail_on_internal_wantarray fail_on_internal_call refdesc refcount hrefaddr is_exception quote_sub qsub perlstring serialize @@ -199,6 +199,19 @@ sub modver_gt_or_eq ($$) { eval { $mod->VERSION($ver) } ? 1 : 0; } +sub modver_gt_or_eq_and_lt ($$$) { + my ($mod, $v_ge, $v_lt) = @_; + + croak "Nonsensical maximum version supplied" + if ! defined $v_lt or $v_lt =~ /[^0-9\.\_]/; + + return ( + modver_gt_or_eq($mod, $v_ge) + and + ! modver_gt_or_eq($mod, $v_lt) + ) ? 1 : 0; +} + { my $list_ctx_ok_stack_marker; diff --git a/t/752sqlite.t b/t/752sqlite.t index e1d90bd..9cee7e2 100644 --- a/t/752sqlite.t +++ b/t/752sqlite.t @@ -9,7 +9,7 @@ use Math::BigInt; use lib qw(t/lib); use DBICTest; -use DBIx::Class::_Util qw(sigwarn_silencer modver_gt_or_eq); +use DBIx::Class::_Util qw( sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt ); # check that we work somewhat OK with braindead SQLite transaction handling # @@ -160,9 +160,7 @@ $schema->storage->dbh_do(sub { $_[1]->do('ALTER TABLE artist ADD COLUMN bigint BIGINT'); }); -my $sqlite_broken_bigint = ( - modver_gt_or_eq('DBD::SQLite', '1.34') and ! modver_gt_or_eq('DBD::SQLite', '1.37') -); +my $sqlite_broken_bigint = modver_gt_or_eq_and_lt( 'DBD::SQLite', '1.34', '1.37' ); # 63 bit integer my $many_bits = (Math::BigInt->new(2) ** 62); diff --git a/t/inflate/hri.t b/t/inflate/hri.t index b9ca3d8..b5e9d2f 100644 --- a/t/inflate/hri.t +++ b/t/inflate/hri.t @@ -3,11 +3,11 @@ use warnings; use Test::More; -use DBIx::Class::_Util 'modver_gt_or_eq'; +use DBIx::Class::_Util 'modver_gt_or_eq_and_lt'; use base(); BEGIN { plan skip_all => 'base.pm 2.20 (only present in perl 5.19.7) is known to break this test' - if modver_gt_or_eq(base => '2.19_01') and ! modver_gt_or_eq(base => '2.21'); + if modver_gt_or_eq_and_lt( 'base', '2.19_01', '2.21' ); } use Test::Exception;