X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F04modifiers.t;h=2d887717e09757750b0cd4ed0525dfbbae1ead99;hb=df2ddf7787f93344c8e693c8f7cdc93aa55dfc4b;hp=7cb4d2c0bd70130b7a3aadf03fecc1321f4748ba;hpb=c8d97b3d74d77a885a62e1d6fc712b2b058dc4c7;p=dbsrgits%2FSQL-Abstract.git diff --git a/t/04modifiers.t b/t/04modifiers.t index 7cb4d2c..2d88771 100644 --- a/t/04modifiers.t +++ b/t/04modifiers.t @@ -1,15 +1,12 @@ -#!/usr/bin/perl - use strict; use warnings; use Test::More; use Test::Exception; -use SQL::Abstract::Test import => ['is_same_sql_bind']; +use Test::Warn; +use SQL::Abstract::Test import => [qw(is_same_sql_bind diag_where)]; -use Data::Dumper; use SQL::Abstract; - -my $dclone = eval { require Storable; \&Storable::dclone }; +use Storable 'dclone'; #### WARNING #### # @@ -389,31 +386,21 @@ for my $case (@and_or_tests) { TODO: { local $TODO = $case->{todo} if $case->{todo}; - local $Data::Dumper::Terse = 1; - - my @w; - local $SIG{__WARN__} = sub { push @w, @_ }; - my $sql = SQL::Abstract->new ($case->{args} || {}); - my $where_copy = $dclone->($case->{where}) - if $dclone;; + my $where_copy = dclone($case->{where}); - lives_ok (sub { + warnings_are { my ($stmt, @bind) = $sql->where($case->{where}); is_same_sql_bind( $stmt, \@bind, $case->{stmt}, $case->{bind}, - ) - || diag "Search term:\n" . Dumper $case->{where}; - }); - is (@w, 0, 'No warnings within and-or tests') - || diag join "\n", 'Emitted warnings:', @w; + ) || diag_where( $case->{where} ); + } [], 'No warnings within and-or tests'; - is_deeply ($case->{where}, $where_copy, 'Where conditions unchanged') - if $dclone; + is_deeply ($case->{where}, $where_copy, 'Where conditions unchanged'); } } @@ -422,7 +409,6 @@ for my $case (@nest_tests) { local $TODO = $case->{todo} if $case->{todo}; local $SQL::Abstract::Test::parenthesis_significant = 1; - local $Data::Dumper::Terse = 1; my $sql = SQL::Abstract->new ($case->{args} || {}); lives_ok (sub { @@ -432,8 +418,7 @@ for my $case (@nest_tests) { \@bind, $case->{stmt}, $case->{bind}, - ) - || diag "Search term:\n" . Dumper $case->{where}; + ) || diag_where ( $case->{where} ); }); } }