diff options
Diffstat (limited to 'Master/texmf-dist/source/support/bibtexperllibs/BibTeX-Parser/t/06-parse_complex.t')
-rw-r--r-- | Master/texmf-dist/source/support/bibtexperllibs/BibTeX-Parser/t/06-parse_complex.t | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/support/bibtexperllibs/BibTeX-Parser/t/06-parse_complex.t b/Master/texmf-dist/source/support/bibtexperllibs/BibTeX-Parser/t/06-parse_complex.t new file mode 100644 index 00000000000..95a5848a717 --- /dev/null +++ b/Master/texmf-dist/source/support/bibtexperllibs/BibTeX-Parser/t/06-parse_complex.t @@ -0,0 +1,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"); |