summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/inlinedef/inlinetest.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/inlinedef/inlinetest.tex
Initial commit
Diffstat (limited to 'macros/latex/contrib/inlinedef/inlinetest.tex')
-rw-r--r--macros/latex/contrib/inlinedef/inlinetest.tex507
1 files changed, 507 insertions, 0 deletions
diff --git a/macros/latex/contrib/inlinedef/inlinetest.tex b/macros/latex/contrib/inlinedef/inlinetest.tex
new file mode 100644
index 0000000000..49b4478bbd
--- /dev/null
+++ b/macros/latex/contrib/inlinedef/inlinetest.tex
@@ -0,0 +1,507 @@
+%%
+%% This is file `inlinetest.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% inlinedef.dtx (with options: `testsuite')
+%%
+%% Copyright 2008 Stephen D. Hicks <sdh33@cornell.edu>.
+%%
+%% This program 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'.
+%%
+%% The Current Maintainer of this work is Stephen D. Hicks
+%%
+%% This work consists of the files
+%% README
+%% inlinedef.dtx
+%% inlinedef.ins
+%% inlinedef.pdf
+%% and the derived files
+%% inlinedef.sty
+%% inlinetest.tex
+%%
+%% Any modified versions of this file must be renamed
+%% with new filenames distinct from those in this work.
+%%
+%% This generated file may be distributed as long as the
+%% original source files, as listed above, are part of the
+%% same distribution. (The sources need not necessarily be
+%% in the same archive or directory.)
+%%
+\documentclass{minimal}
+\usepackage{inlinedef}%
+ [2008/07/10 v1.0 Inlined expansions within definitions]
+\makeatletter
+\errorcontextlines=10
+\def\WantError#1#2#3{%
+ \let\WE@packageerror\PackageError
+ \def\PackageError##1##2##3{%
+ \protected@edef\@goterror{##2}\protected@edef\@wanterror{#2}%
+ \edef\@goterror{\xa\detokenize\xa{\@goterror}}%
+ \edef\@wanterror{\xa\detokenize\xa{\@wanterror}}%
+ \protected@edef\@gotpackage{##1}\protected@edef\@wantpackage{#1}%
+ \edef\@gotpackage{\xa\detokenize\xa{\@gotpackage}}%
+ \edef\@wantpackage{\xa\detokenize\xa{\@wantpackage}}%
+ \global\let\PackageError\WE@packageerror
+ \@tempswafalse
+ \ifx\@gotpackage\@wantpackage\else\message{^^J(arg 1 differs)^^J}\@tempswatrue\fi
+ \ifx\@goterror\@wanterror\else\message{^^J(arg 2 differs)^^J}\@tempswatrue\fi
+ \ifx#3##3\else\message{^^J(arg 3 differs)^^J}\@tempswatrue\fi
+ \if@tempswa\PackageError{inlinedef (test)}{wrong error}\@eha\PackageError{##1}{##2}##3\fi
+ }%
+}
+
+\def\CheckError{%
+ \ifx\PackageError\WE@packageerror\else
+ \PackageError{inlinedef (test)}{expected error not thrown}\@eha\fi
+ \global\let\PackageError\WE@packageerror
+}
+\newcommand\CheckDefinition[1][]{\@CheckDefinition{#1}}
+\def\@CheckDefinition#1#2#3#{\@checkdefn{#1}#2{#3}}
+\def\@checkdefn#1#2#3#4{#1\def\@reserveda#3{#4}\ifx#2\@reserveda\else
+ \message{^^J^^J\meaning#2^^J(got)vs(wanted)^^J\meaning\@reserveda^^J^^J}
+ \PackageError{inlinedef (test)}{definition of \detokenize{#2}didn't match}\@eha\fi
+}
+\let\eha\@eha\let\ehd\@ehd
+\makeatother
+\catcode`\#=12
+\def\pound{#}
+\catcode`\#=6
+
+\def\WantSuperNoMatch#1#2#3{%
+ \WantError{inlinedef}{Cannot use \protect\Super\space in
+ \protect#1\space because\MessageBreak
+ parameter lists don't match:\MessageBreak
+ `#3' (new) != `#2' (old)}\eha
+}
+\def\WantStarNoMatch#1#2#3{%
+ \WantError{inlinedef}{Cannot use \protect\Inline* auto-expansion in
+ \protect#1\MessageBreak because
+ parameter lists don't match:\MessageBreak
+ `#3' (new) != `#2' (old)}\eha
+}
+\def\WantNoMatchBang#1#2#3{%
+\WantError{inlinedef}{Parameter lists for
+ \protect#1\space don't match:\MessageBreak
+ `#3' (new) != `#2' (old)\MessageBreak
+ Use !-form of \protect\Inline\space to ignore this}\eha
+}
+\def\WantOnlyDefGdef{%
+ \WantError{inlinedef}{Only \protect\def\space and \protect\gdef\space are
+ allowed after \protect\Inline,\MessageBreak but some other type of
+ definition was found}\eha
+}
+\def\WantNoDefGdef{%
+ \WantError{inlinedef}{No \protect\def\space or \protect\gdef\space found
+ after \protect\Inline}\ehd
+}
+\def\WantSuperNoRedef#1{%
+ \WantError{inlinedef}{Cannot use \protect\Super\space in \protect#1\space
+ because \MessageBreak it hasn't been defined yet}\eha
+}
+ % I. Basic stuff
+ % A. Simple definition
+\let\a\undefined
+\Inline\def\a{b}
+\CheckDefinition\a{b}
+
+ % B. Simple redefinition
+\def\a{b}
+\Inline\def\a{d}
+\CheckDefinition\a{d}
+
+ % C. Erroneous redefinition (needs !)
+\def\a{b}
+\WantNoMatchBang\a{}{\pound1}
+\Inline\def\a#1{c}
+\CheckError
+\CheckDefinition\a{b} % shouldn't have changed
+
+\def\a{b}
+\Inline!\def\a#1{c}
+\CheckDefinition\a#1{c}
+
+ % D. Local/global definition
+\def\a{b}
+\begingroup
+\Inline\def\a{c}
+\endgroup
+\CheckDefinition\a{b}
+
+\begingroup
+\Inline\gdef\a{c}
+\endgroup
+\CheckDefinition\a{c}
+
+{\Inline\global\def\a{d}}
+\CheckDefinition\a{d}
+
+ % E. Collecting arguments
+\Inline\long\def\a{e}
+\CheckDefinition[\long]\a{e}
+
+\Inline\outer\def\a{f}
+\edef\a{\meaning\a}
+\edef\b{\detokenize{\outer macro:->f}}
+\xa\CheckDefinition\xa\a\xa{\b}
+
+\Inline\long\outer\def\a{g}
+\edef\a{\meaning\a}
+\edef\b{\string\long\string\outer\space\detokenize{macro:->g}}
+\xa\CheckDefinition\xa\a\xa{\b}
+
+\def\a{g}
+\Inline!\long\def\a#1{h}
+\CheckDefinition[\long]\a#1{h}
+
+ % II. Special tokens
+ % A. Recursion
+\def\a{b}
+\Inline\def\a{a\a c}
+\CheckDefinition\a{a\a c}
+
+ % B. Expansion
+\def\a{b}
+\Inline\def\a{a\Expand\a c}
+\CheckDefinition\a{abc}
+
+\def\a{b}
+\Inline\def\a{\Expand a\Expand\a\Expand c}
+\CheckDefinition\a{abc}
+
+\def\a{\b}
+\def\b{c}
+\Inline\def\a{a\Expand\a c}
+\CheckDefinition\a{a\b c}
+
+\toks0{b}\toks1{d}
+\Inline\def\a{a\the\toks0c\the\toks1e}
+\CheckDefinition\a{a\the\toks0c\the\toks1e}
+
+\Inline\def\a{a\Expand{\the\toks0}c\Expand{\the\toks1}e}
+\CheckDefinition\a{abcde}
+
+\Inline\def\a{\Expand{a\the\toks0}c\Expand{\the\toks1}e}
+\CheckDefinition\a{a\the\toks0cde}
+
+\Inline\def\a{\Expand{\expandafter a\the\toks0}c\Expand{\the\toks1e}}
+\CheckDefinition\a{abcde}
+
+ % C. MultiExpand
+\def\x{\y}
+\def\y{\z}
+\def\z{0}
+\Inline\def\a{a\MultiExpand0\x b}
+\CheckDefinition\a{a\x b}
+
+\Inline\def\a{a\MultiExpand1\x b}
+\CheckDefinition\a{a\y b}
+
+\Inline\def\a{a\MultiExpand2\x b}
+\CheckDefinition\a{a\z b}
+
+\Inline\def\a{a\MultiExpand3\x b}
+\CheckDefinition\a{a0b}
+
+\Inline\def\a{a\MultiExpand{10}\x b}
+\CheckDefinition\a{a0b}
+
+ % i. use with \expandafter
+\Inline\def\a{a\MultiExpand2{\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a\y\y b}
+
+\Inline\def\a{a\MultiExpand1{\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a\expandafter\y\x b}
+
+\Inline\def\a{a\MultiExpand2{\expandafter\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a\x\z b}
+
+\Inline\def\a{a\MultiExpand3{\expandafter\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a\y\z b}
+
+\Inline\def\a{a\MultiExpand4{\expandafter\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a\z\z b}
+
+\Inline\def\a{a\MultiExpand5{\expandafter\expandafter\expandafter\x\x}b}
+\CheckDefinition\a{a0\z b}
+
+ % D. UnsafeExpand
+\def\x{b\Super c}
+\Inline\def\a{a\Expand\x d}
+\CheckDefinition\a{ab\Super cd}
+
+\def\a{0}
+\Inline\def\a{a\UnsafeExpand\x d}
+\CheckDefinition\a{ab0cd}
+
+\def\a{b\Super d}
+\Inline\def\a{a\UnsafeExpand\a e}
+\CheckDefinition\a{abb\Super dde}
+
+\def\a{b\Super d}
+\Inline**\def\a{a\a e}
+\CheckDefinition\a{abb\Super dde}
+
+ % Would be nice if we could catch TeX capacity exceeded errors...
+ % Then try \def\a{b\a d}\Inline**\def\a{a\a e}
+
+\def\x#1{b#1d}
+\Inline\def\a{a\x ce}
+\CheckDefinition\a{a\x ce}
+
+\Inline\def\a{a\UnsafeExpand\x ce}
+\CheckDefinition\a{abcde}
+
+ % E. NoExpand
+\Inline\def\a{a\NoExpand\Expand\x b}
+\CheckDefinition\a{a\Expand\x b}
+
+\Inline*\def\a{a\NoExpand\a b}
+\CheckDefinition\a{a\a b}
+
+\Inline**\def\a{a\NoExpand\a b}
+\CheckDefinition\a{a\a b}
+
+\Inline\def\a{a\NoExpand{\Expand\x\Expand\y}b}
+\CheckDefinition\a{a\Expand\x\Expand\y b}
+
+ % F. Super
+\def\a{bcd}
+\Inline\def\a{a\Super e}
+\CheckDefinition\a{abcde}
+
+\def\a#1{b#1d}
+\Inline\def\a#1{a\Super e}
+\CheckDefinition\a#1{ab#1de}
+
+\def\a#1{b#1d}
+\Inline*\def\a#1{a\Super e}
+\CheckDefinition\a#1{ab#1de}
+
+\def\a#1{b#1d}
+\Inline**\def\a#1{a\Super e}
+\CheckDefinition\a#1{ab#1de}
+
+ % G. Recurse
+\def\a{q}
+\Inline\def\a{a\Recurse b}
+\CheckDefinition\a{a\a b}
+
+\Inline*\def\a{a\Recurse b}
+\CheckDefinition\a{a\a b}
+
+\Inline**\def\a{a\Recurse b}
+\CheckDefinition\a{a\a b}
+
+ % III. Tricky parsing
+ % A. Spaces
+\def\a{b c d}
+\Inline\def\a{a \Super e}
+\CheckDefinition\a{a b c de}
+
+\def\a{b c d}
+\Inline\def\a{a \Expand\a e}
+\CheckDefinition\a{a b c de}
+
+\def\a{b c d}
+\Inline\def\a{a \Expand{\a} e}
+\CheckDefinition\a{a b c d e}
+
+\Inline\def\a{a\NoExpand{\Expand\x\Expand\y} b}
+\xa\CheckDefinition\xa\a\xa{\xa a\xa\Expand\xa\x\xa\Expand\xa\y\space b}
+
+ % B. Grouping
+\def\a{b{c d}e}
+\Inline\def\a{{a\Super}f\Super}
+\CheckDefinition\a{{ab{c d}e}fb{c d}e}
+
+\Inline\def\a{{ }{}}
+\Inline\def\a{{\Expand\a\a}{} {{\Super}{}}}
+\CheckDefinition\a{{{ }{}\a}{} {{{ }{}}{}}}
+
+ % C. Parameters
+\def\a#1bcd#2{[#1...#2]}
+\Inline\def\a#1bcd#2{a\Super b}
+\CheckDefinition\a#1bcd#2{a[#1...#2]b}
+
+\def\a#1\##2{y}
+\Inline\def\a#1\##2{x\UnsafeExpand\a{#1}\#{#2}z}
+\CheckDefinition\a#1\##2{xyz}
+
+\def\a#1\##2{#1y#2}
+\Inline\def\a#1\##2{x\UnsafeExpand\a{#1}\#{#2}z}
+\CheckDefinition\a#1\##2{x#1y#2z}
+
+ % i. spaces!
+\def\a #1 {y}
+\Inline\def\a#1 {x\Super z}
+\CheckDefinition\a#1 {xyz}
+
+\xa\def\xa\a\space{y}
+\xa\Inline\xa\def\xa\a\space{x\Super z}
+\xa\CheckDefinition\xa\a\space{xyz}
+
+ % ii. funky catcodes
+ %%%% This test fails.
+ %\begingroup
+ % \catcode`&=6
+ % \def\a&1{b#1d}
+ % \Inline\def\a#1{a\Super e}
+ % \CheckDefinition\a#1{b&1d}
+ %\endgroup
+
+ % D. Active characters
+\begingroup
+ \catcode`A=13
+ \defA#1{b#1d}
+ \Inline\defA#1{aAe}
+ \CheckDefinitionA#1{aAe}
+
+ \defA#1{b#1d}
+ \Inline*\defA#1{aAe}
+ \CheckDefinitionA#1{ab#1de}
+\endgroup
+
+ % IV. Auto-expansion
+
+\def\a#1{y}
+\Inline\def\a#1{x\a z}
+\CheckDefinition\a#1{x\a z}
+
+\def\a#1{y}
+\Inline*\def\a#1{x\a z}
+\CheckDefinition\a#1{xyz}
+
+\def\a#1{y}
+\Inline**\def\a#1{x\a{#1}z}
+\CheckDefinition\a#1{xyz}
+
+ % A. With delimited arguments
+\def\a[#1]#2{#1y#2}
+\Inline*\def\a[#1]#2{x\a z}
+\CheckDefinition\a[#1]#2{x#1y#2z}
+
+\def\a[#1]#2{#1y#2}
+\Inline**\def\a[#1]#2{x\a[#1]{#2}z}
+\CheckDefinition\a[#1]#2{x#1y#2z}
+
+ % V. Errors
+
+\def\bar#1{d #1 f}
+\def\x{b}
+
+\WantSuperNoMatch\a{\pound1}{.\pound1}
+\def\a#1{x}
+\Inline!\def\a.#1{y\Super}
+\CheckError
+\CheckDefinition\a#1{x}
+
+\WantStarNoMatch\a{\pound1}{.\pound1}
+\def\a#1{x}
+\Inline*!\def\a.#1{y\a}
+\CheckError
+\CheckDefinition\a#1{x}
+
+\def\a#1{x}
+\Inline!\def\a.#1{y} % ok
+\CheckDefinition\a.#1{y}
+
+\WantOnlyDefGdef
+\def\foo{a}
+\Inline\edef\foo{b}
+\CheckError
+\CheckDefinition\foo{a}
+\let\foo\undefined
+
+\WantOnlyDefGdef
+\Inline\global\outer\xdef{}
+\CheckError
+
+\WantOnlyDefGdef
+\Inline\global\outer\abc\space vbcda s \newcommand{}
+\CheckError
+
+\WantNoDefGdef
+\Inline\let\relax\relax
+\CheckError
+
+\WantNoDefGdef
+\Inline{}
+\CheckError
+
+\WantSuperNoRedef\foo
+\Inline\def\foo#1{a \Expand\x\space cd #1 fg \x\space i\Super}
+\CheckError
+
+\WantNoMatchBang\a{}{\pound1}
+\def\a{b}
+\Inline\def\a#1{a\a c}
+\CheckError
+
+ % Miscellaneous (read: "old") tests
+
+\def\test#1{d #1 f}
+\Inline\def\test#1{a \Expand\x\space c\Super g \x\space i}
+\CheckDefinition\test#1{a b\space cd #1 fg \x\space i}
+
+\Inline*\def\bar#1{a \Expand\x\space c\bar g \x\space i}
+\CheckDefinition\bar#1{a b\space cd #1 fg \x\space i}
+
+\def\bar#1{d #1 f}
+\Inline**\def\bar#1{a \Expand\x\space c\bar{#1}g \x\space i}
+\CheckDefinition\bar#1{a b\space cd #1 fg \x\space i}
+
+\Inline\def\foo#1{a \Expand\x\space cd #1 fg \x\space i}
+\CheckDefinition\foo#1{a b\space cd #1 fg \x\space i}
+
+\def\a{b}
+\Inline!\def\a#1{a\Expand\a c}
+\CheckDefinition\a#1{abc}
+
+\def\a{b}
+\Inline!**\def\a#1{a\a c}
+\CheckDefinition\a#1{abc}
+
+\Inline\def\a#1{a\a c}
+\CheckDefinition\a#1{a\a c}
+
+\Inline\def\a#1{a\Recurse c}
+\CheckDefinition\a#1{a\a c}
+
+\Inline!\def\a{a\NoExpand{b\Super c}d}
+\CheckDefinition\a{ab\Super cd}
+
+\Inline*\def\a{gh\a jk}
+\CheckDefinition\a{ghab\Super cdjk}
+
+ % SURPRISE! unsafe expansion...
+\def\a{ab\Super cd}
+\Inline**\def\a{gh\a jk}
+\CheckDefinition\a{ghabab\Super cdcdjk}
+
+\def\a{ab\Super cd}
+\Inline\def\a{gh\UnsafeExpand\a jk}
+\CheckDefinition\a{ghabab\Super cdcdjk}
+
+\def\x{\x a} % This is a fun one...!
+\Inline\def\a{\MultiExpand{5}\x}
+\CheckDefinition\a{\x aaaaa}
+
+\message{^^JAll tests completed.^^J}
+
+\begin{document}
+\end{document}
+
+
+\endinput
+%%
+%% End of file `inlinetest.tex'.