r937@llin: dpavlin | 2006-09-11 16:26:07 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 11 Sep 2006 14:29:01 +0000 (14:29 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 11 Sep 2006 14:29:01 +0000 (14:29 +0000)
 changed _pack_subfields_hash usage and document it

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@669 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Normalize.pm
t/3-normalize.t

index 10a5a7f..9d315ab 100644 (file)
@@ -722,7 +722,11 @@ above.
 
 =head2 _pack_subfields_hash
 
- @values = _pack_subfields_hash( $h, $include_subfields )
+ @subfields = _pack_subfields_hash( $h );
+ $subfields = _pack_subfields_hash( $h, 1 );
+
+Return each subfield value in array or pack them all together and return scalar
+with subfields (denoted by C<^>) and values.
 
 =cut
 
@@ -741,11 +745,11 @@ sub _pack_subfields_hash {
                        my $o = shift @$sfs;
                        if ($o == 0 && ref( $h->{$sf} ) ne 'ARRAY' ) {
                                # single element subfields are not arrays
-warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n";
+#warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n";
 
                                push @out, $h->{$sf};
                        } else {
-warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n";
+#warn "====> $sf $o / $#$sfs ", dump( $sfs, $h->{$sf} ), "\n";
                                push @out, $h->{$sf}->[$o];
                        }
                }
index a576c73..e5ab7ab 100755 (executable)
@@ -691,12 +691,13 @@ sub test_s {
                '_pack_subfields_hash( $h )'
        );
 
-       is_deeply(
-               _pack_subfields_hash({
+       cmp_ok(
+               _pack_subfields_hash({
                        a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ],
                        subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ],
-               }, 1) ],
-               ['^a','a1', '^b','b1', '^a','a2', '^b','b2', '^c','c1', '^c','c2'],
+               }, 1),
+               'eq',
+               '^aa1^bb1^aa2^bb2^cc1^cc2',
                '_pack_subfields_hash( $h, 1 )'
        );
 }