CC: | mjdominus [...] gmail.com |
Subject: | Neither diagnoses malformed templates nor continues gracefully, quietly producing nonsense output |
use Test::More tests => 2;
use String::Errf 0.006;
use String::Errf 'errf';
my $payload = { total_amount => 1010,
category => "sandwiches",
limit => 1000,
};
{
# Here String::Errf could warn about a malformed format string, or it could produce
# reasonable partial output, but it does neither.
my $format = join(" ",
"payment of \$%{total_amount}",
"for category '%{category}s'",
"over limit of \$%{limit;.2}f");
my $output = errf($format, $payload);
isnt($output, 'payment of $\' over limit of $1000.00', "wat");
}
{
# Here String::Errf could warn about a malformed format string, or it could produce
# reasonable partial output, but it does neither.
my $format = join(" ",
"payment of \$%{total_amount;.2}",
"for category '%{category}s'",
"over limit of \$%{limit;.2}f");
my $output = errf($format, $payload);
like($output, qr/category.*sandwiches/, "where did the literal text 'category' go?");
}