Core Testing Tools
Table-Driven Summary
A compact table of cases can summarize repeated checks with pass and fail counts.
Table-Driven Summary
table_driven_summary.pl
use strict;
use warnings;
my $offset = ;
my @inputs = (1, 2, 3);
my @expected = (2, 3, 4);
my $passed = 0;
my $failed = 0;
for my $index (0 .. 2) {
my $actual = $inputs[$index] + $offset;
if ($actual == $expected[$index]) {
$passed = $passed + 1;
} else {
$failed = $failed + 1;
}
}
print "offset=$offset\n";
print "passed=$passed\n";
print "failed=$failed\n";
use strict;
use warnings;
my $offset = ;
my @inputs = (1, 2, 3);
my @expected = (2, 3, 4);
my $passed = 0;
my $failed = 0;
for my $index (0 .. 2) {
my $actual = $inputs[$index] + $offset;
if ($actual == $expected[$index]) {
$passed = $passed + 1;
} else {
$failed = $failed + 1;
}
}
print "offset=$offset\n";
print "passed=$passed\n";
print "failed=$failed\n";
use strict;
use warnings;
my $offset = ;
my @inputs = (1, 2, 3);
my @expected = (2, 3, 4);
my $passed = 0;
my $failed = 0;
for my $index (0 .. 2) {
my $actual = $inputs[$index] + $offset;
if ($actual == $expected[$index]) {
$passed = $passed + 1;
} else {
$failed = $failed + 1;
}
}
print "offset=$offset\n";
print "passed=$passed\n";
print "failed=$failed\n";
table-driven-summary
Small tables make repeated checks visible while keeping the assertion logic in one place.