[Bast-commits] r5998 - SQL-Abstract/1.x/trunk/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Tue Apr 28 13:29:52 GMT 2009


Author: ribasushi
Date: 2009-04-28 14:29:52 +0100 (Tue, 28 Apr 2009)
New Revision: 5998

Modified:
   SQL-Abstract/1.x/trunk/t/04modifiers.t
Log:
Add -nest tests by ldami

Modified: SQL-Abstract/1.x/trunk/t/04modifiers.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/04modifiers.t	2009-04-28 13:27:33 UTC (rev 5997)
+++ SQL-Abstract/1.x/trunk/t/04modifiers.t	2009-04-28 13:29:52 UTC (rev 5998)
@@ -338,8 +338,36 @@
   },
 );
 
-plan tests => @and_or_tests*3 + @numbered_mods*4;
+my @nest_tests = (
+ {
+   where => {a => 1, -nest => [b => 2, c => 3]},
+   stmt  => 'WHERE ( ( (b = ? OR c = ?) AND a = ? ) )',
+   bind  => [qw/2 3 1/],
+ },
+ {
+   where => {a => 1, -nest => {b => 2, c => 3}},
+   stmt  => 'WHERE ( ( (b = ? AND c = ?) AND a = ? ) )',
+   bind  => [qw/2 3 1/],
+ },
+ {
+   where => {a => 1, -or => {-nest => {b => 2, c => 3}}},
+   stmt  => 'WHERE ( ( (b = ? AND c = ?) AND a = ? ) )',
+   bind  => [qw/2 3 1/],
+ },
+ {
+   where => {a => 1, -or => {-nest => [b => 2, c => 3]}},
+   stmt  => 'WHERE ( ( (b = ? OR c = ?) AND a = ? ) )',
+   bind  => [qw/2 3 1/],
+ },
+ {
+   where => {a => 1, -nest => {-or => {b => 2, c => 3}}},
+   stmt  => 'WHERE ( ( (c = ? OR b = ?) AND a = ? ) )',
+   bind  => [qw/3 2 1/],
+ },
+);
 
+plan tests => @and_or_tests*3 + @numbered_mods*4 + @nest_tests*2;
+
 for my $case (@and_or_tests) {
   TODO: {
     local $TODO = $case->{todo} if $case->{todo};
@@ -364,8 +392,34 @@
   }
 }
 
+for my $case (@nest_tests) {
+  TODO: {
+    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 {
+      my ($stmt, @bind) = $sql->where($case->{where});
+      is_same_sql_bind(
+        $stmt,
+        \@bind,
+        $case->{stmt},
+        $case->{bind},
+      )
+        || diag "Search term:\n" . Dumper $case->{where};
+    });
+  }
+}
+
+
+
 my $w_str = "\QUse of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0\E";
 for my $case (@numbered_mods) {
+  TODO: {
+    local $TODO = $case->{todo} if $case->{todo};
+
     local $Data::Dumper::Terse = 1;
 
     my @w;
@@ -393,5 +447,6 @@
 
     is (@non_match, 0, 'All warnings match the deprecation message')
       || diag join "\n", 'Rogue warnings:', @non_match;
+  }
 }
 




More information about the Bast-commits mailing list