prevent Tradition from association collation with stemma
[scpubgit/stemmatology.git] / 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
16my $baddotfh;
17open( $baddotfh, 't/data/besoin_bad.dot' ) or die "Could not open test dotfile";
18try {
ace5fce5 19 my $stemma = Text::Tradition::Stemma->new( dot => $baddotfh );
64a36834 20 ok( 0, "Created broken stemma from dotfile with syntax error" );
21} catch( Text::Tradition::Error $e ) {
22 like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" );
23}
24
25# Create a good graph
26my $dotfh;
27open( $dotfh, 't/data/florilegium.dot' ) or die "Could not open test dotfile";
28binmode( $dotfh, ':utf8' );
ace5fce5 29my $stemma = Text::Tradition::Stemma->new( dot => $dotfh );
64a36834 30is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" );
31is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" );
32is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" );
33my $found_unicode_sigil;
34foreach my $h ( $stemma->hypotheticals ) {
35 $found_unicode_sigil = 1 if $h eq "\x{3b1}";
36}
37ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" );
38}
39
40
41
42
431;