correct URLs for AJAX / img requests in stexaminer
[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{
11use Text::Tradition::Collation;
12use TryCatch;
13
14use_ok( 'Text::Tradition::Stemma' );
15
16# Placeholder collation to use in tests
17my $c = Text::Tradition::Collation->new();
18
19# Try to create a bad graph
20my $baddotfh;
21open( $baddotfh, 't/data/besoin_bad.dot' ) or die "Could not open test dotfile";
22try {
23 my $stemma = Text::Tradition::Stemma->new( collation => $c, dot => $baddotfh );
24 ok( 0, "Created broken stemma from dotfile with syntax error" );
25} catch( Text::Tradition::Error $e ) {
26 like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" );
27}
28
29# Create a good graph
30my $dotfh;
31open( $dotfh, 't/data/florilegium.dot' ) or die "Could not open test dotfile";
32binmode( $dotfh, ':utf8' );
33my $stemma = Text::Tradition::Stemma->new( collation => $c, dot => $dotfh );
34is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" );
35is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" );
36is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" );
37my $found_unicode_sigil;
38foreach my $h ( $stemma->hypotheticals ) {
39 $found_unicode_sigil = 1 if $h eq "\x{3b1}";
40}
41ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" );
42}
43
44
45
46
471;