Skip to content

Commit 15e77c3

Browse files
committed
[cookbook] add test for 10subroutine subcategory
1 parent df763c1 commit 15e77c3

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

t/categories/cookbook/10subroutines.t

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use v6;
2+
3+
use Test;
4+
5+
plan 1;
6+
7+
subtest {
8+
plan 1;
9+
10+
my $example-name = "10-01arguments.pl";
11+
my $expected-output = q:to/EOD/;
12+
old-fashioned
13+
some parameter
14+
some parameter
15+
some parameter
16+
some parameter
17+
array
18+
elements
19+
are => pairs
20+
hash => elements
21+
this
22+
Told you it was optional!
23+
this
24+
that
25+
123
26+
123
27+
Transporting to Magrathea:
28+
Arthur
29+
Ford
30+
Ovid
31+
You gave me the integer: 3
32+
EOD
33+
34+
my $output = run-example($example-name);
35+
is($output, $expected-output, $example-name);
36+
}, "10-01arguments.pl";
37+
38+
#| run the given example script
39+
sub run-example($name, :$script-args = Nil) {
40+
my $base-dir = "categories/cookbook/10subroutines";
41+
my $script-path = $base-dir ~ "/" ~ $name;
42+
my $base-cmd = "perl6 $script-path";
43+
my $output = $script-args ?? qqx{$base-cmd \"$script-args\"}
44+
!! qqx{$base-cmd};
45+
46+
return $output;
47+
}
48+
49+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)