remove some debugging statements
[scpubgit/stemmatology.git] / t / text_tradition_parser_tabular.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 $csv = 't/data/florilegium.csv';
17my $t = Text::Tradition->new(
18 'name' => 'inline',
19 'input' => 'Tabular',
20 'file' => $csv,
21 'sep_char' => ',',
22 );
23
24is( ref( $t ), 'Text::Tradition', "Parsed florilegium CSV file" );
25
26### TODO Check these figures
27if( $t ) {
0e47f4f6 28 is( scalar $t->collation->readings, 311, "Collation has all readings" );
29 is( scalar $t->collation->paths, 361, "Collation has all paths" );
3b853983 30 is( scalar $t->witnesses, 13, "Collation has all witnesses" );
31}
b0b4421a 32
33# Check that we have the right witnesses
34my %seen_wits;
35map { $seen_wits{$_} = 0 } qw/ A B C D E F G H K P Q S T /;
36foreach my $wit ( $t->witnesses ) {
37 $seen_wits{$wit->sigil} = 1;
38}
39is( scalar keys %seen_wits, 13, "No extra witnesses were made" );
40foreach my $k ( keys %seen_wits ) {
41 ok( $seen_wits{$k}, "Witness $k still exists" );
42}
43
44# Check that the witnesses have the right texts
45foreach my $wit ( $t->witnesses ) {
46 my $origtext = join( ' ', @{$wit->text} );
47 my $graphtext = $t->collation->path_text( $wit->sigil );
48 is( $graphtext, $origtext, "Collation matches original for witness " . $wit->sigil );
49}
50
51# Check that the a.c. witnesses have the right text
52map { $seen_wits{$_} = 0 } qw/ A B C D F G H K S /;
53foreach my $k ( keys %seen_wits ) {
54 my $wit = $t->witness( $k );
55 if( $seen_wits{$k} ) {
56 ok( $wit->is_layered, "Witness $k got marked as layered" );
57 ok( $wit->has_layertext, "Witness $k has an a.c. version" );
58 my $origtext = join( ' ', @{$wit->layertext} );
59 my $acsig = $wit->sigil . $t->collation->ac_label;
861c3e27 60 my $graphtext = $t->collation->path_text( $acsig );
b0b4421a 61 is( $graphtext, $origtext, "Collation matches original a.c. for witness $k" );
62 } else {
63 ok( !$wit->is_layered, "Witness $k not marked as layered" );
64 ok( !$wit->has_layertext, "Witness $k has no a.c. version" );
65 }
66}
cc31ebaa 67
68# Check that we only have collation relationships where we need them
69is( scalar $t->collation->relationships, 3, "Redundant collations were removed" );
3b853983 70}
71
72
73
74
751;