remove some debugging statements
[scpubgit/stemmatology.git] / t / text_tradition.t
CommitLineData
331c2dbf 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5$| = 1;
6
7
8
9# =begin testing
10{
11use_ok( 'Text::Tradition', "can use module" );
12
13my $t = Text::Tradition->new( 'name' => 'empty' );
14is( ref( $t ), 'Text::Tradition', "initialized an empty Tradition object" );
15is( $t->name, 'empty', "object has the right name" );
16is( scalar $t->witnesses, 0, "object has no witnesses" );
17
18my $simple = 't/data/simple.txt';
19my $s = Text::Tradition->new(
20 'name' => 'inline',
21 'input' => 'Tabular',
22 'file' => $simple,
23 );
24is( ref( $s ), 'Text::Tradition', "initialized a Tradition object" );
25is( $s->name, 'inline', "object has the right name" );
26is( scalar $s->witnesses, 3, "object has three witnesses" );
27
331c2dbf 28my $wit_a = $s->witness('A');
29is( ref( $wit_a ), 'Text::Tradition::Witness', "Found a witness A" );
30if( $wit_a ) {
31 is( $wit_a->sigil, 'A', "Witness A has the right sigil" );
32}
33is( $s->witness('X'), undef, "There is no witness X" );
044d1e45 34ok( !exists $s->{'witnesses'}->{'X'}, "Witness key X not created" );
35
82fa4d57 36my $wit_d = $s->add_witness( 'sigil' => 'D', 'sourcetype' => 'collation' );
044d1e45 37is( ref( $wit_d ), 'Text::Tradition::Witness', "new witness created" );
38is( $wit_d->sigil, 'D', "witness has correct sigil" );
39is( scalar $s->witnesses, 4, "object now has four witnesses" );
40
41my $del = $s->del_witness( 'D' );
42is( $del, $wit_d, "Deleted correct witness" );
43is( scalar $s->witnesses, 3, "object has three witnesses again" );
44
45# TODO test initialization by witness list when we have it
331c2dbf 46}
47
48
49
56cf65bd 50# =begin testing
51{
52use Text::Tradition;
53
54my $t = Text::Tradition->new(
55 'name' => 'simple test',
56 'input' => 'Tabular',
57 'file' => 't/data/simple.txt',
58 );
59
c3c79612 60is( $t->stemma_count, 0, "No stemmas added yet" );
56cf65bd 61my $s;
9ba651b9 62ok( $s = $t->add_stemma( dotfile => 't/data/simple.dot' ), "Added a simple stemma" );
56cf65bd 63is( ref( $s ), 'Text::Tradition::Stemma', "Got a stemma object returned" );
e0d617e6 64is( $t->stemma_count, 1, "Tradition claims to have a stemma" );
65is( $t->stemma(0), $s, "Tradition hands back the right stemma" );
56cf65bd 66}
67
68
69
331c2dbf 70
711;