diff options
| author | Abigail <abigail@abigail.be> | 2020-09-21 17:51:26 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2020-09-21 17:51:26 +0200 |
| commit | 75843f94f259023800bf1605c1414cfefeab704f (patch) | |
| tree | c3f54e4dfce6ffc5ef589732cae75db63bc7ca5f | |
| parent | 5ac16ac7e9826137e0da5597e954f4992c66205d (diff) | |
| download | perlweeklychallenge-club-75843f94f259023800bf1605c1414cfefeab704f.tar.gz perlweeklychallenge-club-75843f94f259023800bf1605c1414cfefeab704f.tar.bz2 perlweeklychallenge-club-75843f94f259023800bf1605c1414cfefeab704f.zip | |
Test program for Week 79.
| -rwxr-xr-x | challenge-079/abigail/test.pl | 48 |
1 files changed, 48 insertions, 0 deletions
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 = <input-$challenge-*> 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__ |
