Slide 46
Slide 46 text
Table Driven Test
TableDrivenTests - github.com/golang/go
Go
で知った話だけれどPerl
でも出来る
Example:
note "
現在の連続ヒット数を計算する関数のテスト";
my @cases = (
{ scores => [hit_single(), hit_double()], expect => 2, note => "2
連続ヒット" },
{ scores => [hit_single(), bounder_out()], expect => 0, note => "
ヒット後にゴロアウト" },
{ scores => [bounder_out(), hit_single()], expect => 1, note => "
ゴロアウト語にヒット" },
);
for my $case (@cases) {
subtest $case->{note} => sub {
my $inning = MyApp::Inning->new(scores => $case->{scores});
is $inning->hitting_streak, $note->{expect};
};
}
46 / 58