Skip to content

Commit

Permalink
Remove method/sub checks, refactor tests, change perltidy options (ex…
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dango authored Jul 26, 2023
1 parent 45e3854 commit 576e819
Show file tree
Hide file tree
Showing 114 changed files with 962 additions and 917 deletions.
3 changes: 3 additions & 0 deletions .perltidyrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
--perl-best-practices
--nostandard-output
--ignore-side-comment-lengths
--minimum-space-to-comment=1
--novalign-side-comments
--freeze-newlines
--keep-old-breakpoints-after='('
2 changes: 0 additions & 2 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ modules:

# For exports
subs: 'foo bar'
# For class methods
methods: 'foo bar'

# This is a string containing Perl code, to be inserted before any properties
tests: |-
Expand Down
14 changes: 3 additions & 11 deletions exercises/practice/accumulate/accumulate.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use lib $Bin, "$Bin/local/lib/perl5";
use Accumulate qw<accumulate>;
use experimental qw<signatures>;

imported_ok qw<accumulate> or bail_out;

is(
accumulate( [], sub ($x) { $x * $x } ),
[],
Expand All @@ -28,21 +26,15 @@ is(
);

is(
accumulate(
[ "the", "quick", "brown", "fox", "etc" ],
sub ($x) { scalar reverse $x }
),
accumulate( [ "the", "quick", "brown", "fox", "etc" ], sub ($x) { scalar reverse $x } ),
[ "eht", "kciuq", "nworb", "xof", "cte" ],
"accumulate reversed strings",
);

is(
accumulate(
[ "a", "b", "c" ],
sub ($x) {
accumulate( [ "a", "b", "c" ], sub ($x) {
accumulate( [ 1 .. 3 ], sub ($y) { $x . $y } );
}
),
} ),
[ [ "a1", "a2", "a3" ], [ "b1", "b2", "b3" ], [ "c1", "c2", "c3" ] ],
"accumulate recursively",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ sub rebase {
}
}

return from_decimal( $output_base, to_decimal( $input_base, $digits ) );
return from_decimal( $output_base,
to_decimal( $input_base, $digits ) );
}

sub to_decimal {
Expand Down
2 changes: 0 additions & 2 deletions exercises/practice/all-your-base/all-your-base.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use lib $Bin, "$Bin/local/lib/perl5";

use AllYourBase qw<rebase>;

imported_ok qw<rebase> or bail_out;

is(
rebase( [1], 2, 10 ),
[1],
Expand Down
6 changes: 2 additions & 4 deletions exercises/practice/allergies/.meta/solutions/Allergies.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ sub allergic_to {

sub list_allergies {
my ($score) = @_;
return [
grep { allergic_to $_, $score }
keys %{ +ALLERGENS }
];
return [ grep { allergic_to $_, $score }
keys %{ +ALLERGENS } ];
}

1;
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.meta/template-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ properties:
list:
test: |-
use Data::Dmp;
sprintf(<<'END', $case->{input}{score}, 'bag {' . (join '', map {'item ' . dmp($_) . ';'} @{$case->{expected}}) . 'end;}', dmp($case->{description}));
sprintf(<<'END', $case->{input}{score}, "bag {\n" . (join '', map {'item ' . dmp($_) . ";\n"} @{$case->{expected}}) . "end;\n}", dmp($case->{description}));
is(
list_allergies(%s),
%s,
Expand Down
Loading

0 comments on commit 576e819

Please sign in to comment.