From: Peter Rabbitson Date: Sat, 21 Mar 2009 17:26:05 +0000 (+0000) Subject: test SQLA::Test shortcommings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=56c0595d3a2f88097f6d985a3f12261632c3bf96;p=scpubgit%2FQ-Branch.git test SQLA::Test shortcommings --- diff --git a/t/10test.t b/t/10test.t index a776368..8f1ceae 100644 --- a/t/10test.t +++ b/t/10test.t @@ -97,6 +97,24 @@ my @sql_tests = ( /, ] }, + { + equal => 1, + todo => '( (x AND y) AND z ) should be reducable to ( x AND y AND z )', + statements => [ + q/SELECT foo FROM bar WHERE a = 1 AND b = 1 AND c = 1/, + q/SELECT foo FROM bar WHERE (a = 1 AND b = 1) AND c = 1/, + q/SELECT foo FROM bar WHERE a = 1 AND (b = 1 AND c = 1)/, + ] + }, + { + equal => 1, + todo => '( (x OR y) OR z ) should be reducable to ( x OR y OR z )', + statements => [ + q/SELECT foo FROM bar WHERE a = 1 OR b = 1 OR c = 1/, + q/SELECT foo FROM bar WHERE (a = 1 OR b = 1) OR c = 1/, + q/SELECT foo FROM bar WHERE a = 1 OR (b = 1 OR c = 1)/, + ] + }, # WHERE condition - different { @@ -158,6 +176,22 @@ my @sql_tests = ( q/SELECT foo FROM bar JOIN quux ON a = 1 WHERE a = 1 AND b = 1/, ] }, + { + equal => 0, + statements => [ + q/SELECT foo FROM bar WHERE a = 1 AND b = 1 OR c = 1/, + q/SELECT foo FROM bar WHERE (a = 1 AND b = 1) OR c = 1/, + q/SELECT foo FROM bar WHERE a = 1 AND (b = 1 OR c = 1)/, + ] + }, + { + equal => 0, + statements => [ + q/SELECT foo FROM bar WHERE a = 1 OR b = 1 AND c = 1/, + q/SELECT foo FROM bar WHERE (a = 1 OR b = 1) AND c = 1/, + q/SELECT foo FROM bar WHERE a = 1 OR (b = 1 AND c = 1)/, + ] + }, # JOIN condition - equal { @@ -667,15 +701,19 @@ for my $test (@sql_tests) { my $sql1 = shift @$statements; foreach my $sql2 (@$statements) { my $equal = eq_sql($sql1, $sql2); - if ($test->{equal}) { - ok($equal, "equal SQL expressions considered equal"); - } else { - ok(!$equal, "different SQL expressions considered not equal"); - } - - if ($equal ^ $test->{equal}) { - diag("sql1: $sql1"); - diag("sql2: $sql2"); + TODO: { + local $TODO = $test->{todo} if $test->{todo}; + + if ($test->{equal}) { + ok($equal, "equal SQL expressions should have been considered equal"); + } else { + ok(!$equal, "different SQL expressions should have been considered not equal"); + } + + if ($equal ^ $test->{equal}) { + diag("sql1: $sql1"); + diag("sql2: $sql2"); + } } } }