read lexeme info in GraphML parsing
[scpubgit/stemmatology.git] / t / text_tradition_parser_self.t
CommitLineData
e867486f 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5$| = 1;
6
7
8
9# =begin testing
10{
11use Text::Tradition;
12binmode STDOUT, ":utf8";
13binmode STDERR, ":utf8";
14eval { no warnings; binmode $DB::OUT, ":utf8"; };
15
16my $tradition = 't/data/florilegium_graphml.xml';
17my $t = Text::Tradition->new(
18 'name' => 'inline',
19 'input' => 'Self',
20 'file' => $tradition,
21 );
22
bbd064a9 23is( ref( $t ), 'Text::Tradition', "Parsed GraphML version 2" );
e867486f 24if( $t ) {
25 is( scalar $t->collation->readings, 319, "Collation has all readings" );
255875b8 26 is( scalar $t->collation->paths, 376, "Collation has all paths" );
e867486f 27 is( scalar $t->witnesses, 13, "Collation has all witnesses" );
28}
bbd064a9 29
30# TODO add a relationship, write graphml, reparse it, check that the rel
31# is still there
32$t->language('Greek');
33$t->collation->add_relationship( 'w12', 'w13',
34 { 'type' => 'grammatical', 'scope' => 'global',
35 'annotation' => 'This is some note' } );
36ok( $t->collation->get_relationship( 'w12', 'w13' ), "Relationship set" );
37my $graphml_str = $t->collation->as_graphml;
38
39my $newt = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml_str );
40is( ref( $newt ), 'Text::Tradition', "Parsed current GraphML version" );
41if( $newt ) {
42 is( scalar $newt->collation->readings, 319, "Collation has all readings" );
43 is( scalar $newt->collation->paths, 376, "Collation has all paths" );
44 is( scalar $newt->witnesses, 13, "Collation has all witnesses" );
45 is( scalar $newt->collation->relationships, 1, "Collation has added relationship" );
46 is( $newt->language, 'Greek', "Tradition has correct language setting" );
47 my $rel = $newt->collation->get_relationship( 'w12', 'w13' );
48 ok( $rel, "Found set relationship" );
49 is( $rel->annotation, 'This is some note', "Relationship has its properties" );
50}
e867486f 51}
52
53
54
55
561;