r1898@llin: dpavlin | 2009-05-29 22:55:52 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 May 2009 20:55:54 +0000 (20:55 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 29 May 2009 20:55:54 +0000 (20:55 +0000)
 test rec_array and rows

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

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

index d753370..6d11324 100644 (file)
@@ -21,6 +21,9 @@ our @EXPORT = qw/
        get set
        count
 
+       row
+       rec_array
+
 /;
 
 use warnings;
index 603f170..b69ecd1 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use blib;
 
-use Test::More tests => 348;
+use Test::More tests => 355;
 
 BEGIN {
        use_ok( 'WebPAC::Test' );
@@ -866,7 +866,7 @@ sub test_s {
 
        # frec
 
-       my $rec = {
+       $rec = {
                        '200' => [ {
                                a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ],
                                subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ],
@@ -902,5 +902,19 @@ sub test_s {
        cmp_ok( _pack_subfields_hash( $hash, 1 ), 'eq', '^a[a]^b[b]', '_pack_subfields_hash' );
        ok( $hash->{subfields}, 'subfields exist' );
 
+       $rec = { 'arr' => [ 1, 2, 3 ] };
+       test_rule( 'rec_array', $rec, qq{ rec_array('arr') }, $rec->{arr} );
+
+       _clean_ds();
+       _set_ds( $rec );
+       test_s(q{
+                       row( e => $_ ) foreach ( rec_array('arr') );
+       });
+       ok( my $rows = _get_ds->{_rows}, 'ds have _rows' );
+
+       foreach my $i ( 1 .. 3 ) {
+               cmp_ok( $rows->[ $i - 1 ]->{e}, '==', $i, "e $i" );
+       }
+
 }