load XML::LibXML only when required; handle global relationships more correctly;...
[scpubgit/stemmatology.git] / t / analysis.t
index d22a91b..b9e9d83 100755 (executable)
@@ -17,9 +17,6 @@ my $tradition = Text::Tradition->new(
        'file' => 't/data/besoin.xml' );
 $tradition->add_stemma( 'dotfile' => 't/data/besoin.dot' );
 
-# Hack to avoid warning
-$tradition->collation->add_relationship( '493,2', '493,3', {'type'=>'orthographic'} );
-
 # Run the analysis of the tradition
 my $results = run_analysis( $tradition );
 
@@ -133,15 +130,15 @@ foreach my $row ( @{$results->{'variants'}} ) {
                        my %is_parent;
                        my @has_no_parent;
                        foreach my $rdg ( @{$row->{'readings'}} ) {
-                               my $parents = $rdg->{'reading_parents'} || [];
-                               foreach my $p ( @$parents ) {
+                               my $parents = $rdg->{'reading_parents'} || {};
+                               foreach my $p ( keys %$parents ) {
                                        push( @{$is_parent{$p}}, $rdg->{'readingid'} );
                                }
-                               push( @has_no_parent, $rdg->{'readingid'} ) unless @$parents;
+                               push( @has_no_parent, $rdg->{'readingid'} ) unless keys %$parents;
                        }
                        # Test some stuff
                        foreach my $rdg ( @{$row->{'readings'}} ) {
-                               is( $rdg->{'independent_occurrence'}, 1, 
+                               is( @{$rdg->{'independent_occurrence'}}, 1, 
                                        "Genealogical reading originates exactly once" );
                        }
                        is( @has_no_parent, 1, "Only one genealogical reading lacks a parent" );