remove edge weight logic in dot; add adjacency list JSON output
[scpubgit/stemmatology.git] / base / t / text_tradition_parser_collatex.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
39d16d81 16# Test a simple CollateX input
e867486f 17my $cxfile = 't/data/Collatex-16.xml';
18my $t = Text::Tradition->new(
19 'name' => 'inline',
20 'input' => 'CollateX',
21 'file' => $cxfile,
22 );
23
679f17e1 24is( ref( $t ), 'Text::Tradition', "Parsed a CollateX input" );
e867486f 25if( $t ) {
26 is( scalar $t->collation->readings, 26, "Collation has all readings" );
a753cc84 27 is( scalar $t->collation->paths, 32, "Collation has all paths" );
e867486f 28 is( scalar $t->witnesses, 3, "Collation has all witnesses" );
29
30 # Check an 'identical' node
31 my $transposed = $t->collation->reading( 'n15' );
a753cc84 32 my @related = $transposed->related_readings;
33 is( scalar @related, 1, "Reading links to transposed version" );
679f17e1 34 is( $related[0]->id, 'n18', "Correct transposition link" );
e867486f 35}
39d16d81 36
37# Now test a CollateX result with a.c. witnesses
38
39my $ct = Text::Tradition->new(
40 name => 'florilegium',
41 input => 'CollateX',
42 file => 't/data/florilegium_cx.xml' );
43
44is( ref( $ct ), 'Text::Tradition', "Parsed the CollateX input" );
45if( $ct ) {
46 is( scalar $ct->collation->readings, 309, "Collation has all readings" );
47 is( scalar $ct->collation->paths, 361, "Collation has all paths" );
48 is( scalar $ct->witnesses, 13, "Collation has correct number of witnesses" );
49
50 my %layered = ( E => 1, P => 1, Q => 1, T => 1 );
51 foreach my $w ( $ct->witnesses ) {
52 is( $w->is_layered, $layered{$w->sigil},
53 "Witness " . $w->sigil . " has correct layered setting" );
54 }
55
56 my $pseq = $ct->witness('P')->text;
57 my $pseqac = $ct->witness('P')->layertext;
58 is( scalar @$pseq, 264, "Witness P has correct number of tokens" );
59 is( scalar @$pseqac, 261, "Witness P (a.c.) has correct number of tokens" );
60}
61
e867486f 62}
63
64
65
66
671;