Commit | Line | Data |
7f52eac8 |
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 | |
f00cefe8 |
21 | my %expected_genealogical = ( |
a44aaf2a |
22 | 1 => 0, |
f00cefe8 |
23 | 2 => 1, |
a44aaf2a |
24 | 3 => 0, |
25 | 5 => 0, |
26 | 7 => 0, |
27 | 8 => 0, |
28 | 10 => 0, |
f00cefe8 |
29 | 13 => 1, |
a44aaf2a |
30 | 33 => 0, |
31 | 34 => 0, |
32 | 37 => 0, |
33 | 60 => 0, |
f00cefe8 |
34 | 81 => 1, |
a44aaf2a |
35 | 84 => 0, |
36 | 87 => 0, |
37 | 101 => 0, |
38 | 102 => 0, |
f00cefe8 |
39 | 122 => 1, |
a44aaf2a |
40 | 157 => 0, |
f00cefe8 |
41 | 166 => 1, |
42 | 169 => 1, |
a44aaf2a |
43 | 200 => 0, |
f00cefe8 |
44 | 216 => 1, |
45 | 217 => 1, |
46 | 219 => 1, |
47 | 241 => 1, |
48 | 242 => 1, |
49 | 243 => 1, |
50 | ); |
51 | |
7e17346f |
52 | my $data = run_analysis( $tradition, calcdsn => 'dbi:SQLite:dbname=t/data/analysis.db' ); |
7234b01d |
53 | my $c = $tradition->collation; |
f00cefe8 |
54 | foreach my $row ( @{$data->{'variants'}} ) { |
a44aaf2a |
55 | # Account for rows that used to be "not useful" |
56 | unless( exists $expected_genealogical{$row->{'id'}} ) { |
57 | $expected_genealogical{$row->{'id'}} = 1; |
58 | } |
18f48b82 |
59 | my $gen_bool = $row->{'genealogical'} ? 1 : 0; |
60 | is( $gen_bool, $expected_genealogical{$row->{'id'}}, |
f00cefe8 |
61 | "Got correct genealogical flag for row " . $row->{'id'} ); |
7234b01d |
62 | # Check that we have the right row with the right groups |
63 | my $rank = $row->{'id'}; |
64 | foreach my $rdghash ( @{$row->{'readings'}} ) { |
65 | # Skip 'readings' that aren't really |
66 | next unless $c->reading( $rdghash->{'readingid'} ); |
67 | # Check the rank |
68 | is( $c->reading( $rdghash->{'readingid'} )->rank, $rank, |
69 | "Got correct reading rank" ); |
70 | # Check the witnesses |
71 | my @realwits = sort $c->reading_witnesses( $rdghash->{'readingid'} ); |
72 | my @sgrp = sort @{$rdghash->{'group'}}; |
73 | is_deeply( \@sgrp, \@realwits, "Reading analyzed with correct groups" ); |
74 | } |
f00cefe8 |
75 | } |
a44aaf2a |
76 | is( $data->{'variant_count'}, 58, "Got right total variant number" ); |
b4cb2d60 |
77 | # TODO Make something meaningful of conflict count, maybe test other bits |
7f52eac8 |
78 | } |
79 | |
80 | |
81 | |
82 | |
83 | 1; |