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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
%%
%% This is file `askinclude-test14.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% askinclude.dtx (with options: `test0,test14')
%%
%% This is a generated file.
%%
%% Copyright (C) 1991-1994 by Pablo A. Straub
%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Heiko Oberdiek.
%%
%% This work consists of the main source file askinclude.dtx
%% and the derived files
%% askinclude.sty, askinclude.pdf, askinclude.ins, askinclude.drv,
%% askinclude-a.tex, askinclude-b.tex, askinclude-c.tex,
%% askinclude-test1.tex, askinclude-test2.tex,
%% askinclude-test3.tex, askinclude-test4.tex,
%% askinclude-test5.tex, askinclude-test6.tex,
%% askinclude-test7.tex, askinclude-test8.tex,
%% askinclude-test9.tex, askinclude-test10.tex,
%% askinclude-test11.tex, askinclude-test12.tex,
%% askinclude-test13.tex, askinclude-test14.tex,
%% askinclude-test15.tex, askinclude-test16.tex,
%% askinclude-test17.tex, askinclude-test18.tex,
%% askinclude-test19.tex, askinclude-test20.tex,
%% askinclude-test21.tex, askinclude-test22.tex,
%% askinclude-test23.tex, askinclude-test24.tex.
%%
\ifx\CompatibilityMode Y%
\documentstyle[filecontents,qstest,askinclude]{book}%
\else
\documentclass{book}%
\usepackage{filecontents}%
\usepackage{qstest}%
\ifx\AtBeginDocumentMode Y%
\AtBeginDocument{%
\usepackage{askinclude}[2007/10/23]%
}%
\else
\usepackage{askinclude}[2007/10/23]%
\fi
\fi
\IncludeTests{*}
\LogTests{log}{*}{*}
\makeatletter
\let\org@typein\typein
\def\typein[#1]#2{%
\ifx\@Stack\@StackEmpty
\begin{qstest}{StackNonEmpty}{StackNonEmpty}%
\Expect{Error: empty stack}{}%
\end{qstest}%
\org@typein[{#1}]{#2}%
\else
\edef#1{%
\unexpanded\expandafter\expandafter\expandafter{%
\expandafter\@car\@Stack\@nil
}%
}%
\xdef\@Stack{%
\unexpanded\expandafter\expandafter\expandafter{%
\expandafter\@cdr\@Stack\@nil
}%
}%
\typeout{}%
\typeout{\string#1=#1}%
\fi
}
\def\@StackEmpty{\BOTTOM}
\let\@Stack\@StackEmpty
\newcommand*{\Stack}[1]{%
\def\@Stack{#1\BOTTOM}%
}
\AtEndDocument{%
\begin{qstest}{StackUsed}{StackUsed}%
\Expect*{%
\ifx\@Stack\@StackEmpty
\else
Error: Unused stack entries%
\fi
}{}%
\end{qstest}%
}
\newcommand*{\CheckInclude}[2]{%
\include{askinclude-#1}%
\begin{qstest}{CheckInclude-#1}{CheckInclude-#1}%
\Expect*{%
\expandafter\ifx\csname file#1\endcsname Ytrue\else false\fi
}{#2}%
\end{qstest}%
}
\def\@EndChecks{}
\AtBeginDocument{%
\AtEndDocument{%
\if@filesw
\immediate\write\@mainaux{\string\@EndChecks}%
\fi
}%
}
\newcommand*{\CheckAnswer}[1]{%
\gdef\AnswerText{#1}%
\g@addto@macro\@EndChecks{\@CheckAnswer}%
}
\def\@CheckAnswer{%
\begin{qstest}{CheckAnswer}{CheckAnswer}%
\Expect*{\unexpanded\expandafter{\AskInc@Answer}}%
*{\unexpanded\expandafter{\AnswerText}}%
\end{qstest}%
}
\newcommand*{\CheckMatchMethod}[1]{%
\gdef\MatchMethodText{#1}%
\g@addto@macro\@EndChecks{\@CheckMatchMethod}%
}
\def\@CheckMatchMethod{%
\begin{qstest}{CheckMatchMethod}{CheckMatchMethod}%
\Expect*{\unexpanded\expandafter{\AskInc@MatchMethod}}%
*{\unexpanded\expandafter{\MatchMethodText}}%
\end{qstest}%
}
\def\@CheckAux{%
\begin{qstest}{CheckAux}{CheckAux}%
\def\GetFileContents##1{%
\pdfunescapehex{%
\pdffiledump length\pdffilesize{##1}{##1}%
}%
}%
\Expect*{\GetFileContents{\jobname.aux}}%
*{\GetFileContents{\jobname-aux.aux}}%
\end{qstest}%
}
\g@addto@macro\@EndChecks{\@CheckAux}
\let\org@filec@ntents\filec@ntents
\def\filec@ntents{%
\catcode`\|=0 %
\org@filec@ntents
}
\begingroup
\endlinechar=-1 %
\catcode`\|=0 %
\@makeother\#%
\@makeother\\%
|gdef|AddList{%
\providecommand*\AskInc@AddList[2]{%
\ifcase\ifx#1\@undefined
\else\ifx#1\relax
\else\ifx#1\@empty
\else1\fi\fi\fi0 %
\gdef#1{#2}%
\else
\g@addto@macro#1{,#2}%
\fi
}%
}%
|gdef|AddFile{%
\providecommand\AskInc@AddFile{%
\AskInc@AddList\AskInc@Files
}%
}%
|gdef|AddMatch{%
\providecommand\AskInc@AddMatch{%
\AskInc@AddList\AskInc@MatchFiles
}%
}%
|endgroup
\Stack{{}}
\CheckAnswer{*}
\begin{filecontents*}{\jobname.aux}
\gdef\AskInc@Answer{*}
\gdef\AskInc@MatchMethod{}
|AddList
|AddFile
\AskInc@AddFile{askinclude-a}
\AskInc@AddFile{askinclude-b}
\end{filecontents*}
\begin{filecontents*}{\jobname-aux.aux}
\relax|space
\gdef\AskInc@Answer{*}
\gdef\AskInc@MatchMethod{}
|AddList
|AddFile
\AskInc@AddFile{askinclude-a}
\@input{askinclude-a.aux}
\AskInc@AddFile{askinclude-b}
\@input{askinclude-b.aux}
\AskInc@AddFile{askinclude-c}
\@input{askinclude-c.aux}
\@EndChecks
\end{filecontents*}
\begin{document}
\CheckInclude{a}{true}
\CheckInclude{b}{true}
\CheckInclude{c}{true}
\end{document}
\endinput
%%
%% End of file `askinclude-test14.tex'.
|