/[webpac2]/trunk/t/2-input.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

Diff of /trunk/t/2-input.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 784 by dpavlin, Wed Dec 6 23:43:45 2006 UTC revision 797 by dpavlin, Sun Feb 4 13:28:30 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use Test::More tests => 104;  use Test::More tests => 108;
4  use Test::Exception;  use Test::Exception;
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use blib;  use blib;
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11  BEGIN {  BEGIN {
12  use_ok( 'WebPAC::Input::ISIS' );  use_ok( 'WebPAC::Input::ISIS' );
13  use_ok( 'WebPAC::Input::MARC' );  use_ok( 'WebPAC::Input::MARC' );
14    use_ok( 'WebPAC::Input::Test' );
15  }  }
16    
17  my $debug = shift @ARGV;  my $debug = shift @ARGV;
# Line 105  test_start_limit($input, 3, $size, $size Line 106  test_start_limit($input, 3, $size, $size
106  test_start_limit($input, 1, $size + 2, $size);  test_start_limit($input, 1, $size + 2, $size);
107    
108  ok(my $s = $input->stats, 'stats');  ok(my $s = $input->stats, 'stats');
109  diag "stats:\n$s";  diag "stats:\n$s" if ($debug);
110    
111  $module = 'WebPAC::Input::MARC';  $module = 'WebPAC::Input::MARC';
112  diag "testing with $module";  diag "testing with $module";
# Line 119  test_after_open($input); Line 120  test_after_open($input);
120  test_fetch($input, $input->size);  test_fetch($input, $input->size);
121    
122  # test modify_record  # test modify_record
123  $module = 'WebPAC::Input::ISIS';  $module = 'WebPAC::Input::Test';
124  ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");  ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module");
125    
126    $WebPAC::Input::Test::rec = {
127            '200' => [
128                    { 'a' => '[200 a]', 'b' => '[200 b]', 'c' => '[200 c]', 'f' => '[200 f] test : test' },
129            ],
130            '900' => [
131                    { 'x' => 'foobar', },
132            ],
133    };
134    
135    $WebPAC::Input::Test::size = 42;
136    
137  ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");  ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");
138    
139    cmp_ok($input->size, '==', 42, 'size');
140    
141  ok(my $rec_p = $input->fetch, 'fetch');  ok(my $rec_p = $input->fetch, 'fetch');
142    
143  # modify_records  # modify_records
# Line 132  ok($input->open( Line 147  ok($input->open(
147          modify_records => {          modify_records => {
148                  200 => {                  200 => {
149                          '*' => { '^c' => '. ' },                          '*' => { '^c' => '. ' },
150                            '^f' => { ' : ' => ' / ' },
151                  }                  }
152          },          },
153  ), "open modify_isis (with modify_records)");  ), "open modify_isis (with modify_records)");
154    
155  ok(my $rec = $input->fetch, 'fetch');  # seek
156    throws_ok { $input->seek } qr/without/, 'seek without position';
157  cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working');  cmp_ok($input->seek(0), '==', -1, 'seek');
158    
159  diag dump($input);  my $f = $WebPAC::Input::Test::filter_coderef;
160    ok(ref($f) eq 'CODE', 'filter_coderef');
161  # break encapsulation, bad! bad!  
162  $input->{ll_db}->{record} = {  cmp_ok(
163          900 => 'foo ; bar ; baz',          $f->(   '^afoo^cbar^fbing : bong',      200),
164  };          'eq',   '^afoo. bar^fbing / bong',
165            'modify 200'
166  $input->{modify_record} = {  );
         900 => {  
                 '*' => {  
                         ' ; ' => 'a',  
                 }  
         }  
 };  
167    
 diag "hacked: ",dump($input, $input->fetch);  

Legend:
Removed from v.784  
changed lines
  Added in v.797

  ViewVC Help
Powered by ViewVC 1.1.26