X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F3-normalize.t;h=76acb045b04b1a6f34e6fbd1bda8bb9629d9e94d;hb=HEAD;hp=b69ecd14401bcff5a8a7427ef0f1e3256eba700c;hpb=d961e39cfba23dc9edd131f4e4a73433bb1c7996;p=webpac2 diff --git a/t/3-normalize.t b/t/3-normalize.t index b69ecd1..76acb04 100755 --- a/t/3-normalize.t +++ b/t/3-normalize.t @@ -1,9 +1,11 @@ #!/usr/bin/perl -w use strict; -use blib; +use lib 'lib'; -use Test::More tests => 355; +use Test::More tests => 364; + +use utf8; BEGIN { use_ok( 'WebPAC::Test' ); @@ -55,7 +57,7 @@ my $rec2 = { } ], '700' => [ { 'a' => 'Haynal', - 'b' => 'André' + 'b' => 'André' } ], '801' => [ 'FFZG' ], '991' => [ '8302' ], @@ -78,7 +80,7 @@ my $rec2 = { 'e' => 'from Freud and Ferenczi to Michael balint', 'a' => 'Controversies in psychoanalytic method', 'g' => 'translated by Elizabeth Holder on the basisi of a first draft by Archie Hooton ; with a preface by Daniel N. Stern', - 'f' => 'by André E. Haynal' + 'f' => 'by André E. Haynal' } ], '610' => [ 'povijest psihoanalize' ], '994' => [ { @@ -798,6 +800,27 @@ sub test_s { ], ); + test_rec_rules( + 'marc_original_order and marc_indicators', + { + '200' => [ { + a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ], + subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ], + }, { + a => [ 'a3', 'a4', 'a5' ], b => 'b3', c => 'c3', + subfields => [ qw/a 0 a 1 b 0 c 0 a 2/ ], + } ], + }, + qq{ + marc_original_order(900,200); + marc_indicators(900,1,2); + }, + [ + [ '900', '1', '2', 'a', 'a1', 'b', 'b1', 'a', 'a2', 'b', 'b2', 'c', 'c1', 'c', 'c2', ], + [ '900', '1', '2', 'a', 'a3', 'a', 'a4', 'b', 'b3', 'c', 'c3', 'a', 'a5', ], + ], + ); + test_rule( 'rec1 skips subfields', { @@ -881,6 +904,8 @@ sub test_s { test_rule( 'frec', $rec, qq{ frec(200,'a') }, [ 'a1' ] ); test_rule( 'frec', $rec, qq{ frec(200,'b') }, [ 'b1' ] ); test_rule( 'frec', $rec, qq{ frec(200,'c') }, [ 'c1' ] ); + test_rule( 'frec', $rec, qq{ frec(200,'i1') }, [ '0' ] ); + test_rule( 'frec', $rec, qq{ frec(200,'i2') }, [ '1' ] ); $rec->{'900'} = $rec->{'200'}; foreach my $sf ( qw/a b c/ ) { @@ -908,13 +933,19 @@ 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" ); } + test_rule( 'utf-8' + , { '900' => [{ a => 'Čev', b => 'ić' }] } + , qq{ join_with('', rec(900,'a'), 'apč', rec(900,'b') ) } + , [ "\x{10C}evap\x{10D}i\x{107}" ] + ); + }