Merge branch 'master' of github.com:tla/stemmatology
[scpubgit/stemmatology.git] / morphology / t / text_tradition_language.t
CommitLineData
142698b8 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5$| = 1;
6
7
8
9# =begin testing
10{
11use Test::Warn;
12use TryCatch;
13use_ok( 'Text::Tradition' ); # with Language
14
15# Test setting and recovering language
16my $t = Text::Tradition->new( input => 'Self', file => 't/data/legendfrag.xml' );
475e0be8 17warning_like { $t->language( 'Klingon' ); } qr/^Cannot load any language/,
142698b8 18 "Got expected warning for setting of unsupported language";
19$t->language( 'English' );
20is( $t->language, 'English', "Successfully set supported language" );
21
22# Test bad attempt to lemmatize - proper lemmatization is tested separately
23my $bt = Text::Tradition->new( input => 'Self', file => 't/data/besoin.xml' );
24try {
25 $bt->lemmatize;
26 ok( 0, "Failed to throw error on lemmatizing without language" );
27} catch( Text::Tradition::Error $e ) {
28 is( $e->message, "Please set a language to lemmatize a tradition",
29 "Got correct error thrown for lemmatization without set language" );
30} catch {
31 ok( 0, "Unexpected error on bad lemmatization attempt" );
32}
33}
34
35
36
37
381;