remove edge weight logic in dot; add adjacency list JSON output
[scpubgit/stemmatology.git] / base / t / text_tradition_parser_tei.t
CommitLineData
3b853983 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 $par_seg = 't/data/florilegium_tei_ps.xml';
17my $t = Text::Tradition->new(
18 'name' => 'inline',
19 'input' => 'TEI',
20 'file' => $par_seg,
21 );
22
23is( ref( $t ), 'Text::Tradition', "Parsed parallel-segmentation TEI" );
24if( $t ) {
56eefa04 25 is( scalar $t->collation->readings, 311, "Collation has all readings" );
26 is( scalar $t->collation->paths, 361, "Collation has all paths" );
3b853983 27}
f08498a5 28
29# Try to re-parse it, ensure we can use the parser twice in the same Perl
30# invocation
31
32my $t2 = Text::Tradition->new(
33 'name' => 'inline',
34 'input' => 'TEI',
35 'file' => $par_seg,
36 );
37
38is( ref( $t2 ), 'Text::Tradition', "Parsed parallel-segmentation TEI again" );
3b853983 39}
40
41
42
43# =begin testing
44{
3b853983 45use XML::LibXML;
46use XML::LibXML::XPathContext;
47use Text::Tradition::Parser::TEI;
48
49my $xml_str = '<tei><rdg wit="#A #B #C #D">some text</rdg></tei>';
50my $el = XML::LibXML->new()->parse_string( $xml_str )->documentElement;
51my $xpc = XML::LibXML::XPathContext->new( $el );
52my $obj = $xpc->find( '//rdg' );
53
54my @wits = Text::Tradition::Parser::TEI::_get_sigla( $obj );
55is( join( ' ', @wits) , "A B C D", "correctly parsed reading wit string" );
56}
57
58
59
60
611;