diff options
| author | Abigail <abigail@abigail.be> | 2020-12-07 15:11:04 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2020-12-07 15:11:04 +0100 |
| commit | 123febd365b7696e106df716dd78eaf8b7fc5d28 (patch) | |
| tree | 4a2526726769a0b05a10110ca202496735f4327c | |
| parent | e9e86b731cacc156b93266d997d7ff6615f695ff (diff) | |
| download | perlweeklychallenge-club-123febd365b7696e106df716dd78eaf8b7fc5d28.tar.gz perlweeklychallenge-club-123febd365b7696e106df716dd78eaf8b7fc5d28.tar.bz2 perlweeklychallenge-club-123febd365b7696e106df716dd78eaf8b7fc5d28.zip | |
Pragma 'swap-pairs', and allow language specific pragmas.
We can now prefix a pragma with '@language', to only apply for the
specific language. And we have a new pragma 'swap-pairs' with swaps
consecutive output lines before comparing it with the expected output.
| -rwxr-xr-x | challenge-090/abigail/test.pl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/challenge-090/abigail/test.pl b/challenge-090/abigail/test.pl index d9d74784f7..8971d7d938 100755 --- a/challenge-090/abigail/test.pl +++ b/challenge-090/abigail/test.pl @@ -178,7 +178,10 @@ foreach my $challenge (@challenges) { while ($exp =~ s/^\s*#%\s*(.*)\n//) { my $pragma = $1; $pragma =~ s/\s+$//; - if ($pragma =~ /^\w+$/) { + if ($pragma =~ s/^\@(\S+)\s*//) { + next unless lc ($1) eq lc ($language); + } + if ($pragma =~ /^[-\w]+$/) { $pragma {lc $pragma} = 1; next; } @@ -214,6 +217,13 @@ foreach my $challenge (@challenges) { if ($pragma {trim}) { s/^\h+//gm for $exp, $got; } + if ($pragma {"swap-pairs"}) { + my @got = split /\n/ => $got; + for (my $i = 0; $i + 1 < @got; $i += 2) { + @got [$i, $i + 1] = @got [$i + 1, $i]; + } + $got = join "\n" => @got, ""; + } is $got, $exp, $name; }} unlink $compiled if $compiled; |
