From df4aee15abcc46f8b2844b7ba035b45afa0ff31e Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 15 Sep 2020 13:26:46 +0200 Subject: Perl solutions for Week 78 --- challenge-078/abigail/test.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 challenge-078/abigail/test.pl (limited to 'challenge-078/abigail/test.pl') diff --git a/challenge-078/abigail/test.pl b/challenge-078/abigail/test.pl new file mode 100755 index 0000000000..2a0406cf31 --- /dev/null +++ b/challenge-078/abigail/test.pl @@ -0,0 +1,31 @@ +#!/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 shift if @ARGV; + +use experimental 'signatures'; + +use Test::More; + +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; +} + +done_testing; + + +__END__ -- cgit 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(-) (limited to 'challenge-078/abigail/test.pl') 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