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

offset
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";
  1. $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;
  2. $actual ← 2

    pass 1 of 3
    10for 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]$actual
    1012
    2123
    3234
  3. $passed ← 1

    pass 1 of 3
    11my $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]$passed
    1220 1
    2331 2
    3442 3
  4. print "offset=$offset ";

    19print "offset=$offset1\n";20print "passed=$passed3\n";21print "failed=$failed0\n";
    outputoffset=1
    passed=3
    failed=0
  1. $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;
  2. $actual ← 1

    pass 1 of 3
    10for 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]$actual
    1011
    2122
    3233
  3. $failed ← 1

    pass 1 of 3
    13    $passed = $passed + 1;14} else {15    $failed→ 1 = $failed + 1;16}
    All 3 passes — pass 1 is the card above
    pass$failed
    10 1
    21 2
    32 3
  4. print "offset=$offset ";

    19print "offset=$offset0\n";20print "passed=$passed0\n";21print "failed=$failed3\n";
    outputoffset=0
    passed=0
    failed=3
  1. $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;
  2. $actual ← 3

    pass 1 of 3
    10for 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]$actual
    1013
    2124
    3235
  3. $failed ← 1

    pass 1 of 3
    13    $passed = $passed + 1;14} else {15    $failed→ 1 = $failed + 1;16}
    All 3 passes — pass 1 is the card above
    pass$failed
    10 1
    21 2
    32 3
  4. print "offset=$offset ";

    19print "offset=$offset2\n";20print "passed=$passed0\n";21print "failed=$failed3\n";
    outputoffset=2
    passed=0
    failed=3