From: Laurent Dami Date: Thu, 6 Nov 2008 15:19:34 +0000 (+0000) Subject: patch from mendel, using Test::Builder X-Git-Tag: v1.70~267 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5aad8cf3d200d1538a5fad5b01895e1ccd3da80a;p=dbsrgits%2FSQL-Abstract.git patch from mendel, using Test::Builder --- diff --git a/lib/SQL/Abstract/Test.pm b/lib/SQL/Abstract/Test.pm index 916ad6d..d55f3a8 100644 --- a/lib/SQL/Abstract/Test.pm +++ b/lib/SQL/Abstract/Test.pm @@ -2,8 +2,7 @@ package SQL::Abstract::Test; # see doc at end of file use strict; use warnings; -use Test::More; -use base 'Exporter'; +use base qw/Test::Builder::Module Exporter/; use Data::Dumper; use Carp; @@ -12,6 +11,7 @@ our @EXPORT_OK = qw/&is_same_sql_bind &eq_sql &eq_bind our $case_sensitive = 0; our $sql_differ; # keeps track of differing portion between SQLs +our $tb = __PACKAGE__->builder; sub is_same_sql_bind { my ($sql1, $bind_ref1, $sql2, $bind_ref2, $msg) = @_; @@ -23,21 +23,21 @@ sub is_same_sql_bind { my $same_bind = eq_bind($bind_ref1, $bind_ref2); # call Test::More::ok - ok($same_sql && $same_bind, $msg); + $tb->ok($same_sql && $same_bind, $msg); # add debugging info if (!$same_sql) { - diag "SQL expressions differ\n" + $tb->diag("SQL expressions differ\n" ." got: $sql1\n" ."expected: $sql2\n" - ."differing in :\n$sql_differ\n"; - ; + ."differing in :\n$sql_differ\n" + ); } if (!$same_bind) { - diag "BIND values differ\n" + $tb->diag("BIND values differ\n" ." got: " . Dumper($bind_ref1) ."expected: " . Dumper($bind_ref2) - ; + ); } } @@ -160,7 +160,7 @@ SQL::Abstract::Test - Helper function for testing SQL::Abstract use SQL::Abstract; use Test::More; - use SQL::Abstract::Test qw/is_same_sql_bind/; + use SQL::Abstract::Test import => ['is_same_sql_bind']; my ($sql, @bind) = SQL::Abstract->new->select(%args); is_same_sql_bind($given_sql, \@given_bind, diff --git a/t/00new.t b/t/00new.t index ee83650..5727478 100644 --- a/t/00new.t +++ b/t/00new.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 15; diff --git a/t/01generate.t b/t/01generate.t index 2362e6c..5859c38 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 64; use SQL::Abstract; diff --git a/t/02where.t b/t/02where.t index 331ffd0..b47fdf9 100644 --- a/t/02where.t +++ b/t/02where.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; use Test::Exception; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 17; diff --git a/t/03values.t b/t/03values.t index 9cde7cd..4e9056a 100644 --- a/t/03values.t +++ b/t/03values.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 5; use SQL::Abstract; diff --git a/t/06order_by.t b/t/06order_by.t index 1cf06c9..0d922ae 100644 --- a/t/06order_by.t +++ b/t/06order_by.t @@ -6,7 +6,7 @@ use Test::More; use SQL::Abstract; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; my @cases = ( { diff --git a/t/07subqueries.t b/t/07subqueries.t index c86314f..c53d5c7 100644 --- a/t/07subqueries.t +++ b/t/07subqueries.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 5; use SQL::Abstract; diff --git a/t/08special_ops.t b/t/08special_ops.t index bbccd14..895c9c2 100644 --- a/t/08special_ops.t +++ b/t/08special_ops.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; -use SQL::Abstract::Test qw/is_same_sql_bind/; +use SQL::Abstract::Test import => ['is_same_sql_bind']; plan tests => 2; use SQL::Abstract;