--- trunk/t/3-normalize-xml.t 2006/01/07 18:23:27 352 +++ trunk/t/3-normalize-xml.t 2006/01/08 20:26:57 361 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::More tests => 84; +use Test::More tests => 92; use Test::Exception; use Cwd qw/abs_path/; use blib; @@ -163,8 +163,8 @@ ] }, }; -sub parse_test($$$) { - my ($import,$rec,$r) = @_; +sub parse_test($$$$) { + my ($import,$rec,$i,$r) = @_; $n->{import_xml}->{indexer} = $import; # erase internal cache (yak!) delete($n->{tags_by_order}); @@ -172,23 +172,53 @@ #diag "test normalisation of: ",Dumper($n->{import_xml}->{indexer}, $rec); ok(my $ds = $n->data_structure( $rec ), "data_structure"); #diag Dumper($ds); - cmp_ok($ds->{Tag}->{display}->[0], 'eq', $r, "parse $r"); + cmp_ok($ds->{Tag}->{display}->[$i], 'eq', $r, "parse $i: $r"); } -parse_test($import, $rec, '1 + 2 = 3 [yap]'); +parse_test($import, $rec, 0, '1 + 2 = 3 [yap]'); delete($rec->{'900'}->[0]->{'b'}); -parse_test($import, $rec, '1 = 3 [yap]'); +parse_test($import, $rec, 0, '1 = 3 [yap]'); $rec->{'900'}->[0]->{'b'} = 5; $rec->{'900'}->[0]->{'c'} = 6; -parse_test($import, $rec, '1 + 5 = 6 [yap]'); +parse_test($import, $rec, 0, '1 + 5 = 6 [yap]'); delete($rec->{'900'}->[0]->{'c'}); $rec->{'900'}->[0]->{'x'} = 'hmmm'; -parse_test($import, $rec, '1 + 5 [hmmm]'); +parse_test($import, $rec, 0, '1 + 5 [hmmm]'); $rec->{'900'}->[0]->{'x'} = 'nope!'; delete($rec->{'900'}->[0]->{'a'}); -parse_test($import, $rec, '5 [nope!]'); +parse_test($import, $rec, 0, '5 [nope!]'); +$rec = { + '900' => [ { + 'b' => 'b1', + 'x' => 'b1', + },{ + 'a' => 'a1', + 'b' => 'b2', + 'x' => 'a1_b2', + },{ + 'b' => 'b3', + 'c' => 'c1', + 'x' => 'b3_c1', + },{ + 'a' => 'a2', + 'b' => 'b4', + 'c' => 'c2', + 'x' => 'a2_b4_c2', + } ], +}; + +my $import = { + 'Tag' => { 'isis' => [ + { content => '0 v900^a 1 v900^b 2 v900^c 3 v900^x 4' }, + ] }, +}; + +parse_test($import, $rec, 0, '0 b1 3 b1 4'); +parse_test($import, $rec, 1, '0 a1 1 b2 3 a1_b2 4'); +parse_test($import, $rec, 2, '0 b3 2 c1 3 b3_c1 4'); +parse_test($import, $rec, 3, '0 a2 1 b4 2 c2 3 a2_b4_c2 4');