a bit of refactor
[catagits/HTML-Zoom.git] / t / fill.t
index 5fbfbe9..beba105 100644 (file)
--- a/t/fill.t
+++ b/t/fill.t
@@ -140,6 +140,7 @@ sub code_stream (&) {
 
 {
   use Scalar::Util ();
+  
   my $next_item_from_array = sub {
     my @items = @_;
     return sub { shift @items };      
@@ -163,9 +164,10 @@ sub code_stream (&) {
   my $normalize_targets = sub {
     my $targets = shift;
     my $targets_type = ref $targets;
-    return $targets_type eq 'ARRAY' ? $targets
-      : $targets_type eq 'HASH' ? [ map { +{$_=>$targets->{$_}} } keys %$targets ]
+    return $targets_type eq 'ARRAY' ? $targets : do {
+      $targets_type eq 'HASH' ? [ map { +{$_=>$targets->{$_}} } keys %$targets ]
         : die "targets data structure ". ref($targets). " not understood";
+    }
   };
   
   my $replace_from_hash_or_object = sub {
@@ -191,9 +193,9 @@ sub code_stream (&) {
                   my $type = ref $target;
                   $type ? ($type eq 'HASH' ? do { 
                       my ($match, $value) = %$target;
-                      ref $value eq 'CODE' ?
-                        ($match, $value->($datum, $idx, $_))
-                        : ($match, $replace_from_hash_or_object->($datum, $value));
+                      ($match, ref($value) eq 'CODE' ?
+                        $value->($datum, $idx, $_)
+                        : $replace_from_hash_or_object->($datum, $value))
                     } : die "What?")
                     : do {
                         ref($datum) eq 'ARRAY' ?