Skip to content

Commit 3eb7e9d

Browse files
committed
Start adding tests for the Rosalind examples
1 parent 3c0db4b commit 3eb7e9d

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

t/categories/rosalind.t

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
use v6;
2+
3+
use Test;
4+
5+
plan 5;
6+
7+
subtest {
8+
plan 1;
9+
10+
my $problem = "afrq";
11+
my @authors = <grondilu>;
12+
my $expected-output = "0.532 0.75 0.914";
13+
14+
for @authors -> $author {
15+
my $name = "$problem-$author.pl";
16+
my $output = run-example($name);
17+
is($output.chomp, $expected-output, $name);
18+
}
19+
20+
}, "afrq";
21+
22+
subtest {
23+
plan 1;
24+
25+
my $problem = "aspc";
26+
my @authors = <grondilu>;
27+
my $expected-output = 42;
28+
29+
for @authors -> $author {
30+
my $name = "$problem-$author.pl";
31+
my $output = run-example($name);
32+
is($output.chomp, $expected-output, $name);
33+
}
34+
35+
}, "aspc";
36+
37+
subtest {
38+
plan 1;
39+
40+
my $problem = "cons";
41+
my @authors = <grondilu>;
42+
my $expected-output = q:to/EOD/;
43+
ATGCAACT
44+
A: 5 1 0 0 5 5 0 0
45+
C: 0 0 1 4 2 0 6 1
46+
G: 1 1 6 3 0 1 0 0
47+
T: 1 5 0 0 0 1 1 6
48+
EOD
49+
50+
for @authors -> $author {
51+
my $name = "$problem-$author.pl";
52+
my $output = run-example($name);
53+
is($output.chomp, $expected-output.chomp, $name);
54+
}
55+
56+
}, "cons";
57+
58+
subtest {
59+
plan 1;
60+
61+
my $problem = "conv";
62+
my @authors = <grondilu>;
63+
my $expected-output = q:to/EOD/;
64+
3
65+
85.03163
66+
EOD
67+
68+
for @authors -> $author {
69+
my $name = "$problem-$author.pl";
70+
my $output = run-example($name);
71+
is($output.chomp, $expected-output.chomp, $name);
72+
}
73+
74+
}, "conv";
75+
76+
subtest {
77+
plan 1;
78+
79+
my $problem = "cstr";
80+
my @authors = <grondilu>;
81+
my $expected-output = q:to/EOD/;
82+
10110
83+
10100
84+
EOD
85+
86+
for @authors -> $author {
87+
my $name = "$problem-$author.pl";
88+
my $output = run-example($name);
89+
is($output.chomp, $expected-output.chomp, $name);
90+
}
91+
92+
}, "cstr";
93+
94+
#| check examples provided by the given authors
95+
sub check-example-solutions($problem, $expected-output, @authors) {
96+
for @authors -> $author {
97+
my $name = "$problem-$author.pl";
98+
my $output = run-example($name);
99+
is($output.chomp, $expected-output, $name);
100+
}
101+
}
102+
103+
#| run the given example script
104+
sub run-example($name) {
105+
my $base-dir = "categories/rosalind";
106+
my $script-path = $base-dir ~ "/" ~ $name;
107+
my $base-cmd = "perl6 $script-path";
108+
my $output = qqx{$base-cmd};
109+
110+
return $output;
111+
}
112+
113+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)