1 # -*-Perl-*- Test Harness script for Bioperl
12 test_begin(-tests => 537);
17 Bio::Biblio::BookArticle
19 Bio::Biblio::JournalArticle
20 Bio::Biblio::MedlineArticle
21 Bio::Biblio::MedlineBook
22 Bio::Biblio::MedlineBookArticle
23 Bio::Biblio::MedlineJournal
24 Bio::Biblio::MedlineJournalArticle
25 Bio::Biblio::Organisation
28 Bio::Biblio::Proceeding
32 Bio::Biblio::TechReport
34 Bio::Biblio::WebResource
35 Bio::Biblio::PubmedArticle
36 Bio::Biblio::PubmedBookArticle
37 Bio::Biblio::PubmedJournalArticle);
39 foreach my $module (@modules) {
44 my $verbose = test_debug();
46 my ($biblio, $count, $str, @args);
47 my ($citation, $provider);
49 print "Testing 'Bio::Biblio::->new() ...'\n" if $verbose;
50 foreach my $object (@modules) {
51 ok defined ($biblio = $object->new());
54 my @scalar_methods_for_ref =
60 cross_references_list_complete
72 subject_headings_source
79 my @other_methods_for_ref =
90 my @scalar_methods_for_book =
97 my @other_methods_for_book =
102 my @scalar_methods_for_bookarticle =
105 my @other_methods_for_bookarticle =
110 my @scalar_methods_for_article =
115 my @other_methods_for_article =
119 my @scalar_methods_for_journalarticle =
125 my @other_methods_for_journalarticle =
130 my @scalar_methods_for_medlinearticle =
134 date_of_electronic_publication
148 my @other_methods_for_medlinearticle =
165 summary_for_patients_ins
170 my @scalar_methods_for_medlinejournalarticle =
173 my @other_methods_for_medlinejournalarticle =
178 my @scalar_methods_for_medlinebookarticle =
181 my @other_methods_for_medlinebookarticle =
186 my @scalar_methods_for_medlinebook =
189 my @other_methods_for_medlinebook =
193 my @scalar_methods_for_pubmedarticle =
198 my @other_methods_for_pubmedarticle =
201 pubmed_article_id_list
205 my @scalar_methods_for_journal =
211 my @other_methods_for_journal =
215 my @scalar_methods_for_medlinejournal =
223 my @other_methods_for_medlinejournal =
227 my @scalar_methods_for_patent =
233 my @other_methods_for_patent =
238 my @scalar_methods_for_webresource =
244 my @other_methods_for_webresource =
248 my @scalar_methods_for_provider =
253 my @scalar_methods_for_person =
266 my @scalar_methods_for_organisation =
271 my @scalar_methods_for_service =
277 # Bio::Biblio::MedlineJournalArticle
279 print "Testing Bio::Biblio::MedlineJournalArticle ...\n" if $verbose;
280 $citation = Bio::Biblio::MedlineJournalArticle->new();
283 foreach my $method (@scalar_methods_for_ref,
284 @scalar_methods_for_article,
285 @scalar_methods_for_journalarticle,
286 @scalar_methods_for_medlinearticle,
287 @scalar_methods_for_medlinejournalarticle) {
288 $str = 'string' . ($count++);
289 is $citation->$method ($str), $str, "set '$method'";
290 is $citation->$method(), $str, "get '$method'";
291 push (@args, ("-$method" => $str));
294 ok defined ($biblio = Bio::Biblio::MedlineJournalArticle->new(@args));
295 for (my $i = 0; $i < @args; $i += 2) {
296 my $method = substr ($args[$i], 1);
297 is $citation->$method(), $args[$i+1], $method;
299 foreach my $method (@other_methods_for_ref,
300 @other_methods_for_article,
301 @other_methods_for_journalarticle,
302 @other_methods_for_medlinearticle,
303 @other_methods_for_medlinejournalarticle) {
304 is $citation->$method(), undef, "get '$method'";
306 my ($me) = Bio::Biblio::Person->new(-lastname => 'me');
307 my ($you) = Bio::Biblio::Person->new(-lastname => 'you');
308 ok $citation->add_author ($me), "add_author 1";
309 ok $citation->add_author ($you), "add_author 2";
310 is ${ $citation->authors }[1]->lastname, 'you', "get authors";
312 ok $citation->add_contributor ($me), "add_contributor 1";
313 ok $citation->add_contributor ($you), "add_contributor 2";
314 is ${ $citation->contributors }[1]->lastname, 'you', "get contributors";
316 use Bio::Annotation::DBLink;
317 my $link1 = Bio::Annotation::DBLink->new(-database => 'here',
320 my $link2 = Bio::Annotation::DBLink->new(-database => 'there',
324 ok $citation->add_cross_reference ($link1), "add_cross_reference 1";
325 ok $citation->add_cross_reference ($link2), "add_cross_reference 2";
326 is ${ $citation->cross_references }[0]->database, 'here', "get cross_references";
327 is ${ $citation->cross_references }[1]->primary_id, '002', "get cross_references";
331 # Bio::Biblio::MedlineBookArticle
333 print "Testing Bio::Biblio::MedlineBookArticle ...\n" if $verbose;
334 $citation = Bio::Biblio::MedlineBookArticle->new();
337 foreach my $method (@scalar_methods_for_ref,
338 @scalar_methods_for_article,
339 @scalar_methods_for_bookarticle,
340 @scalar_methods_for_medlinearticle,
341 @scalar_methods_for_medlinebookarticle) {
342 $str = 'string' . ($count++);
343 is $citation->$method ($str), $str, "set '$method'";
344 is $citation->$method(), $str, "get '$method'";
345 push (@args, ("-$method" => $str));
348 ok defined ($biblio = Bio::Biblio::MedlineBookArticle->new(@args));
349 for (my $i = 0; $i < @args; $i += 2) {
350 my $method = substr ($args[$i], 1);
351 is $citation->$method(), $args[$i+1], $method;
353 foreach my $method (@other_methods_for_ref,
354 @other_methods_for_article,
355 @other_methods_for_bookarticle,
356 @other_methods_for_medlinearticle,
357 @other_methods_for_medlinebookarticle) {
358 is $citation->$method(), undef, "get '$method'";
363 # Bio::Biblio::MedlineBook
365 print "Testing Bio::Biblio::MedlineBook ...\n" if $verbose;
366 $citation = Bio::Biblio::MedlineBook->new();
369 foreach my $method (@scalar_methods_for_ref,
370 @scalar_methods_for_book,
371 @scalar_methods_for_medlinebook) {
372 $str = 'string' . ($count++);
373 is $citation->$method ($str), $str, "set '$method'";
374 is $citation->$method(), $str, "get '$method'";
375 push (@args, ("-$method" => $str));
378 ok defined ($biblio = Bio::Biblio::MedlineBook->new(@args));
379 for (my $i = 0; $i < @args; $i += 2) {
380 my $method = substr ($args[$i], 1);
381 is $citation->$method(), $args[$i+1], $method;
383 foreach my $method (@other_methods_for_ref,
384 @other_methods_for_book,
385 @other_methods_for_medlinebook) {
386 is $citation->$method(), undef, "get '$method'";
390 # Bio::Biblio::MedlineJournal
392 print "Testing Bio::Biblio::MedlineJournal ...\n" if $verbose;
393 $citation = Bio::Biblio::MedlineJournal->new();
396 foreach my $method (@scalar_methods_for_journal,
397 @scalar_methods_for_medlinejournal) {
398 $str = 'string' . ($count++);
399 is $citation->$method ($str), $str, "set '$method'";
400 is $citation->$method(), $str, "get '$method'";
401 push (@args, ("-$method" => $str));
404 ok defined ($biblio = Bio::Biblio::MedlineJournal->new(@args));
405 for (my $i = 0; $i < @args; $i += 2) {
406 my $method = substr ($args[$i], 1);
407 is $citation->$method(), $args[$i+1], $method;
409 foreach my $method (@other_methods_for_journal,
410 @other_methods_for_medlinejournal) {
411 is $citation->$method(), undef, "get '$method'";
415 # Bio::Biblio::Patent
417 print "Testing Bio::Biblio::Patent ...\n" if $verbose;
418 $citation = Bio::Biblio::Patent->new();
421 foreach my $method (@scalar_methods_for_patent) {
422 $str = 'string' . ($count++);
423 is $citation->$method ($str), $str, "set '$method'";
424 is $citation->$method(), $str, "get '$method'";
425 push (@args, ("-$method" => $str));
428 ok defined ($biblio = Bio::Biblio::Patent->new(@args));
429 for (my $i = 0; $i < @args; $i += 2) {
430 my $method = substr ($args[$i], 1);
431 is $citation->$method(), $args[$i+1], $method;
433 foreach my $method (@other_methods_for_patent) {
434 is $citation->$method(), undef, "get '$method'";
438 # Bio::Biblio::WebResource
440 print "Testing Bio::Biblio::WebResource ...\n" if $verbose;
441 $citation = Bio::Biblio::WebResource->new();
444 foreach my $method (@scalar_methods_for_webresource) {
445 $str = 'string' . ($count++);
446 is $citation->$method ($str), $str, "set '$method'";
447 is $citation->$method(), $str, "get '$method'";
448 push (@args, ("-$method" => $str));
451 ok defined ($biblio = Bio::Biblio::WebResource->new(@args));
452 for (my $i = 0; $i < @args; $i += 2) {
453 my $method = substr ($args[$i], 1);
454 is $citation->$method(), $args[$i+1], $method;
456 foreach my $method (@other_methods_for_webresource) {
457 is $citation->$method(), undef, "get '$method'";
462 # Bio::Biblio::Person
464 print "Testing Bio::Biblio::Person ...\n" if $verbose;
465 $provider = Bio::Biblio::Person->new();
468 foreach my $method (@scalar_methods_for_provider,
469 @scalar_methods_for_person) {
470 $str = 'string' . ($count++);
471 is $provider->$method ($str), $str, "set '$method'";
472 is $provider->$method(), $str, "get '$method'";
473 push (@args, ("-$method" => $str));
476 ok defined ($biblio = Bio::Biblio::Person->new(@args));
477 for (my $i = 0; $i < @args; $i += 2) {
478 my $method = substr ($args[$i], 1);
479 is $provider->$method(), $args[$i+1], $method;
483 # Bio::Biblio::Organisation
485 print "Testing Bio::Biblio::Organisation ...\n" if $verbose;
486 $provider = Bio::Biblio::Organisation->new();
489 foreach my $method (@scalar_methods_for_provider,
490 @scalar_methods_for_organisation) {
491 $str = 'string' . ($count++);
492 is $provider->$method ($str), $str, "set '$method'";
493 is $provider->$method(), $str, "get '$method'";
494 push (@args, ("-$method" => $str));
497 ok defined ($biblio = Bio::Biblio::Organisation->new(@args));
498 for (my $i = 0; $i < @args; $i += 2) {
499 my $method = substr ($args[$i], 1);
500 is $provider->$method(), $args[$i+1], $method;
504 # Bio::Biblio::Service
506 print "Testing Bio::Biblio::Service ...\n" if $verbose;
507 $provider = Bio::Biblio::Service->new();
510 foreach my $method (@scalar_methods_for_provider,
511 @scalar_methods_for_organisation) {
512 $str = 'string' . ($count++);
513 is $provider->$method ($str), $str, "set '$method'";
514 is $provider->$method(), $str, "get '$method'";
515 push (@args, ("-$method" => $str));
518 ok defined ($biblio = Bio::Biblio::Service->new(@args));
519 for (my $i = 0; $i < @args; $i += 2) {
520 my $method = substr ($args[$i], 1);
521 is $provider->$method(), $args[$i+1], $method;
525 # Bio::Biblio::PubmedJournalArticle
527 print "Testing Bio::Biblio::PubmedJournalArticle ...\n" if $verbose;
528 $citation = Bio::Biblio::PubmedJournalArticle->new();
531 foreach my $method (@scalar_methods_for_pubmedarticle) {
532 $str = 'string' . ($count++);
533 is $citation->$method ($str), $str, "set '$method'";
534 is $citation->$method(), $str, "get '$method'";
535 push (@args, ("-$method" => $str));
538 ok defined ($biblio = Bio::Biblio::PubmedJournalArticle->new(@args));
539 for (my $i = 0; $i < @args; $i += 2) {
540 my $method = substr ($args[$i], 1);
541 is $citation->$method(), $args[$i+1], $method;
543 foreach my $method (@other_methods_for_pubmedarticle) {
544 is $citation->$method(), undef, "get '$method'";