From ffbd8368ce571dab7b941dd8aa8e50f2f5678b5b Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 15 Sep 2020 14:30:29 +0200 Subject: Modify the test program so it tests Javascript solutions as well. --- challenge-078/abigail/test.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/challenge-078/abigail/test.pl b/challenge-078/abigail/test.pl index 2a0406cf31..115e570c62 100755 --- a/challenge-078/abigail/test.pl +++ b/challenge-078/abigail/test.pl @@ -17,12 +17,25 @@ use experimental 'signatures'; use Test::More; +my %languages = ( + Perl => ["/opt/perl/bin/perl" => 'pl'], + JavaScript => ["/usr/local/bin/node" => 'js'], +); + + my @inputs = ; -foreach my $input (@inputs) { - my $output_exp = ($input =~ s/input/output/r) . ".exp"; - my $exp = `cat $output_exp`; - my $got = `./solution.pl < $input`; - is $got, $exp, $input; + +foreach my $language (sort keys %languages) { + my ($exe, $ext) = @{$languages {$language}}; + next unless -r "solution.$ext"; + 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.$ext < $input`; + is $got, $exp, $input; + } + } } done_testing; -- cgit