X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition_analysis.t;h=4828b68074f194d253cac7ddb1b93e32b13b3458;hb=62a39b8f5d0ae86b26350664828069a2a44f5645;hp=080ad5ebfd9958efc1e6a82f7033aa3033a092b2;hpb=7f52eac8cd00b160ea9e828790cbd093dc444feb;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition_analysis.t b/t/text_tradition_analysis.t index 080ad5e..4828b68 100644 --- a/t/text_tradition_analysis.t +++ b/t/text_tradition_analysis.t @@ -18,11 +18,63 @@ my $tradition = Text::Tradition->new( 'input' => 'TEI', my $s = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' ); is( ref( $s ), 'Text::Tradition::Stemma', "Added stemma to tradition" ); +my %expected_genealogical = ( + 1 => 0, + 2 => 1, + 3 => 0, + 5 => 0, + 7 => 0, + 8 => 0, + 10 => 0, + 13 => 1, + 33 => 0, + 34 => 0, + 37 => 0, + 60 => 0, + 81 => 1, + 84 => 0, + 87 => 0, + 101 => 0, + 102 => 0, + 122 => 1, + 157 => 0, + 166 => 1, + 169 => 1, + 200 => 0, + 216 => 1, + 217 => 1, + 219 => 1, + 241 => 1, + 242 => 1, + 243 => 1, +); + my $data = run_analysis( $tradition ); -# TODO should be 21! -is( $data->{'genealogical_count'}, 42, "Got right genealogical count" ); -is( $data->{'conflict_count'}, 17, "Got right conflict count" ); +my $c = $tradition->collation; +foreach my $row ( @{$data->{'variants'}} ) { + # Account for rows that used to be "not useful" + unless( exists $expected_genealogical{$row->{'id'}} ) { + $expected_genealogical{$row->{'id'}} = 1; + } + my $gen_bool = $row->{'genealogical'} ? 1 : 0; + is( $gen_bool, $expected_genealogical{$row->{'id'}}, + "Got correct genealogical flag for row " . $row->{'id'} ); + # Check that we have the right row with the right groups + my $rank = $row->{'id'}; + foreach my $rdghash ( @{$row->{'readings'}} ) { + # Skip 'readings' that aren't really + next unless $c->reading( $rdghash->{'readingid'} ); + # Check the rank + is( $c->reading( $rdghash->{'readingid'} )->rank, $rank, + "Got correct reading rank" ); + # Check the witnesses + my @realwits = sort $c->reading_witnesses( $rdghash->{'readingid'} ); + my @sgrp = sort @{$rdghash->{'group'}}; + is_deeply( \@sgrp, \@realwits, "Reading analyzed with correct groups" ); + } +} is( $data->{'variant_count'}, 58, "Got right total variant number" ); +# TODO Make something meaningful of conflict count, maybe test other bits }