Core Testing Tools
Table-Driven Summary
A compact table of cases can summarize repeated checks with pass and fail counts.
table-driven-summary
Small tables make repeated checks visible while keeping the assertion logic in one place.
Table-Driven Summary
table_driven_summary.pl
Replay: real traced execution (multi-file project)
use strict;
use warnings;
my $offset = 1;
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 = 0;
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 = 2;
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";
$offset ← 1, @inputs ← 3, @expected ← 3, $passed ← 0, $failed ← 0
4my $offset→ 1 = 1; #@offset=0, 25my @inputs→ 3 = (1, 2, 3);6my @expected→ 3 = (2, 3, 4);7my $passed→ 0 = 0;8my $failed→ 0 = 0;$actual ← 2
pass 1 of 310for my $index0 (0 .. 2) {11 my $actual→ 2 = $inputs[$index]1 + $offset1;12 if ($actual == $expected[$index]) {All 3 passes — pass 1 is the card above pass $index$inputs[$index]$actual1 0 1 2 2 1 2 3 3 2 3 4 $passed ← 1
pass 1 of 311my $actual = $inputs[$index] + $offset;12if ($actual2 == $expected[$index]2) {13 $passed→ 1 = $passed + 1;14} else {All 3 passes — pass 1 is the card above pass $actual$expected[$index]$passed1 2 2 0 → 1 2 3 3 1 → 2 3 4 4 2 → 3 print "offset=$offset ";
19print "offset=$offset1\n";20print "passed=$passed3\n";21print "failed=$failed0\n";outputoffset=1 passed=3 failed=0
$offset ← 0, @inputs ← 3, @expected ← 3, $passed ← 0, $failed ← 0
4my $offset→ 0 = 0;5my @inputs→ 3 = (1, 2, 3);6my @expected→ 3 = (2, 3, 4);7my $passed→ 0 = 0;8my $failed→ 0 = 0;$actual ← 1
pass 1 of 310for my $index0 (0 .. 2) {11 my $actual→ 1 = $inputs[$index]1 + $offset0;12 if ($actual == $expected[$index]) {All 3 passes — pass 1 is the card above pass $index$inputs[$index]$actual1 0 1 1 2 1 2 2 3 2 3 3 $failed ← 1
pass 1 of 313 $passed = $passed + 1;14} else {15 $failed→ 1 = $failed + 1;16}All 3 passes — pass 1 is the card above pass $failed1 0 → 1 2 1 → 2 3 2 → 3 print "offset=$offset ";
19print "offset=$offset0\n";20print "passed=$passed0\n";21print "failed=$failed3\n";outputoffset=0 passed=0 failed=3
$offset ← 2, @inputs ← 3, @expected ← 3, $passed ← 0, $failed ← 0
4my $offset→ 2 = 2;5my @inputs→ 3 = (1, 2, 3);6my @expected→ 3 = (2, 3, 4);7my $passed→ 0 = 0;8my $failed→ 0 = 0;$actual ← 3
pass 1 of 310for my $index0 (0 .. 2) {11 my $actual→ 3 = $inputs[$index]1 + $offset2;12 if ($actual == $expected[$index]) {All 3 passes — pass 1 is the card above pass $index$inputs[$index]$actual1 0 1 3 2 1 2 4 3 2 3 5 $failed ← 1
pass 1 of 313 $passed = $passed + 1;14} else {15 $failed→ 1 = $failed + 1;16}All 3 passes — pass 1 is the card above pass $failed1 0 → 1 2 1 → 2 3 2 → 3 print "offset=$offset ";
19print "offset=$offset2\n";20print "passed=$passed0\n";21print "failed=$failed3\n";outputoffset=2 passed=0 failed=3