74428ef98545dcc15623dfbb032e0f3ea22205df
[scpubgit/stemmatology.git] / t / text_tradition_analysis.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More 'no_plan';
5 $| = 1;
6
7
8
9 # =begin testing
10 {
11 use Text::Tradition;
12 use Text::Tradition::Analysis qw/ run_analysis analyze_variant_location /;
13
14 my $datafile = 't/data/florilegium_tei_ps.xml';
15 my $tradition = Text::Tradition->new( 'input' => 'TEI',
16                                       'name' => 'test0',
17                                       'file' => $datafile );
18 my $s = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
19 is( ref( $s ), 'Text::Tradition::Stemma', "Added stemma to tradition" );
20
21 my %expected_genealogical = (
22         1 => 0,
23         2 => 1,
24         3 =>  0,
25         5 =>  0,
26         7 =>  0,
27         8 =>  0,
28         10 => 0,
29         13 => 1,
30         33 => 0,
31         34 => 0,
32         37 => 0,
33         60 => 0,
34         81 => 1,
35         84 => 0,
36         87 => 0,
37         101 => 0,
38         102 => 0,
39         122 => 1,
40         157 => 0,
41         166 => 1,
42         169 => 1,
43         200 => 0,
44         216 => 1,
45         217 => 1,
46         219 => 1,
47         241 => 1,
48         242 => 1,
49         243 => 1,
50 );
51
52 my $data = run_analysis( $tradition );
53 foreach my $row ( @{$data->{'variants'}} ) {
54         # Account for rows that used to be "not useful"
55         unless( exists $expected_genealogical{$row->{'id'}} ) {
56                 $expected_genealogical{$row->{'id'}} = 1;
57         }
58         is( $row->{'genealogical'}, $expected_genealogical{$row->{'id'}}, 
59                 "Got correct genealogical flag for row " . $row->{'id'} );
60 }
61 is( $data->{'variant_count'}, 58, "Got right total variant number" );
62 # TODO Make something meaningful of conflict count, maybe test other bits
63 }
64
65
66
67
68 1;