[Bast-commits] r5715 - SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Mon Mar 9 01:24:35 GMT 2009


Author: ribasushi
Date: 2009-03-09 01:24:34 +0000 (Mon, 09 Mar 2009)
New Revision: 5715

Modified:
   SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm
Log:
Better handling of borked sql in tests

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	2009-03-09 00:35:23 UTC (rev 5714)
+++ SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract/Test.pm	2009-03-09 01:24:34 UTC (rev 5715)
@@ -161,15 +161,19 @@
   my ($left, $right) = @_;
 
   # ignore top-level parentheses 
-  while ($left->[0] and $left->[0]  eq 'PAREN') {$left  = $left->[1] }
-  while ($right->[0] and $right->[0] eq 'PAREN') {$right = $right->[1]}
+  while ($left and $left->[0] and $left->[0]  eq 'PAREN') {$left  = $left->[1]}
+  while ($right and $right->[0] and $right->[0] eq 'PAREN') {$right = $right->[1]}
 
-  # if both are undef i.e. ()
-  if (not grep { defined $_ } ($left->[0], $right->[0]) ) {
+  # one is defined the other not
+  if ( (defined $left) xor (defined $right) ) {
+    return 0;
+  }
+  # one is undefined, then so is the other
+  elsif (not defined $left) {
     return 1;
   }
   # if operators are different
-  elsif ($left->[0] ne $right->[0]) { 
+  elsif ($left->[0] ne $right->[0]) {
     $sql_differ = sprintf "OP [$left->[0]] != [$right->[0]] in\nleft: %s\nright: %s\n",
       unparse($left),
       unparse($right);




More information about the Bast-commits mailing list