From 75843f94f259023800bf1605c1414cfefeab704f Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 21 Sep 2020 17:51:26 +0200 Subject: Test program for Week 79. --- challenge-079/abigail/test.pl | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 challenge-079/abigail/test.pl diff --git a/challenge-079/abigail/test.pl b/challenge-079/abigail/test.pl new file mode 100755 index 0000000000..578f69cc61 --- /dev/null +++ b/challenge-079/abigail/test.pl @@ -0,0 +1,48 @@ +#!/opt/perl/bin/perl + +# +# Test the solutions. Either call it with the directory name you +# want to test in, or call it as "../test.pl" from within the directory. +# + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +chdir ".." if -f "../test.pl"; + +use experimental 'signatures'; + +use Test::More; + +my %languages = ( + Perl => ["/opt/perl/bin/perl" => 'pl', 'perl'], + JavaScript => ["/usr/local/bin/node" => 'js', 'node'], +); + + +foreach my $challenge (1, 2) { + my @inputs = or next; + subtest "Challenge $challenge" => sub { + foreach my $language (sort keys %languages) { + my ($exe, $ext, $dir) = @{$languages {$language}}; + my $solution = "$dir/ch-$challenge.$ext"; + next unless -r $solution; + subtest $language => sub { + foreach my $input (@inputs) { + my $output_exp = ($input =~ s/input/output/r) . ".exp"; + my $exp = `cat $output_exp`; + my $got = `$exe ./$solution < $input`; + is $got, $exp, $input; + } + } + } + } +} + +done_testing; + + +__END__ -- cgit