[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh441: Add test file for 'top-level' changes (3a25fd90)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Dec 14 15:32:27 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh441
Link       : https://github.com/latex3/latex2e/commit/3a25fd90a85ede35115f8a167213889b900f2771

>---------------------------------------------------------------

commit 3a25fd90a85ede35115f8a167213889b900f2771
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Dec 14 11:32:27 2020 -0300

    Add test file for 'top-level' changes


>---------------------------------------------------------------

3a25fd90a85ede35115f8a167213889b900f2771
 base/testfiles-lthooks/lthooks-028.lvt |  89 ++++++++++++++++++++
 base/testfiles-lthooks/lthooks-028.tlg | 147 +++++++++++++++++++++++++++++++++
 2 files changed, 236 insertions(+)

diff --git a/base/testfiles-lthooks/lthooks-028.lvt b/base/testfiles-lthooks/lthooks-028.lvt
new file mode 100644
index 00000000..ce4ebd05
--- /dev/null
+++ b/base/testfiles-lthooks/lthooks-028.lvt
@@ -0,0 +1,89 @@
+\input{regression-test}
+
+\documentclass{article}
+\usepackage{expl3}
+
+\begin{filecontents}{\jobname-pkg.sty}
+\AtBeginDocument{\TIMO\typeout{from \jobname-pkg}\OMIT}
+\AtBeginDocument[top-level]{\TIMO\typeout{'top-level' from \jobname-pkg}\OMIT}
+\end{filecontents}
+
+\START
+
+% Expect an error
+\usepackage{\jobname-pkg}
+
+% Expect an error
+\DeclareDefaultHookLabel{not-top-level}
+\AtBeginDocument[top-level]{\TIMO\typeout{'top-level' with changed label}\OMIT}
+
+% Return default label to top-level
+\DeclareDefaultHookLabel{top-level}
+\AtBeginDocument[top-level]{\TIMO\typeout{'top-level' with default label}\OMIT}
+
+\OMIT
+\begin{document}
+\TIMO
+
+\NewHook{aaa}
+\AddToHook{aaa}[package]{\typeout{package }}
+\AddToHook{aaa}[top-level]{\typeout{top-level }}
+\AddToHook{aaa}[package]{\typeout{also package }}
+\AddToHook{aaa}{\typeout{also top-level }}
+\AddToHook{aaa}[other package]{\typeout{other package }}
+\DeclareHookRule{aaa}{package}{after}{other package}
+\DeclareHookRule{aaa}{package}{after}{top-level} % does nothing
+
+\ShowHook{aaa}
+
+%
+
+\AddToHook{bbb}[package]{\typeout{package }}
+\AddToHook{bbb}[top-level]{\typeout{top-level }}
+\AddToHook{bbb}[package]{\typeout{also package }}
+\AddToHook{bbb}{\typeout{also top-level }}
+\AddToHook{bbb}[other package]{\typeout{other package }}
+\DeclareHookRule{bbb}{package}{after}{other package}
+\DeclareHookRule{bbb}{package}{after}{top-level} % does nothing
+
+\ShowHook{bbb}
+\NewHook{bbb}
+\ShowHook{bbb}
+
+%
+
+\AddToHook{ccc}[package]{\typeout{package }}
+\AddToHook{ccc}[top-level]{\typeout{top-level }}
+\AddToHook{ccc}[package]{\typeout{also package }}
+\AddToHook{ccc}{\typeout{also top-level }}
+\AddToHook{ccc}[other package]{\typeout{other package }}
+\DeclareHookRule{ccc}{package}{after}{other package}
+\DeclareHookRule{ccc}{package}{after}{top-level} % does nothing
+
+\ShowHook{ccc}
+\NewReversedHook{ccc}
+\ShowHook{ccc}
+
+%
+
+% Add then remove
+\AddToHook{ddd}[top-level]{\typeout{top-level }}
+\ShowHook{ddd}
+\RemoveFromHook{ddd}[top-level]
+\ShowHook{ddd}
+
+% Add then remove all
+\AddToHook{ddd}[top-level]{\typeout{top-level }}
+\ShowHook{ddd}
+\RemoveFromHook{ddd}[*]
+\ShowHook{ddd}
+
+% Remove then add (the removal is not queued)
+\RemoveFromHook{ddd}[top-level]
+\ShowHook{ddd}
+\AddToHook{ddd}[top-level]{\typeout{top-level }}
+\ShowHook{ddd}
+
+
+
+\end{document}
diff --git a/base/testfiles-lthooks/lthooks-028.tlg b/base/testfiles-lthooks/lthooks-028.tlg
new file mode 100644
index 00000000..a2d6551a
--- /dev/null
+++ b/base/testfiles-lthooks/lthooks-028.tlg
@@ -0,0 +1,147 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+(lthooks-028-pkg.sty
+! Package hooks Error: Illegal \AddToHook{begindocument}[top-level]{...}.
+(hooks)                'top-level' is reserved to the user's document.
+For immediate help type H <return>.
+ ...                                              
+l. ......ypeout{'top-level' from \jobname-pkg}\OMIT}
+The 'top-level' label is meant for user code only, and should only be used
+(sparingly) in the main document. Use the default label 'lthooks-028-pkg' for
+this package, or another suitable label.
+)
+! Package hooks Error: Illegal \AddToHook{begindocument}[top-level]{...}.
+(hooks)                'top-level' is reserved to the user's document.
+For immediate help type H <return>.
+ ...                                              
+l. ......eout{'top-level' with changed label}\OMIT}
+The 'top-level' label is meant for user code only, and should only be used
+(sparingly) in the main document. Use the default label 'not-top-level' for
+this package, or another suitable label.
+from lthooks-028-pkg
+'top-level' with default label
+-> The hook 'aaa':
+> Code chunks:
+>     package -> \typeout {package }\typeout {also package }
+>     other package -> \typeout {other package }
+> Document-level (top-level) code (executed last):
+>     -> \typeout {top-level }\typeout {also top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     package|other package with relation >
+> Execution order (after applying rules):
+>     other package, package.
+<recently read> }
+l. ...\ShowHook{aaa}
+-> The hook 'bbb':
+> is not declared!
+> Code chunks:
+>     package -> \typeout {package }\typeout {also package }
+>     other package -> \typeout {other package }
+> Document-level (top-level) code:
+>     -> \typeout {top-level }\typeout {also top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     package|other package with relation >
+> Hook not declared.
+<recently read> }
+l. ...\ShowHook{bbb}
+-> The hook 'bbb':
+> Code chunks:
+>     package -> \typeout {package }\typeout {also package }
+>     other package -> \typeout {other package }
+> Document-level (top-level) code (executed last):
+>     -> \typeout {top-level }\typeout {also top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     package|other package with relation >
+> Execution order (after applying rules):
+>     ---.
+<recently read> }
+l. ...\ShowHook{bbb}
+-> The hook 'ccc':
+> is not declared!
+> Code chunks:
+>     package -> \typeout {package }\typeout {also package }
+>     other package -> \typeout {other package }
+> Document-level (top-level) code:
+>     -> \typeout {top-level }\typeout {also top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     package|other package with relation >
+> Hook not declared.
+<recently read> }
+l. ...\ShowHook{ccc}
+-> The hook 'ccc':
+> Code chunks:
+>     package -> \typeout {package }\typeout {also package }
+>     other package -> \typeout {other package }
+> Document-level (top-level) code (executed first):
+>     -> \typeout {top-level }\typeout {also top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     package|other package with relation >
+> Execution order (after reversal and applying rules):
+>     ---.
+<recently read> }
+l. ...\ShowHook{ccc}
+-> The hook 'ddd':
+> is not declared!
+> Code chunks:
+>     ---
+> Document-level (top-level) code:
+>     -> \typeout {top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     ---
+> Hook not declared.
+<recently read> }
+l. ...\ShowHook{ddd}
+-> The hook 'ddd':
+> is not declared!
+> The hook is empty.
+<recently read> }
+l. ...\ShowHook{ddd}
+-> The hook 'ddd':
+> is not declared!
+> Code chunks:
+>     ---
+> Document-level (top-level) code:
+>     -> \typeout {top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     ---
+> Hook not declared.
+<recently read> }
+l. ...\ShowHook{ddd}
+-> The hook 'ddd':
+> is not declared!
+> The hook is empty.
+<recently read> }
+l. ...\ShowHook{ddd}
+-> The hook 'ddd':
+> is not declared!
+> The hook is empty.
+<recently read> }
+l. ...\ShowHook{ddd}
+-> The hook 'ddd':
+> is not declared!
+> Code chunks:
+>     ---
+> Document-level (top-level) code:
+>     -> \typeout {top-level }
+> Extra code for next invocation:
+>     ---
+> Rules:
+>     ---
+> Hook not declared.
+<recently read> }
+l. ...\ShowHook{ddd}
+(lthooks-028.aux)





More information about the latex3-commits mailing list.