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
|
#!/usr/bin/perl -w
use Test::More tests => 11;
use BibTeX::Parser;
use IO::File;
use constant ENTRIES => 1;
my $fh = new IO::File "t/bibs/01.bib", "r" ;
if (defined $fh) {
my $parser = new BibTeX::Parser $fh;
isa_ok($parser, "BibTeX::Parser");
my $count = 0;
while (my $entry = $parser->next) {
$count++;
isa_ok($entry, "BibTeX::Parser::Entry");
is($entry->key, "key01", "key");
is($entry->type, "ARTICLE", "type");
ok($entry->parse_ok, "parse_ok");
is($entry->field("year"), 1950, "field");
is($entry->field("month"), "January~1", "field");
my @authors = $entry->author;
is(scalar @authors, 2, "#authors");
isa_ok($authors[0], "BibTeX::Parser::Author");
is("$authors[0]", "Duck, Donald", "correct author");
}
is($count, ENTRIES, "number of entries");
}
|