X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition_collation.t;h=20ac93eb22b7d3f02bede7b7b0afda9ae44f8dac;hb=56eefa047aca3def7449cb79ac461b468b51e54c;hp=bb283fab0e6d5f1ea789f12a6c6952bfe2b5b72f;hpb=2626f7099a2e4f00962f6b33dd2ff66a7b41c5a1;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition_collation.t b/t/text_tradition_collation.t index bb283fa..20ac93e 100644 --- a/t/text_tradition_collation.t +++ b/t/text_tradition_collation.t @@ -10,6 +10,44 @@ $| = 1; { use Text::Tradition; +my $READINGS = 311; +my $PATHS = 361; + +my $datafile = 't/data/florilegium_tei_ps.xml'; +my $tradition = Text::Tradition->new( 'input' => 'TEI', + 'name' => 'test0', + 'file' => $datafile, + 'linear' => 1 ); + +ok( $tradition, "Got a tradition object" ); +is( scalar $tradition->witnesses, 13, "Found all witnesses" ); +ok( $tradition->collation, "Tradition has a collation" ); + +my $c = $tradition->collation; +is( scalar $c->readings, $READINGS, "Collation has all readings" ); +is( scalar $c->paths, $PATHS, "Collation has all paths" ); +is( scalar $c->relationships, 0, "Collation has all relationships" ); + +# Add a few relationships +$c->add_relationship( 'w123', 'w125', { 'type' => 'collated' } ); +$c->add_relationship( 'w193', 'w196', { 'type' => 'collated' } ); +$c->add_relationship( 'w257', 'w262', { 'type' => 'transposition' } ); + +# Now write it to GraphML and parse it again. + +my $graphml = $c->as_graphml; +my $st = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml ); +is( scalar $st->collation->readings, $READINGS, "Reparsed collation has all readings" ); +is( scalar $st->collation->paths, $PATHS, "Reparsed collation has all paths" ); +is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" ); +} + + + +# =begin testing +{ +use Text::Tradition; + my $cxfile = 't/data/Collatex-16.xml'; my $t = Text::Tradition->new( 'name' => 'inline',