1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# -*- cperl -*-
use strict;
use Test::More tests => 31;
BEGIN { use_ok("Biblio::Thesaurus") }
# Thesaurus is an object of Biblio::Thesaurus type
my $the = thesaurusNew();
isa_ok($the, "Biblio::Thesaurus");
my @allterms;
# Empty thesaurus is really empty
@allterms = $the->allTerms;
is_deeply([@allterms], []);
ok(!$the->isDefined("foo"));
# Addiction really adds...
$the->addTerm("foo");
ok($the->isDefined("foo"));
ok(!$the->isDefined("bar"));
# deletion works
$the->addTerm("bar");
$the->deleteTerm("foo");
ok(!$the->isDefined("foo"));
ok($the->isDefined("bar"));
# term listing works
@allterms = $the->allTerms;
is_deeply([@allterms], [qw/bar/]);
# term listing gives all terms
$the->addTerm("foo");
@allterms = $the->allTerms;
is_deeply([sort @allterms], [qw/bar foo/]);
$the->addRelation("foo", "BT", "ugh");
@allterms = $the->allTerms;
is_deeply([sort @allterms], [qw/bar foo ugh/]);
$the->addRelation("foo", "BT", qw/zbr1 zbr2 zbr3 zbr4/);
@allterms = $the->allTerms;
is_deeply([sort @allterms], [qw/bar foo ugh zbr1 zbr2 zbr3 zbr4/]);
ok($the->hasRelation("foo", "BT", "zbr1"));
ok(!$the->hasRelation("foo", "XX", "zbr1"));
ok(!$the->hasRelation("foo", "BT", "zbr5"));
ok($the->hasRelation("foo","BT","ugh"));
$the->complete;
ok($the->hasRelation("ugh","NT","foo"));
$the->deleteRelation("foo","BT","ugh");
ok(!$the->hasRelation("foo","BT","ugh"));
ok(!$the->hasRelation("ugh","NT","foo"));
$the->addRelation("bar","SN","Uma scope note qualquer");
ok($the->hasRelation("bar","SN"));
$the->deleteRelation("bar","SN");
ok(!$the->hasRelation("bar","SN"));
$the->addRelation("bar","BT", "AA", "BB");
$the->complete;
ok($the->hasRelation("AA","NT","bar"));
ok($the->hasRelation("BB","NT","bar"));
my @rels = $the->relations("bar");
ok(!grep { $_ eq "_NAME_"} @rels);
ok(grep {$_ eq "BT"} @rels);
$the->deleteRelation("bar","BT");
ok(!$the->hasRelation("AA","NT","bar"));
ok(!$the->hasRelation("BB","NT","bar"));
ok(!$the->hasRelation("bar","BT","AA"));
ok(!$the->hasRelation("bar","BT","BB"));
$the->deleteRelation("bar","BT");
isa_ok($the, "Biblio::Thesaurus");
$the->deleteRelation("bar","BT","AA");
isa_ok($the, "Biblio::Thesaurus");
|