4 use Test::More 'no_plan';
16 my $datafile = 't/data/florilegium_tei_ps.xml';
17 my $tradition = Text::Tradition->new( 'input' => 'TEI',
22 ok( $tradition, "Got a tradition object" );
23 is( scalar $tradition->witnesses, 13, "Found all witnesses" );
24 ok( $tradition->collation, "Tradition has a collation" );
26 my $c = $tradition->collation;
27 is( scalar $c->readings, $READINGS, "Collation has all readings" );
28 is( scalar $c->paths, $PATHS, "Collation has all paths" );
29 is( scalar $c->relationships, 0, "Collation has all relationships" );
31 # Add a few relationships
32 $c->add_relationship( 'w123', 'w125', { 'type' => 'collated' } );
33 $c->add_relationship( 'w193', 'w196', { 'type' => 'collated' } );
34 $c->add_relationship( 'w257', 'w262', { 'type' => 'transposition' } );
36 # Now write it to GraphML and parse it again.
38 my $graphml = $c->as_graphml;
39 my $st = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml );
40 is( scalar $st->collation->readings, $READINGS, "Reparsed collation has all readings" );
41 is( scalar $st->collation->paths, $PATHS, "Reparsed collation has all paths" );
42 is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" );
51 my $cxfile = 't/data/Collatex-16.xml';
52 my $t = Text::Tradition->new(
54 'input' => 'CollateX',
57 my $c = $t->collation;
60 my $table = $c->alignment_table;
61 ok( $c->has_cached_table, "Alignment table was cached" );
62 is( $c->alignment_table, $table, "Cached table returned upon second call" );
64 is( $c->alignment_table, $table, "Cached table retained with no rank change" );
65 $c->add_relationship( 'n9', 'n23', { 'type' => 'spelling' } );
66 isnt( $c->alignment_table, $table, "Alignment table changed after relationship add" );
75 my $cxfile = 't/data/Collatex-16.xml';
76 my $t = Text::Tradition->new(
78 'input' => 'CollateX',
81 my $c = $t->collation;
83 isnt( $c->reading('n23')->rank, $c->reading('n9')->rank, "Rank skew exists" );
84 $c->add_relationship( 'n23', 'n9', { 'type' => 'collated', 'scope' => 'local' } );
85 is( scalar $c->relationships, 4, "Found all expected relationships" );
86 $c->remove_collations;
87 is( scalar $c->relationships, 3, "Collated relationships now gone" );
88 is( $c->reading('n23')->rank, $c->reading('n9')->rank, "Aligned ranks were preserved" );
97 my $cxfile = 't/data/Collatex-16.xml';
98 my $t = Text::Tradition->new(
100 'input' => 'CollateX',
103 my $c = $t->collation;
105 my @common = $c->calculate_common_readings();
106 is( scalar @common, 8, "Found correct number of common readings" );
107 my @marked = sort $c->common_readings();
108 is( scalar @common, 8, "All common readings got marked as such" );
109 my @expected = qw/ n1 n12 n16 n19 n20 n5 n6 n7 /;
110 is_deeply( \@marked, \@expected, "Found correct list of common readings" );
119 my $cxfile = 't/data/Collatex-16.xml';
120 my $t = Text::Tradition->new(
122 'input' => 'CollateX',
125 my $c = $t->collation;
127 is( $c->common_predecessor( 'n9', 'n23' )->id,
128 'n20', "Found correct common predecessor" );
129 is( $c->common_successor( 'n9', 'n23' )->id,
130 '#END#', "Found correct common successor" );
132 is( $c->common_predecessor( 'n19', 'n17' )->id,
133 'n16', "Found correct common predecessor for readings on same path" );
134 is( $c->common_successor( 'n21', 'n26' )->id,
135 '#END#', "Found correct common successor for readings on same path" );