Provides more flexiblity to test cases.
Also warn and bail out if there is an '%else' or %endif' without a
preceeding '%if'.
Ref: #11610
Closes #11728
Accept-Encoding: nothing
%endif
-**Note** that there can be no nested conditions. You can only do one
-conditional at a time and you can only check for a single feature in it.
+Nested conditions are supported.
# Variables
my $show = 1;
my @out;
my $data_crlf;
+ my @pshow;
+ my $plvl;
+ my $line;
for my $s (@entiretest) {
my $f = $s;
+ $line++;
if($s =~ /^ *%if (.*)/) {
my $cond = $1;
my $rev = 0;
$rev = 1;
}
$rev ^= $feature{$cond} ? 1 : 0;
+ push @pshow, $show; # push the previous state
+ $plvl++;
$show = $rev;
next;
}
elsif($s =~ /^ *%else/) {
+ if(!$plvl) {
+ print STDERR "error: test$testnum:$line: %else no %if\n";
+ last;
+ }
$show ^= 1;
next;
}
elsif($s =~ /^ *%endif/) {
- $show = 1;
+ if(!$plvl--) {
+ print STDERR "error: test$testnum:$line: %endif had no %if\n";
+ last;
+ }
+ $show = pop @pshow;
next;
}
if($show) {