/[webpac2]/trunk/t/3-normalize-set.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/t/3-normalize-set.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 460 - (hide annotations)
Fri May 12 14:07:08 2006 UTC (18 years ago) by dpavlin
File MIME type: application/x-troff
File size: 2986 byte(s)
 r579@llin:  dpavlin | 2006-05-12 16:10:11 +0200
 added new normalizer, based on set functions (and easier to use, I hope)

1 dpavlin 460 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     use Test::More tests => 16;
6     use Test::Exception;
7     use Cwd qw/abs_path/;
8     use blib;
9     use File::Slurp;
10    
11     use Data::Dumper;
12    
13     BEGIN {
14     use_ok( 'WebPAC::Normalize::Set' );
15     }
16    
17     ok(my $abs_path = abs_path($0), "abs_path");
18     $abs_path =~ s#/[^/]*$#/../#;
19     #diag "abs_path: $abs_path";
20    
21     #throws_ok { new WebPAC::Normalize::XML( lookup_regex => 'foo' ) } qr/pair/, "lookup_regex without lookup";
22    
23     my $rec = {
24     '675' => [ {
25     'a' => '159.9'
26     } ],
27     '210' => [ {
28     'c' => 'New York University press',
29     'a' => 'New York',
30     'd' => 'cop. 1988'
31     } ],
32     '700' => [ {
33     'a' => 'Haynal',
34     'b' => 'AndrĂ©'
35     } ],
36     '801' => [ 'FFZG' ],
37     '991' => [ '8302' ],
38     '000' => [ 1 ],
39     '702' => [ {
40     'a' => 'Holder',
41     'b' => 'Elizabeth'
42     } ],
43     '215' => [ {
44     'c' => 'ilustr',
45     'a' => 'xix, 202 str',
46     'd' => '23cm'
47     } ],
48     '990' => [
49     '2140',
50     '88',
51     'HAY'
52     ],
53     '200' => [ {
54     'e' => 'from Freud and Ferenczi to Michael balint',
55     'a' => 'Controversies in psychoanalytic method',
56     'g' => 'translated by Elizabeth Holder on the basisi of a first draft by Archie Hooton ; with a preface by Daniel N. Stern',
57     'f' => 'by AndrĂ© E. Haynal'
58     } ],
59     '610' => [ 'povijest psihoanalize' ],
60     '994' => [ {
61     'c' => '',
62     'a' => 'PS',
63     'b' => 'MG'
64     } ],
65     '320' => [ 'Kazalo' ],
66     '101' => [ 'ENG' ],
67     '686' => [ '2140' ],
68     '300' => [ 'Prijevod djela: ' ],
69     '999' => [ { 'z' => '900' } ],
70     };
71    
72    
73     my $lookup = {
74     '00900' => [
75     'lookup vrijednost 1',
76     'lookup vrijednost 2',
77     ],
78     };
79    
80     print Dumper($rec);
81    
82     sub test {
83     print Dumper( @_ ), ("-" x 78), "\n";
84     ok( defined(@_) );
85     }
86    
87     sub test_s {
88     my $t = shift || die;
89     ok(my $v = eval "$t", "eval: $t");
90     ok(! $@, "$t == ".join("|", @{$v}));
91     }
92    
93     {
94     no strict 'subs';
95     use WebPAC::Normalize::Set;
96    
97     set_rec( $rec );
98    
99     test( join(",", rec2('200','a') ) );
100     test( join(",", rec2('200','a'), rec2('200','b') ) );
101     test( join(" * ",rec1('200'), rec1('201') ) );
102     test( rec1('200') );
103     test( regex( 's/0/o/g', rec1('200') ) );
104     test( grep { /\*/ } regex( 's/0/o/g', rec1('200') ) );
105     test( rec('999') );
106     test( rec('999','z') );
107     test(
108     join_with(" i ",
109     lookup(
110     regex( 's/^/00/',
111     rec2('999','z')
112     )
113     )
114     )
115     );
116    
117     test_s(qq{
118     tag('Title',
119     rec('200','a')
120     );
121     });
122     test_s(qq{
123     tag('Who',
124     join_with(" ",
125     rec('702','a'),
126     rec('702','b')
127     )
128     );
129     });
130    
131     test_s(qq{
132     display('Publisher',
133     rec('210','c')
134     )
135     });
136    
137     test_s(qq{
138     search('Year',
139     regex( 's/[^\\d]+//',
140     rec('210','d')
141     )
142     )
143     });
144    
145     ok(my $ds = get_ds(), "get_ds");
146     diag "ds = ", Dumper($ds);
147    
148     #my $n = read_file( "$abs_path/conf/normalize/isis_ffzg.pl" );
149     #diag "normalize code:\n$n\n";
150     #eval "$n";
151     #warn $@ if ($@);
152     }
153    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26