develooper Front page | perl.perl5.porters | Postings from October 2012

t/test.pl warnings protection

Thread Next
From:
hv
Date:
October 25, 2012 01:00
Subject:
t/test.pl warnings protection
Message ID:
201210250709.q9P79Su27338@crypt.org
With the updates to t/op/hashassign.t in Ruslan's branch, we get a lot
of warnings now.

I'm reluctant to suggest disabling warnings in the test file, or (because
it is trying to test rather low-level stuff) switching to lexical warnings.

The bulk of the warnings are coming from eq_hash in t/test.pl, and those
at least could be reasonably easily avoided as below. Is this a reasonable
refinement of eq_hash?

Hugo
---
diff --git a/t/test.pl b/t/test.pl
index bf9269b..66245db 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -497,7 +497,10 @@ sub eq_hash {
     # Force a hash recompute if this perl's internals can cache the hash key.
     $key = "" . $key;
     if (exists $orig->{$key}) {
-      if ($orig->{$key} ne $value) {
+      if (
+        defined $orig->{$key} != defined $value
+        || (defined $value && $orig->{$key} ne $value)
+      ) {
         _print "# key ", _qq($key), " was ", _qq($orig->{$key}),
                      " now ", _qq($value), "\n";
         $fail = 1;

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About