File: 06-parse_complex.t

package info (click to toggle)
libbibtex-parser-perl 1.05%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 264 kB
  • sloc: perl: 1,382; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl

use Test::More tests => 19;

use strict;
use IO::File;
use BibTeX::Parser;

my $fh = IO::File->new("t/bibs/06.bib");

my $parser = new BibTeX::Parser $fh;


my $entry = $parser->next;

isa_ok($entry, 'BibTeX::Parser::Entry', "Correct type");
ok($entry->parse_ok, "Entry parsed correctly");
is($entry->type, "ARTICLE", "BibTeX type is correct");
is($entry->field("title"), "Paper title", "Title attribute");
is($entry->field("year"), 2008);
is($entry->field("month"), "August", "Month expansion");
is($entry->key, 'key1', "key");

my @authors = $entry->author;
is(scalar @authors, 2, "number of authors correct");
my $author = shift @authors;
is_deeply(
	[$author->first, $author->von, $author->last, $author->jr], 
	['Gerhard', undef, 'Gossen', undef], "author correct");

$author = shift @authors;
is_deeply(
	[$author->first, $author->von, $author->last, $author->jr], 
	['Ludwig', 'van', 'Beethoven', undef], "author correct");

$entry = $parser->next;
isa_ok($entry, 'BibTeX::Parser::Entry', "Correct type");
ok($entry->parse_ok, "Entry parsed correctly");
is($entry->type, "BOOK", "BibTeX type is correct");
is($entry->field("title"), "Book title", "Title attribute");
is($entry->field("year"), 2008);
is($entry->field("month"), "August", "Month expansion");
is($entry->key, 'key2', "key");
@authors = $entry->author;
is(scalar @authors, 1, "number of authors");
is(scalar $entry->editor, 0, "number of editors");