X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F10test.t;h=19afd8f3956632f9674c06226939f8f112ba3003;hb=3b9d807ed582eaefa2ec65ee33654b5dbb537f73;hp=6e4259fe30bce22383984de6cf7e68a2b3ac0f8e;hpb=5e4361304e44378efe29ad97c4430cd5f5c0f1ba;p=scpubgit%2FQ-Branch.git diff --git a/t/10test.t b/t/10test.t index 6e4259f..19afd8f 100644 --- a/t/10test.t +++ b/t/10test.t @@ -153,7 +153,7 @@ my @sql_tests = ( }, { equal => 0, - parenthesis_significant => 1, + opts => { parenthesis_significant => 1 }, 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)/, @@ -164,7 +164,7 @@ my @sql_tests = ( }, { equal => 0, - parenthesis_significant => 1, + opts => { parenthesis_significant => 1 }, 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/, @@ -174,7 +174,7 @@ my @sql_tests = ( }, { equal => 0, - parenthesis_significant => 1, + opts => { parenthesis_significant => 1 }, statements => [ q/SELECT foo FROM bar WHERE (a = 1) AND (b = 1 OR c = 1 OR d = 1) AND (e = 1 AND f = 1)/, q/SELECT foo FROM bar WHERE a = 1 AND (b = 1 OR c = 1 OR d = 1) AND e = 1 AND (f = 1)/, @@ -260,7 +260,7 @@ my @sql_tests = ( }, { equal => 0, - parenthesis_significant => 1, + opts => { parenthesis_significant => 1 }, statements => [ q/SELECT foo FROM bar WHERE a IN (1,2,3)/, q/SELECT foo FROM bar WHERE a IN (1,3,2)/, @@ -943,14 +943,23 @@ use_ok('SQL::Abstract::Test', import => [qw( )]); for my $test (@sql_tests) { + + # this does not work on 5.8.8 and earlier :( + #local @{*SQL::Abstract::Test::}{keys %{$test->{opts}}} = map { \$_ } values %{$test->{opts}} + # if $test->{opts}; + + my %restore_globals; + + for (keys %{$test->{opts} || {} }) { + $restore_globals{$_} = ${${*SQL::Abstract::Test::}{$_}}; + ${*SQL::Abstract::Test::}{$_} = \ do { my $cp = $test->{opts}{$_} }; + } + my $statements = $test->{statements}; while (@$statements) { my $sql1 = shift @$statements; foreach my $sql2 (@$statements) { - no warnings qw/once/; # perl 5.10 is dumb - local $SQL::Abstract::Test::parenthesis_significant = $test->{parenthesis_significant} - if $test->{parenthesis_significant}; my $equal = eq_sql($sql1, $sql2); TODO: { @@ -975,6 +984,9 @@ for my $test (@sql_tests) { } } } + + ${*SQL::Abstract::Test::}{$_} = \$restore_globals{$_} + for keys %restore_globals; } for my $test (@bind_tests) {