From 123febd365b7696e106df716dd78eaf8b7fc5d28 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 7 Dec 2020 15:11:04 +0100 Subject: 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. --- challenge-090/abigail/test.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; -- cgit