[Bast-commits] r5217 - in SQL-Abstract/1.x/branches/1.50_RC: .
lib/SQL/Abstract
norbi at dev.catalyst.perl.org
norbi at dev.catalyst.perl.org
Fri Nov 28 08:26:34 GMT 2008
Author: norbi
Date: 2008-11-28 08:26:34 +0000 (Fri, 28 Nov 2008)
New Revision: 5217
Modified:
SQL-Abstract/1.x/branches/1.50_RC/
SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm
Log:
r5283 at vger: mendel | 2008-11-28 09:26:25 +0100
* Replaced eq_bind() implementation to use Test::Deep::eq_deeply().
Property changes on: SQL-Abstract/1.x/branches/1.50_RC
___________________________________________________________________
Name: svk:merge
- 4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC:5276
+ 4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC:5283
Modified: SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm 2008-11-26 23:04:52 UTC (rev 5216)
+++ SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm 2008-11-28 08:26:34 UTC (rev 5217)
@@ -6,6 +6,8 @@
use Scalar::Util qw(looks_like_number blessed reftype);
use Data::Dumper;
use Carp;
+use Test::Builder;
+use Test::Deep qw(eq_deeply);
our @EXPORT_OK = qw/&is_same_sql_bind &eq_sql &eq_bind
$case_sensitive $sql_differ/;
@@ -45,58 +47,7 @@
sub eq_bind {
my ($bind_ref1, $bind_ref2) = @_;
- my $ref1 = ref $bind_ref1;
- my $ref2 = ref $bind_ref2;
-
- return 0 if $ref1 ne $ref2;
-
- if ($ref1 eq 'SCALAR' || $ref1 eq 'REF') {
- return eq_bind($$bind_ref1, $$bind_ref2);
- } elsif ($ref1 eq 'ARRAY') {
- return 0 if scalar @$bind_ref1 != scalar @$bind_ref2;
- for (my $i = 0; $i < @$bind_ref1; $i++) {
- return 0 if !eq_bind($bind_ref1->[$i], $bind_ref2->[$i]);
- }
- return 1;
- } elsif ($ref1 eq 'HASH') {
- return
- eq_bind(
- [sort keys %$bind_ref1],
- [sort keys %$bind_ref2]
- )
- && eq_bind(
- [map { $bind_ref1->{$_} } sort keys %$bind_ref1],
- [map { $bind_ref2->{$_} } sort keys %$bind_ref2]
- );
- } else {
- if (!defined $bind_ref1 || !defined $bind_ref2) {
- return !(defined $bind_ref1 ^ defined $bind_ref2);
- } elsif (blessed($bind_ref1) || blessed($bind_ref2)) {
- return 0 if (blessed($bind_ref1) || "") ne (blessed($bind_ref2) || "");
- return 1 if $bind_ref1 == $bind_ref2; # uses overloaded '=='
- # fallback: compare the guts of the object
- my $reftype1 = reftype $bind_ref1;
- my $reftype2 = reftype $bind_ref2;
- return 0 if $reftype1 ne $reftype2;
- if ($reftype1 eq 'SCALAR' || $reftype1 eq 'REF') {
- $bind_ref1 = $$bind_ref1;
- $bind_ref2 = $$bind_ref2;
- } elsif ($reftype1 eq 'ARRAY') {
- $bind_ref1 = [@$bind_ref1];
- $bind_ref2 = [@$bind_ref2];
- } elsif ($reftype1 eq 'HASH') {
- $bind_ref1 = {%$bind_ref1};
- $bind_ref2 = {%$bind_ref2};
- } else {
- return 0;
- }
- return eq_bind($bind_ref1, $bind_ref2);
- } elsif (looks_like_number($bind_ref1) && looks_like_number($bind_ref2)) {
- return $bind_ref1 == $bind_ref2;
- } else {
- return $bind_ref1 eq $bind_ref2;
- }
- }
+ return eq_deeply($bind_ref1, $bind_ref2);
}
sub eq_sql {
More information about the Bast-commits
mailing list