fix offset to skip records just like SQL databases do, and not position us on it
[webpac2] / t / 3-normalize.t
index 603f170..a0ebebe 100755 (executable)
@@ -1,9 +1,9 @@
 #!/usr/bin/perl -w
 
 use strict;
-use blib;
+use lib 'lib';
 
-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( 'table', e => $_ ) foreach ( rec_array('arr') );
+       });
+       ok( my $rows = _get_ds->{_rows}->{table}, 'ds have _rows' );
+
+       foreach my $i ( 1 .. 3 ) {
+               cmp_ok( $rows->[ $i - 1 ]->{e}, '==', $i, "e $i" );
+       }
+
 }