| 1 |
#!/usr/bin/env perl |
| 2 |
# ============================================================================= |
| 3 |
# |
| 4 |
# This file is part of BibTool. |
| 5 |
# It is distributed under the GNU General Public License. |
| 6 |
# See the file COPYING for details. |
| 7 |
# |
| 8 |
# (c) 2011-2020 Gerd Neugebauer |
| 9 |
# |
| 10 |
# Net: [email protected] |
| 11 |
# |
| 12 |
# This program is free software; you can redistribute it and/or modify |
| 13 |
# it under the terms of the GNU General Public License as published by |
| 14 |
# the Free Software Foundation; either version 2, or (at your option) |
| 15 |
# any later version. |
| 16 |
# |
| 17 |
# This program is distributed in the hope that it will be useful, |
| 18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
# GNU General Public License for more details. |
| 21 |
# |
| 22 |
# You should have received a copy of the GNU General Public License |
| 23 |
# along with this program; if not, write to the Free Software |
| 24 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 25 |
# |
| 26 |
#*============================================================================= |
| 27 |
|
| 28 |
=head1 NAME |
| 29 |
|
| 30 |
print_entry_types.t - Test suite for BibTool print.entry.types. |
| 31 |
|
| 32 |
=head1 SYNOPSIS |
| 33 |
|
| 34 |
print_entry_types.t |
| 35 |
|
| 36 |
=head1 DESCRIPTION |
| 37 |
|
| 38 |
This module contains some test cases. Running this module as program |
| 39 |
will run all test cases and print a summary for each. Optionally files |
| 40 |
*.out and *.err are left if the expected result does not match the |
| 41 |
actual result. |
| 42 |
|
| 43 |
=head1 OPTIONS |
| 44 |
|
| 45 |
none |
| 46 |
|
| 47 |
=head1 AUTHOR |
| 48 |
|
| 49 |
Gerd Neugebauer |
| 50 |
|
| 51 |
=head1 BUGS |
| 52 |
|
| 53 |
=over 4 |
| 54 |
|
| 55 |
=item * |
| 56 |
|
| 57 |
... |
| 58 |
|
| 59 |
=back |
| 60 |
|
| 61 |
=cut |
| 62 |
|
| 63 |
use strict; |
| 64 |
use BUnit;use warnings; |
| 65 |
|
| 66 |
|
| 67 |
use constant BIB_3 =><<__EOF__; |
| 68 |
start |
| 69 |
\@article{art, author="A.U. Thor"} |
| 70 |
\@string{s ="s"} |
| 71 |
\@string{t ="t"} |
| 72 |
\@preamble{preamble} |
| 73 |
\@book{bk, author =s} |
| 74 |
\@alias{kb=bk} |
| 75 |
the comment |
| 76 |
__EOF__ |
| 77 |
|
| 78 |
#------------------------------------------------------------------------------ |
| 79 |
BUnit::run(name => 'print_entry_types_0', |
| 80 |
args => 'bib/xampl.bib', |
| 81 |
resource => <<__EOF__ , |
| 82 |
print.entry.types = {} |
| 83 |
__EOF__ |
| 84 |
expected_out => '' ); |
| 85 |
|
| 86 |
#------------------------------------------------------------------------------ |
| 87 |
BUnit::run(name => 'print_entry_types_p1', |
| 88 |
bib => BIB_3, |
| 89 |
resource => <<__EOF__ , |
| 90 |
print.entry.types {p} |
| 91 |
__EOF__ |
| 92 |
expected_out => <<__EOF__ ); |
| 93 |
\@PREAMBLE{ preamble } |
| 94 |
__EOF__ |
| 95 |
|
| 96 |
#------------------------------------------------------------------------------ |
| 97 |
BUnit::run(name => 'print_entry_types_p2', |
| 98 |
args => 'bib/xampl.bib', |
| 99 |
resource => <<__EOF__ , |
| 100 |
print.entry.types {p} |
| 101 |
__EOF__ |
| 102 |
expected_out => <<__EOF__ ); |
| 103 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 104 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 105 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 106 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 107 |
__EOF__ |
| 108 |
|
| 109 |
#------------------------------------------------------------------------------ |
| 110 |
BUnit::run(name => 'print_entry_types_s1', |
| 111 |
bib => BIB_3, |
| 112 |
resource => <<__EOF__ , |
| 113 |
print.entry.types {s} |
| 114 |
__EOF__ |
| 115 |
expected_out => <<__EOF__ ); |
| 116 |
\@STRING{s = "s" } |
| 117 |
\@STRING{t = "t" } |
| 118 |
__EOF__ |
| 119 |
|
| 120 |
#------------------------------------------------------------------------------ |
| 121 |
BUnit::run(name => 'print_entry_types_s2', |
| 122 |
args => 'bib/xampl.bib', |
| 123 |
resource => <<__EOF__ , |
| 124 |
print.entry.types {S} |
| 125 |
__EOF__ |
| 126 |
expected_out => <<__EOF__ ); |
| 127 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 128 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 129 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 130 |
__EOF__ |
| 131 |
|
| 132 |
#------------------------------------------------------------------------------ |
| 133 |
BUnit::run(name => 'print_entry_types_S1', |
| 134 |
bib => BIB_3, |
| 135 |
resource => <<__EOF__ , |
| 136 |
print.entry.types {S} |
| 137 |
__EOF__ |
| 138 |
expected_out => <<__EOF__ ); |
| 139 |
\@STRING{s = "s" } |
| 140 |
__EOF__ |
| 141 |
|
| 142 |
|
| 143 |
#------------------------------------------------------------------------------ |
| 144 |
BUnit::run(name => 'print_entry_types_dollar1', |
| 145 |
bib => BIB_3, |
| 146 |
resource => <<__EOF__ , |
| 147 |
print.entry.types {\$} |
| 148 |
__EOF__ |
| 149 |
expected_out => <<__EOF__ ); |
| 150 |
\@STRING{s = "s" } |
| 151 |
\@STRING{t = "t" } |
| 152 |
__EOF__ |
| 153 |
|
| 154 |
#------------------------------------------------------------------------------ |
| 155 |
BUnit::run(name => 'print_entry_types_c1', |
| 156 |
ignore => 'TODO', |
| 157 |
bib => BIB_3, |
| 158 |
resource => <<__EOF__ , |
| 159 |
print.entry.types {c} |
| 160 |
__EOF__ |
| 161 |
expected_out => <<__EOF__ ); |
| 162 |
the comment |
| 163 |
__EOF__ |
| 164 |
|
| 165 |
#------------------------------------------------------------------------------ |
| 166 |
BUnit::run(name => 'print_entry_types_a1', |
| 167 |
bib => BIB_3, |
| 168 |
resource => <<__EOF__ , |
| 169 |
print.entry.types {a} |
| 170 |
__EOF__ |
| 171 |
expected_out => <<__EOF__ ); |
| 172 |
\@ALIAS{kb = bk } |
| 173 |
__EOF__ |
| 174 |
|
| 175 |
#------------------------------------------------------------------------------ |
| 176 |
BUnit::run(name => 'print_entry_types_n1', |
| 177 |
bib => BIB_3, |
| 178 |
resource => <<__EOF__ , |
| 179 |
print.entry.types {n} |
| 180 |
__EOF__ |
| 181 |
expected_out => <<__EOF__ ); |
| 182 |
|
| 183 |
\@Article{ art, |
| 184 |
author = "A.U. Thor" |
| 185 |
} |
| 186 |
|
| 187 |
\@Book{ bk, |
| 188 |
author = s |
| 189 |
} |
| 190 |
__EOF__ |
| 191 |
|
| 192 |
#------------------------------------------------------------------------------ |
| 193 |
BUnit::run(name => 'print_entry_types_1', |
| 194 |
bib => BIB_3, |
| 195 |
resource => <<__EOF__ , |
| 196 |
__EOF__ |
| 197 |
#expected_err => '', |
| 198 |
expected_out => <<__EOF__ ); |
| 199 |
\@PREAMBLE{ preamble } |
| 200 |
\@STRING{s = "s" } |
| 201 |
\@STRING{t = "t" } |
| 202 |
|
| 203 |
\@Article{ art, |
| 204 |
author = "A.U. Thor" |
| 205 |
} |
| 206 |
|
| 207 |
\@Book{ bk, |
| 208 |
author = s |
| 209 |
} |
| 210 |
\@ALIAS{kb = bk } |
| 211 |
__EOF__ |
| 212 |
|
| 213 |
|
| 214 |
1; |
| 215 |
#------------------------------------------------------------------------------ |
| 216 |
# Local Variables: |
| 217 |
# mode: perl |
| 218 |
# End: |