add witness role for collation regularization
[scpubgit/stemmatology.git] / morphology / t / text_tradition_language.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More 'no_plan';
5 $| = 1;
6
7
8
9 # =begin testing
10 {
11 use Test::Warn;
12 use TryCatch;
13 use_ok( 'Text::Tradition' ); # with Language
14
15 # Test setting and recovering language
16 my $t = Text::Tradition->new( input => 'Self', file => 't/data/legendfrag.xml' );
17 warning_like { $t->language( 'Klingon' ); } qr/^Cannot load language/,
18         "Got expected warning for setting of unsupported language";
19 $t->language( 'English' );
20 is( $t->language, 'English', "Successfully set supported language" );
21
22 # Test bad attempt to lemmatize - proper lemmatization is tested separately
23 my $bt = Text::Tradition->new( input => 'Self', file => 't/data/besoin.xml' );
24 try {
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
38 1;