#!/usr/bin/env perl # ============================================================================= # # This file is part of BibTool. # It is distributed under the GNU General Public License. # See the file COPYING for details. # # (c) 2011-2020 Gerd Neugebauer # # Net: gene@gerd-neugebauer.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # #*============================================================================= =head1 NAME key_format.t - Test suite for BibTool key.format. =head1 SYNOPSIS key_format.t =head1 DESCRIPTION This module contains some test cases. Running this module as program will run all test cases and print a summary for each. Optionally files *.out and *.err are left if the expected result does not match the actual result. =head1 OPTIONS none =head1 AUTHOR Gerd Neugebauer =cut use strict; use BUnit;use warnings; $ENV{'HOSTNAME'} = 'localhost' if not defined $ENV{'HOSTNAME'}; #------------------------------------------------------------------------------ BUnit::run(name => '_k_1', args => '-k bib/xampl.bib', expected_out => < < '_f_short_1', args => '-f short bib/xampl.bib', expected_out => < < '_K_1', args => '-K bib/xampl.bib', expected_put => < < '_f_long_1', args => '-f long bib/xampl.bib', expected_put => < < 'f_empty_1', args => '-f empty', bib => < < < <<__EOF__; \@Unpublished{unpublished-key, author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor and others", title = "This is a rather long title of an unpublished entry which exceeds one line" } \@Article{, author = {L[eslie] A. Aamport}, title = {The Gnats and Gnus Document Preparation System} } \@BOOK{whole-collection, editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh", title = "High Speed Computer and Algorithm Organization" } \@MISC{misc-minimal, key = "Missilany", note = "This is a minimal MISC entry" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_1', args => '-- key.format={short}', bib => DATA, expected_out => <<__EOF__); \@Unpublished{ thor.author.ea:this, author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor and others", title = "This is a rather long title of an unpublished entry which exceeds one line" } \@Article{ aamport:gnats, author = {L[eslie] A. Aamport}, title = {The Gnats and Gnus Document Preparation System} } \@Book{ lipcoll.lawrie.ea:high, editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh", title = "High Speed Computer and Algorithm Organization" } \@Misc{ missilany, key = "Missilany", note = "This is a minimal MISC entry" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_2', args => '-- key.format={long}', bib => DATA, expected_out => <<__EOF__); \@Unpublished{ thor.fau.author.snd.ea:this, author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor and others", title = "This is a rather long title of an unpublished entry which exceeds one line" } \@Article{ aamport.la:gnats, author = {L[eslie] A. Aamport}, title = {The Gnats and Gnus Document Preparation System} } \@Book{ lipcoll.dj.lawrie.dh.ea:high, editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh", title = "High Speed Computer and Algorithm Organization" } \@Misc{ missilany, key = "Missilany", note = "This is a minimal MISC entry" } __EOF__ use constant SAMPLE => <<__EOF__; \@MISC{misc, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_p1', resource => 'key.format={%p(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.Meone.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_p2', resource => 'key.format={%1p(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_p3', resource => 'key.format={%-2p(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ thor.meone.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_p4', resource => 'key.format={%+1p(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ THOR.EA, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_n1', resource => 'key.format={%n(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.Meone.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_n2', resource => 'key.format={%1n(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_n3', resource => 'key.format={%-2n(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ thor.meone.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_n4', resource => 'key.format={%+1n(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ THOR.EA, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_n5', resource => 'key.format={%.3n(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Tho.Meo.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_N1', resource => 'key.format={%N(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.AU.Meone.SO.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_N2', resource => 'key.format={%1N(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Thor.AU.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_N3', resource => 'key.format={%-2N(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ thor.au.meone.so.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_N4', resource => 'key.format={%+1N(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ THOR.AU.EA, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_N5', resource => 'key.format={%.3N(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ Tho.AU.Meo.SO.ea, author = "A. U. Thor and S. O. Meone and others" } __EOF__ use constant SAMPLE_NUM => <<__EOF__; \@MISC{misc, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d1', resource => 'key.format={x%d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d2', resource => 'key.format={x%1d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x9, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d3', resource => 'key.format={x%4d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d4', resource => 'key.format={x%-4d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x0089, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d5', resource => 'key.format={x%-5.2d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x00123, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d6', resource => 'key.format={x%+.3d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x0, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d7', resource => 'key.format={x%0d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_d8', resource => 'key.format={x%.3d(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ **key*, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D1', resource => 'key.format={x%D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D2', resource => 'key.format={x%1D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D3', resource => 'key.format={x%4D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D4', resource => 'key.format={x%-4D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x0089, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D5', resource => 'key.format={x%-5.2D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x00123, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D6', resource => 'key.format={x%+.3D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x0, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D7', resource => 'key.format={x%0D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ x89, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_D8', resource => 'key.format={x%.3D(pages)}', bib => SAMPLE_NUM, expected_out => <<__EOF__); \@Misc{ **key*, pages = {89--123} } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_s1', resource => 'key.format={%s(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ A.-U.-Thor-and-S.-O.-Meone-and-others, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_s2', resource => 'key.format={%8s(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ A.-U.-Th, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_s3', resource => 'key.format={%-8s(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ a.-u.-th, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_s4', resource => 'key.format={%+8s(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ A.-U.-TH, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_s5', resource => 'key.format={x%0s(author)}', bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ x, author = "A. U. Thor and S. O. Meone and others" } __EOF__ use constant SAMPLE_TITLE => <<__EOF__; \@MISC{csim, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_T1', resource => 'key.format={%T(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ Whole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_T2', resource => 'key.format={%2T(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ Whole-Title, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_T3', resource => 'key.format={%2.1T(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ W-T, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_T4', resource => 'key.format={%-T(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ whole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_T5', resource => 'key.format={%+T(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ WHOLE, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_t1', resource => 'key.format={%t(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ The, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_t2', resource => 'key.format={%2t(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ The-Whole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_t3', resource => 'key.format={%2.1t(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ T-W, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_t4', resource => 'key.format={%-t(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ the, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_t5', resource => 'key.format={%+t(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ THE, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_W1', resource => 'key.format={%W(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ Whole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_W2', resource => 'key.format={%2W(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ WholeTitle, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_W3', resource => 'key.format={%2.1W(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ WT, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_W4', resource => 'key.format={%-W(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ whole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_W5', resource => 'key.format={%+W(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ WHOLE, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_w1', resource => 'key.format={%w(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ The, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_w2', resource => 'key.format={%2w(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ TheWhole, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_w3', resource => 'key.format={%2.1w(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ TW, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_w4', resource => 'key.format={%-w(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ the, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => 'key_format_w5', resource => 'key.format={%+w(title)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ THE, title = "The Whole Title" } __EOF__ foreach $_ (qw/p n N/) { #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}1", resource => "key.format={x%2#$_(author)}", bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ x, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}2", resource => "key.format={x%4#$_(author)}", bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ **key*, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}3", resource => "key.format={x%-4#$_(author)}", bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ x, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}4", resource => "key.format={x%3.4#$_(author)}", bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ x, author = "A. U. Thor and S. O. Meone and others" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}5", resource => "key.format={x%-3.4#$_(author)}", bib => SAMPLE, expected_out => <<__EOF__); \@Misc{ **key*, author = "A. U. Thor and S. O. Meone and others" } __EOF__ } #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_s1", resource => "key.format={x%#s(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_s2", resource => "key.format={x%13.13#s(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_s3", resource => "key.format={x%10.16#s(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_s4", resource => "key.format={x%-10.16#s(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ **key*, title = "The Whole Title" } __EOF__ foreach $_ (qw/w t/) { #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}1", resource => "key.format={x%#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}2", resource => "key.format={x%3.3#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}3", resource => "key.format={x%1.6#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}4", resource => "key.format={x%-1.6#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ **key*, title = "The Whole Title" } __EOF__ } foreach $_ (qw/W T/) { #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}1", resource => "key.format={x%#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}2", resource => "key.format={x%2.2#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}3", resource => "key.format={x%1.6#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_hash_${_}4", resource => "key.format={x%-1.6#$_(title)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ **key*, title = "The Whole Title" } __EOF__ } #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_key1", resource => "key.format={x%s(\$key)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ xcsim, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ #BUnit::run(name => "key_format_dollar_sortkey1", # resource => "key.format={x%s(\$sortkey)}", # bib => SAMPLE_TITLE, # expected_out => <<__EOF__); # #\@Misc{ xcsim, # title = "The Whole Title" #} #__EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_type1", resource => "key.format={x%s(\$type)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ xMisc, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_at_type1", resource => "key.format={x%s(\@Book)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ **key*, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_at_type2", resource => "key.format={x%s(\@Misc)}", bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ xMisc, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_at_type3", resource => 'key.format={x%s(@MISC)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ xMisc, title = "The Whole Title" } __EOF__ my ($sec,$minute,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime(time); $day = "0$day" if $day <= 9; $month++; $month = "0$month" if $month <= 9; $year += 1900; $hour = "0$hour" if $hour <= 9; $minute = "0$minute" if $minute <= 9; #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_day1", resource => 'key.format={x%s($day)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$day, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_month1", resource => 'key.format={x%s($month)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$month, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_year1", resource => 'key.format={x%s($year)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$year, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_hour1", resource => 'key.format={x%s($hour)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$hour, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_minute1", resource => 'key.format={x%s($minute)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$minute, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_user1", resource => 'key.format={x%s($user)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$ENV{USER}, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_dollar_hostname1", resource => 'key.format={x%s($hostname)}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ x$ENV{HOSTNAME}, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_or1", resource => 'key.format={x%#s(abc) # fallback}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ fallback, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_cond1", resource => 'key.format={(abc){then}{else}}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ else, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_cond2", resource => 'key.format={(title){then}{else}}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ then, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_cond3", resource => 'key.format={($key){then}{else}}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ then, title = "The Whole Title" } __EOF__ #------------------------------------------------------------------------------ BUnit::run(name => "key_format_group1", resource => 'key.format={{%N(author) # --no-author-- } {%T(title) # --no-title-- } x}', bib => SAMPLE_TITLE, expected_out => <<__EOF__); \@Misc{ --no-author--Wholex, title = "The Whole Title" } __EOF__ 1; #------------------------------------------------------------------------------ # Local Variables: # mode: perl # End: