commit b4d1a053654b2a6dfb5ffbe79507fdd8e613193b
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Fri Mar 31 13:16:54 2017 +0200

    autotest: de-duplicate: use print*() in show*()
    
    this actually adds some (minimal) transformation overhead, but it makes
    the relationship clearer.

 src/run-tests.pl | 34 ++++++++++------------------------
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/src/run-tests.pl b/src/run-tests.pl
index 41a6f8b..5e44d09 100755
--- a/src/run-tests.pl
+++ b/src/run-tests.pl
@@ -339,17 +339,11 @@ sub showbox($)
        my ($bn) = @_;
 
        my ($mu, %ms) = readbox($bn);
-       print " [ $mu,\n   ";
-       my $frst = 1;
+       my @MS = ($mu);
        for my $num (sort { $a <=> $b } keys %ms) {
-               if ($frst) {
-                       $frst = 0;
-               } else {
-                       print ", ";
-               }
-               print "$num, $ms{$num}[0], \"$ms{$num}[1]\"";
+               push @MS, $num, $ms{$num}[0], $ms{$num}[1];
        }
-       print " ],\n";
+       printbox($bn, @MS);
 }
 
 # $filename
@@ -382,22 +376,14 @@ sub showstate($)
                close FILE;
                return;
        }
-       print " [ ".($hdr{'MaxPulledUid'} // "missing").", ".
-                   ($hdr{'MaxExpiredSlaveUid'} // "0").", 
".($hdr{'MaxPushedUid'} // "missing").",\n   ";
-       my $frst = 1;
+       my @T = ($hdr{'MaxPulledUid'} // "missing",
+                $hdr{'MaxExpiredSlaveUid'} // "0",
+                $hdr{'MaxPushedUid'} // "missing");
        for (@ls) {
-               if ($frst) {
-                       $frst = 0;
-               } else {
-                       print ", ";
-               }
-               if (!/^(-?\d+) (-?\d+) (.*)$/) {
-                       print "??, ??, \"??\"";
-               } else {
-                       print "$1, $2, \"$3\"";
-               }
+               /^(-?\d+) (-?\d+) (.*)$/;
+               push @T, $1, $2, $3;
        }
-       print " ],\n";
+       printstate(@T);
 }
 
 # $filename
@@ -604,7 +590,7 @@ sub printstate(@)
                } else {
                        print ", ";
                }
-               print shift(@t).", ".shift(@t).", \"".shift(@t)."\"";
+               print((shift(@t) // "??").", ".(shift(@t) // "??").", 
\"".(shift(@t) // "??")."\"");
        }
        print " ],\n";
 }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to