Collect all hacks for Graph::Reader::Dot into a single utility. Fixes #15
[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
02b6340e 16try {
11954259 17 my $stemma = Text::Tradition::Stemma->new( dotfile => 't/data/besoin_bad.dot' );
02b6340e 18 ok( 0, "Created broken stemma from dotfile with syntax error" );
19} catch( Text::Tradition::Error $e ) {
20 like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" );
64a36834 21}
22
23# Create a good graph
11954259 24my $stemma = Text::Tradition::Stemma->new( dotfile => 't/data/florilegium.dot' );
64a36834 25is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" );
26is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" );
27is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" );
f96630e3 28ok( $stemma->has_identifier, "Stemma identifier was found in dot" );
29is( $stemma->identifier, 'Coislinianum lineage', "Correct stemma identifier was found in dot" );
64a36834 30my $found_unicode_sigil;
31foreach my $h ( $stemma->hypotheticals ) {
32 $found_unicode_sigil = 1 if $h eq "\x{3b1}";
33}
34ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" );
ea45d2a6 35
cb741417 36# Create an undirected graph
11954259 37my $udstemma = Text::Tradition::Stemma->new( dotfile => 't/data/besoin_undirected.dot' );
cb741417 38is( ref( $udstemma ), 'Text::Tradition::Stemma', "Created stemma from undirected dotfile" );
39is( scalar $udstemma->witnesses, 13, "Found correct number of extant witnesses" );
40is( scalar $udstemma->hypotheticals, 12, "Found correct number of hypotheticals" );
41ok( $udstemma->is_undirected, "Stemma was recorded as undirected" );
6665a327 42is( $udstemma->identifier, "RHM stemma", "Undirected graph retained its name" );
64a36834 43}
44
45
46
47
481;