4 use Test::More 'no_plan';
15 binmode STDOUT, ":utf8";
16 binmode STDERR, ":utf8";
17 eval { no warnings; binmode $DB::OUT, ":utf8"; };
19 my $tradition = 't/data/florilegium_graphml.xml';
20 my $t = Text::Tradition->new(
26 ok( $t->$_isa('Text::Tradition'), "Parsed GraphML version 2" );
28 is( scalar $t->collation->readings, 319, "Collation has all readings" );
29 is( scalar $t->collation->paths, 376, "Collation has all paths" );
30 is( scalar $t->witnesses, 13, "Collation has all witnesses" );
33 # TODO add a relationship, add a stemma, write graphml, reparse it, check that
34 # the new data is there
35 my $language_enabled = $t->can('language');
36 if( $language_enabled ) {
37 $t->language('Greek');
39 my $stemma_enabled = $t->can('add_stemma');
40 if( $stemma_enabled ) {
41 $t->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
43 $t->collation->add_relationship( 'w12', 'w13',
44 { 'type' => 'grammatical', 'scope' => 'global',
45 'annotation' => 'This is some note' } );
46 ok( $t->collation->get_relationship( 'w12', 'w13' ), "Relationship set" );
47 my $graphml_str = $t->collation->as_graphml;
49 my $newt = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml_str );
50 ok( $newt->$_isa('Text::Tradition'), "Parsed current GraphML version" );
52 is( scalar $newt->collation->readings, 319, "Collation has all readings" );
53 is( scalar $newt->collation->paths, 376, "Collation has all paths" );
54 is( scalar $newt->witnesses, 13, "Collation has all witnesses" );
55 is( scalar $newt->collation->relationships, 1, "Collation has added relationship" );
56 if( $language_enabled ) {
57 is( $newt->language, 'Greek', "Tradition has correct language setting" );
59 my $rel = $newt->collation->get_relationship( 'w12', 'w13' );
60 ok( $rel, "Found set relationship" );
61 is( $rel->annotation, 'This is some note', "Relationship has its properties" );
62 if( $stemma_enabled ) {
63 is( scalar $newt->stemmata, 1, "Tradition has its stemma" );
64 is( $newt->stemma(0)->witnesses, $t->stemma(0)->witnesses, "Stemma has correct length witness list" );
68 # Test warning if we can
69 unless( $stemma_enabled ) {
72 $nst = Text::Tradition->new( 'input' => 'Self', 'file' => 't/data/lexformat.xml' );
73 } [qr/DROPPING stemmata/],
74 "Got expected stemma drop warning on parse";