1N/A#!./perl
1N/A
1N/A#
1N/A# test the logical operators '&&', '||', '!', 'and', 'or', 'not'
1N/A#
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A @INC = '../lib';
1N/A}
1N/A
1N/Aprint "1..7\n";
1N/A
1N/Amy $test = 0;
1N/Afor my $i (undef, 0 .. 2, "", "0 but true") {
1N/A my $true = 1;
1N/A my $false = 0;
1N/A for my $j (undef, 0 .. 2, "", "0 but true") {
1N/A $true &&= !(
1N/A ((!$i || !$j) != !($i && $j))
1N/A or (!($i || $j) != (!$i && !$j))
1N/A or (!!($i || $j) != !(!$i && !$j))
1N/A or (!(!$i || !$j) != !!($i && $j))
1N/A );
1N/A $false ||= (
1N/A ((!$i || !$j) == !!($i && $j))
1N/A and (!!($i || $j) == (!$i && !$j))
1N/A and ((!$i || $j) == ($i && !$j))
1N/A and (($i || !$j) != (!$i && $j))
1N/A );
1N/A }
1N/A if (not $true) {
1N/A print "not ";
1N/A } elsif ($false) {
1N/A print "not ";
1N/A }
1N/A print "ok ", ++$test, "\n";
1N/A}
1N/A
1N/A# $test == 6
1N/Amy $i = 0;
1N/A(($i ||= 1) &&= 3) += 4;
1N/Aprint "not " unless $i == 7;
1N/Aprint "ok ", ++$test, "\n";