Commits

Anonymous committed 3073c86

More refactoring of the formatting code.

Comments (0)

Files changed (1)

modules/Test-Shlomif-Harness/lib/Test/Shlomif/Harness/Obj.pm

     return length($self->_get_format_failed_str());
 }
 
-sub _get_int_max_namelen
+sub __max_num
+{
+    my ($self, $max, $others )= @_;
+    foreach my $n (@$others)
+    {
+        $max = $n if $n > $max;
+    }
+    return $max;
+}
+
+sub _get_format_tests_namelens
+{
+    my $self = shift;
+    return [map { length($_->{name}) } values(%{$self->failed_tests()})];
+}
+
+sub _get_initial_max_namelen
 {
     my $self = shift;
     # Figure out our longest name string for formatting purposes.
-    my $max_namelen = $self->_get_format_failed_str_len();
-    foreach my $script_data (values(%{$self->failed_tests()}))
-    {
-        my $namelen = length($script_data->{name});
-        $max_namelen = $namelen if $namelen > $max_namelen;
-    }
-
-    return $max_namelen;    
+    return 
+        $self->__max_num(
+            $self->_get_format_failed_str_len(),
+            $self->_get_format_tests_namelens(),
+        );
 }
 
 sub _get_format_widths
     my $middle_str = $self->_get_format_middle_str();
     my $list_str = $self->_get_format_list_str();
 
-    my $max_namelen = $self->_get_int_max_namelen();
+    my $max_namelen = $self->_get_initial_max_namelen();
 
     my $list_len = $Columns - length($middle_str) - $max_namelen;
     if ($list_len < length($list_str)) {