remove some debugging statements
[scpubgit/stemmatology.git] / t / text_tradition_parser_self.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 binmode STDOUT, ":utf8";
13 binmode STDERR, ":utf8";
14 eval { no warnings; binmode $DB::OUT, ":utf8"; };
15
16 my $tradition = 't/data/florilegium_graphml.xml';
17 my $t = Text::Tradition->new( 
18     'name'  => 'inline', 
19     'input' => 'Self',
20     'file'  => $tradition,
21     );
22
23 is( ref( $t ), 'Text::Tradition', "Parsed GraphML version 2" );
24 if( $t ) {
25     is( scalar $t->collation->readings, 319, "Collation has all readings" );
26     is( scalar $t->collation->paths, 376, "Collation has all paths" );
27     is( scalar $t->witnesses, 13, "Collation has all witnesses" );
28 }
29
30 # TODO add a relationship, add a stemma, write graphml, reparse it, check that 
31 # the new data is there
32 $t->language('Greek');
33 $t->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
34 $t->collation->add_relationship( 'w12', 'w13', 
35         { 'type' => 'grammatical', 'scope' => 'global', 
36           'annotation' => 'This is some note' } );
37 ok( $t->collation->get_relationship( 'w12', 'w13' ), "Relationship set" );
38 my $graphml_str = $t->collation->as_graphml;
39
40 my $newt = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml_str );
41 is( ref( $newt ), 'Text::Tradition', "Parsed current GraphML version" );
42 if( $newt ) {
43     is( scalar $newt->collation->readings, 319, "Collation has all readings" );
44     is( scalar $newt->collation->paths, 376, "Collation has all paths" );
45     is( scalar $newt->witnesses, 13, "Collation has all witnesses" );
46     is( scalar $newt->collation->relationships, 1, "Collation has added relationship" );
47     is( $newt->language, 'Greek', "Tradition has correct language setting" );
48     my $rel = $newt->collation->get_relationship( 'w12', 'w13' );
49     ok( $rel, "Found set relationship" );
50     is( $rel->annotation, 'This is some note', "Relationship has its properties" );
51     is( scalar $newt->stemmata, 1, "Tradition has its stemma" );
52     is( $newt->stemma(0)->witnesses, $t->stemma(0)->witnesses, "Stemma has correct length witness list" );
53 }
54 }
55
56
57
58
59 1;