marc_template
/);
+use Storable qw/dclone/;
+
=head1 NAME
WebPAC::Normalize - describe normalisaton rules using sets
warn "## _pack_subfields_hash( ",dump(@_), " )\n" if ($debug > 1);
- my ($h,$include_subfields) = @_;
+ my ($hash,$include_subfields) = @_;
# sanity and ease of use
- return $h if (ref($h) ne 'HASH');
+ return $hash if (ref($hash) ne 'HASH');
+
+ my $h = dclone( $hash );
if ( defined($h->{subfields}) ) {
my $sfs = delete $h->{subfields} || die "no subfields?";
use strict;
use blib;
-use Test::More tests => 344;
+use Test::More tests => 348;
BEGIN {
use_ok( 'WebPAC::Test' );
test_rule( 'rec(200,i1)', $rec, qq{ rec(200,'i1') }, [ '0' ] );
test_rule( 'rec(200,i2)', $rec, qq{ rec(200,'i2') }, [ '1' ] );
+ my $hash = { a => '[a]', 'b' => '[b]', subfields => [ 'a', 0, 'b', 0 ] };
+ is_deeply([ _pack_subfields_hash( $hash ) ], [ '[a]', '[b]' ], '_pack_subfields_hash' );
+ ok( $hash->{subfields}, 'subfields exist' );
+ cmp_ok( _pack_subfields_hash( $hash, 1 ), 'eq', '^a[a]^b[b]', '_pack_subfields_hash' );
+ ok( $hash->{subfields}, 'subfields exist' );
+
}