document rec_array and fix tests
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 2 Jun 2009 13:14:59 +0000 (13:14 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 2 Jun 2009 13:14:59 +0000 (13:14 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1214 07558da8-63fa-0310-ba24-9fe276d99e06

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

index 49ba7a3..ff14736 100644 (file)
@@ -153,12 +153,6 @@ sub _set_ds {
 
 sub _get_rec { $rec };
 
-sub rec_array {
-       my $d = $rec->{ $_[0] };
-       return @$d if ref($d) eq 'ARRAY';
-       die "field $_[0] not array: ",dump( $d );
-}
-
 =head2 _set_config
 
 Set current config hash
@@ -956,5 +950,21 @@ sub count {
        return @_ . '';
 }
 
+=head2 rec_array
+
+Always return field as array
+
+  foreach my $d ( rec_array('field') {
+       warn $d;
+  }
+
+=cut
+
+sub rec_array {
+       my $d = $rec->{ $_[0] };
+       return @$d if ref($d) eq 'ARRAY';
+       return ($d);
+}
+
 # END
 1;
index b69ecd1..0eb6f2a 100755 (executable)
@@ -908,9 +908,9 @@ sub test_s {
        _clean_ds();
        _set_ds( $rec );
        test_s(q{
-                       row( e => $_ ) foreach ( rec_array('arr') );
+                       row( 'table', e => $_ ) foreach ( rec_array('arr') );
        });
-       ok( my $rows = _get_ds->{_rows}, 'ds have _rows' );
+       ok( my $rows = _get_ds->{_rows}->{table}, 'ds have _rows' );
 
        foreach my $i ( 1 .. 3 ) {
                cmp_ok( $rows->[ $i - 1 ]->{e}, '==', $i, "e $i" );