Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15

Re: [PATCH] Make test script annotate-tests.sh handle missing authors

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:49:48

On Sat, 16 Oct 2010, Kevin Ballard wrote:
On Oct 16, 2010, at 12:34 AM, Jakub Narebski wrote:
quoted
Kevin Ballard [off-list ref] writes:
quoted
Also, I'm not a Perl programmer, so it's possible there's a better idiom
for this sort of thing.

t/annotate-tests.sh |    3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 396b965..4e37a66 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -9,6 +9,9 @@ check_count () {
	cat .result | perl -e '
		my %expect = (@ARGV);
		my %count = ();
+		while (my ($author, $count) = each %expect) {
+			$count{$author} = 0;
+		}

First, it is a very bad practice to have variables of different type
named the same way, here %count (hash) and $count (scalar, unused).
Thanks for the pointer, but $count is already used in the while loop below:

		while (my ($author, $count) = each %count) {
			my $ok;
			if ($expect{$author} != $count) {
				$bad = 1;
				$ok = "bad";
			}
			else {
				$ok = "good";
			}
			print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
		}
Hmmm... the %count hash should probably be named %actual (to complement
%expect), or %attributed (like in output).

-- 
Jakub Narebski
Poland
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help