aboutsummaryrefslogtreecommitdiff
path: root/challenge-078/abigail/test.pl
blob: 115e570c622e264e6a7315edd4e8d52657173bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/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 %languages = (
    Perl        =>   ["/opt/perl/bin/perl"  => 'pl'],
    JavaScript  =>   ["/usr/local/bin/node" => 'js'],
);


my @inputs = <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;


__END__