--- trunk/t/2-input.t 2007/02/04 12:42:43 796 +++ trunk/t/2-input.t 2007/02/04 13:28:30 797 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::More tests => 104; +use Test::More tests => 108; use Test::Exception; use Cwd qw/abs_path/; use blib; @@ -123,21 +123,20 @@ $module = 'WebPAC::Input::Test'; ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module"); -ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)"); - $WebPAC::Input::Test::rec = { - '200' => [ { - 'a' => 'foo', - 'b' => 'bar', - }, { - 'a' => 'baz', - } ], + '200' => [ + { 'a' => '[200 a]', 'b' => '[200 b]', 'c' => '[200 c]', 'f' => '[200 f] test : test' }, + ], '900' => [ - 'foobar', - ], + { 'x' => 'foobar', }, + ], }; -ok($input->size, 'size'); +$WebPAC::Input::Test::size = 42; + +ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)"); + +cmp_ok($input->size, '==', 42, 'size'); ok(my $rec_p = $input->fetch, 'fetch'); @@ -153,33 +152,16 @@ }, ), "open modify_isis (with modify_records)"); -ok(my $rec = $input->fetch, 'fetch'); -diag "fetched rec field 200 = ", dump($rec->{200}) if ($debug); - -cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working'); - -diag "input = ",dump($input->{data}) if ($debug); - -# break encapsulation, bad! bad! -$input->{ll_db}->{_isis_db}->{record} = { - 900 => 'foo ; bar ; baz', -}; - -$input->{modify_record} = { - 900 => { - '*' => [ - { ' ; ' => 'a' }, - { ' ; ' => 'b' }, - { ' ; ' => 'c' }, - ], - } -}; - -diag "hacked: ",dump($input, $input->fetch) if ($debug); - # seek -throws_ok { $input->seek } qw/without/, 'seek without position'; +throws_ok { $input->seek } qr/without/, 'seek without position'; cmp_ok($input->seek(0), '==', -1, 'seek'); -ok(my $rec = $input->fetch, 'fetch'); -diag "fetched rec = ", dump($rec) if ($debug); +my $f = $WebPAC::Input::Test::filter_coderef; +ok(ref($f) eq 'CODE', 'filter_coderef'); + +cmp_ok( + $f->( '^afoo^cbar^fbing : bong', 200), + 'eq', '^afoo. bar^fbing / bong', + 'modify 200' +); +