add support for named stemmata
[scpubgit/stemmatology.git] / analysis / t / text_tradition_stemma.t
CommitLineData
64a36834 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5$| = 1;
6
7
8
9# =begin testing
10{
64a36834 11use TryCatch;
12
13use_ok( 'Text::Tradition::Stemma' );
14
64a36834 15# Try to create a bad graph
ea45d2a6 16TODO: {
17 local $TODO = "cannot use stdout redirection trick with FastCGI";
836e0546 18 my $baddotfh;
ea45d2a6 19 open( $baddotfh, 't/data/besoin_bad.dot' ) or die "Could not open test dotfile";
20 try {
21 my $stemma = Text::Tradition::Stemma->new( dot => $baddotfh );
22 ok( 0, "Created broken stemma from dotfile with syntax error" );
23 } catch( Text::Tradition::Error $e ) {
24 like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" );
25 }
64a36834 26}
27
28# Create a good graph
29my $dotfh;
30open( $dotfh, 't/data/florilegium.dot' ) or die "Could not open test dotfile";
31binmode( $dotfh, ':utf8' );
ace5fce5 32my $stemma = Text::Tradition::Stemma->new( dot => $dotfh );
64a36834 33is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" );
34is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" );
35is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" );
f96630e3 36ok( $stemma->has_identifier, "Stemma identifier was found in dot" );
37is( $stemma->identifier, 'Coislinianum lineage', "Correct stemma identifier was found in dot" );
64a36834 38my $found_unicode_sigil;
39foreach my $h ( $stemma->hypotheticals ) {
40 $found_unicode_sigil = 1 if $h eq "\x{3b1}";
41}
42ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" );
ea45d2a6 43
44# TODO Create stemma from graph, create stemma from undirected graph,
45# create stemma from incompletely-specified graph
64a36834 46}
47
48
49
50
511;