fix graphml subgraph generation; fix tab parsing to only set 'collated' where needed...
[scpubgit/stemmatology.git] / t / text_tradition_parser_self.t
index 997b5ec..612cf1e 100644 (file)
@@ -20,12 +20,34 @@ my $t = Text::Tradition->new(
     'file'  => $tradition,
     );
 
-is( ref( $t ), 'Text::Tradition', "Parsed our own GraphML" );
+is( ref( $t ), 'Text::Tradition', "Parsed GraphML version 2" );
 if( $t ) {
     is( scalar $t->collation->readings, 319, "Collation has all readings" );
     is( scalar $t->collation->paths, 376, "Collation has all paths" );
     is( scalar $t->witnesses, 13, "Collation has all witnesses" );
 }
+
+# TODO add a relationship, write graphml, reparse it, check that the rel
+# is still there
+$t->language('Greek');
+$t->collation->add_relationship( 'w12', 'w13', 
+       { 'type' => 'grammatical', 'scope' => 'global', 
+         'annotation' => 'This is some note' } );
+ok( $t->collation->get_relationship( 'w12', 'w13' ), "Relationship set" );
+my $graphml_str = $t->collation->as_graphml;
+
+my $newt = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml_str );
+is( ref( $newt ), 'Text::Tradition', "Parsed current GraphML version" );
+if( $newt ) {
+    is( scalar $newt->collation->readings, 319, "Collation has all readings" );
+    is( scalar $newt->collation->paths, 376, "Collation has all paths" );
+    is( scalar $newt->witnesses, 13, "Collation has all witnesses" );
+    is( scalar $newt->collation->relationships, 1, "Collation has added relationship" );
+    is( $newt->language, 'Greek', "Tradition has correct language setting" );
+    my $rel = $newt->collation->get_relationship( 'w12', 'w13' );
+    ok( $rel, "Found set relationship" );
+    is( $rel->annotation, 'This is some note', "Relationship has its properties" );
+}
 }