From 9493bd02dc3e10bea1209cd27f5c6a7603b1f521 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Wed, 29 Aug 2012 09:38:07 +0200 Subject: [PATCH] improve diagnostics of dbm_filter_util.pl by using Data::Dumper::qquote We are testing things like packed strings. If we output the bytes raw via diag we upset terminal layers expecting utf8, and generally output unreadable garbage regardless. So use Data::Dumper::qqoute() to preprocess diagnositics output. --- lib/dbm_filter_util.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/dbm_filter_util.pl b/lib/dbm_filter_util.pl index 2f8af20..0105a5c 100644 --- a/lib/dbm_filter_util.pl +++ b/lib/dbm_filter_util.pl @@ -1,5 +1,8 @@ use strict; use warnings; +use Data::Dumper; + +*qquote= *Data::Dumper::qquote; sub StoreData { @@ -36,11 +39,11 @@ sub VerifyData while (my ($k, $v) = each %$hashref) { no warnings 'uninitialized'; if ($expected{$k} eq $v) { - #diag "Match [$k][$v]"; + #diag "Match " . qquote($k) . " => " . qquote($v); delete $expected{$k} ; } else { - #diag "No Match [$k][$v]"; + #diag "No Match " . qquote($k) . " => " . qquote($v) . " want " . qquote($expected{$k}); $bad{$k} = $v; } } @@ -50,17 +53,17 @@ sub VerifyData if (keys %expected ) { $bad .=" No Match from Expected:\n" ; while (my ($k, $v) = each %expected) { - $bad .= "\t'$k' =>\t'$v'\n"; + $bad .= "\t" . qquote($k) . " => " . qquote($v) . "\n"; } } if (keys %bad ) { $bad .= "\n No Match from Actual:\n" ; while (my ($k, $v) = each %bad) { no warnings 'uninitialized'; - $bad .= "\t'$k' =>\t'$v'\n"; + $bad .= "\t" . qquote($k) . " => " . qquote($v) . "\n"; } } - diag "${bad}\n" ; + diag( "${bad}\n" ); } } -- 2.7.4