Skip to content

Commit

Permalink
Do not assume default values
Browse files Browse the repository at this point in the history
Fixes #110
  • Loading branch information
alexkalderimis committed Mar 23, 2016
1 parent 4437154 commit 8c6ab83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sum-of-multiples/Example.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use List::Util 'sum';

sub new {
my ($class, @multiples_of) = @_;
@multiples_of = (3, 5) unless @multiples_of;
die "no multiples" unless scalar @multiples_of;

bless { multiples_of => [@multiples_of] } => $class;
}
Expand Down
10 changes: 5 additions & 5 deletions sum-of-multiples/sum_of_multiples.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ can_ok $module, "new"
can_ok $module, "to"
or BAIL_OUT "Missing package $module; or missing sub to()";

is $module->new->to(1), 0, "No multiples of 3 or 5 equals zero";
is $module->new->to(4), 3, "One multiple of 3";
is $module->new->to(10), 23, "Multiples of 3 and 5";
is $module->new->to(100), 2_318, "Multiples of 3 and 5 to 100";
is $module->new->to(1000), 233_168, "A lot of multiples of 3 and 5";
is $module->new(3, 5)->to(1), 0, "No multiples of 3 or 5 equals zero";
is $module->new(3, 5)->to(4), 3, "One multiple of 3";
is $module->new(3, 5)->to(10), 23, "Multiples of 3 and 5";
is $module->new(3, 5)->to(100), 2_318, "Multiples of 3 and 5 to 100";
is $module->new(3, 5)->to(1000), 233_168, "A lot of multiples of 3 and 5";
is $module->new(7, 13, 17)->to(20), 51, "Multiples of 7, 13, 17";
is $module->new(43, 47)->to(10_000), 2_203_160, "Multiples of 43, 47";

0 comments on commit 8c6ab83

Please sign in to comment.