remove some debugging statements
[scpubgit/stemmatology.git] / t / lexeme_serialize.t
1 use lib 'lib';
2 use strict;
3 use warnings;
4 use Test::More;
5 use Text::Tradition;
6
7 eval "use Flemm";
8 plan skip_all => "Flemm 3.1 required" if $@;
9
10 binmode( STDOUT, ':utf8' );
11 binmode( STDERR, ':utf8' );
12
13 my $tf = Text::Tradition->new(
14         'input' => 'Self',
15         'file' => 't/data/besoin.xml',
16         'language' => 'French' );
17         
18 $tf->lemmatize();
19 my $graphmlstr = $tf->collation->as_graphml;
20 like( $graphmlstr, qr/graphml xmlns/, 
21         "Serialized tradition after lemmatization" );
22
23 my $tf2 = Text::Tradition->new(
24         input => 'Self',
25         string => $graphmlstr,
26         language => 'French' );
27
28 is( ref $tf2, 'Text::Tradition', "Re-parsed tradition with lemmatization" );
29 is( $tf->name, $tf2->name, "Traditions have same name" );
30 foreach my $r ( $tf->collation->readings ) {
31         my $r2 = $tf2->collation->reading( $r->id );
32         is( ref $r2, 'Text::Tradition::Collation::Reading',
33                 "Reading $r exists in new tradition" );
34         if( $r2 ) {
35                 is( scalar $r->lexemes, scalar $r2->lexemes,
36                         "Same number of lexemes in new tradition for $r" );
37         }
38 }
39
40 # Test a snippet of tradition with possibly-problematic saved lexemes
41 my $tf3 = Text::Tradition->new(
42         'input' => 'Self',
43         'file' => 't/data/lexformat.xml' );
44 is( ref $tf3, 'Text::Tradition', 
45         "Successfully parsed tradition with incomplete lexemes" );
46
47 done_testing();