[latex3-commits] [latex3/latex2e] cmd-args: More tests (0531889d)
github at latex-project.org
github at latex-project.org
Fri May 19 05:26:28 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : cmd-args
Link : https://github.com/latex3/latex2e/commit/0531889d60720bd3bd662caa4962cd046d7e9340
>---------------------------------------------------------------
commit 0531889d60720bd3bd662caa4962cd046d7e9340
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Fri May 19 00:26:28 2023 -0300
More tests
>---------------------------------------------------------------
0531889d60720bd3bd662caa4962cd046d7e9340
base/testfiles-lthooks/ltcmdhooks-006.lvt | 14 ++++++++++++--
base/testfiles-lthooks/ltcmdhooks-006.tlg | 14 +++++++++++++-
base/testfiles-lthooks/ltcmdhooks-007.lvt | 14 ++++++++++++--
base/testfiles-lthooks/ltcmdhooks-007.tlg | 15 ++++++++++++++-
4 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/base/testfiles-lthooks/ltcmdhooks-006.lvt b/base/testfiles-lthooks/ltcmdhooks-006.lvt
index 4ed02655..33d8a958 100644
--- a/base/testfiles-lthooks/ltcmdhooks-006.lvt
+++ b/base/testfiles-lthooks/ltcmdhooks-006.lvt
@@ -1,3 +1,5 @@
+% This test file and ltcmdhooks-007 only differ in the
+% loading order of the two sample packages
\RequirePackage[enable-debug,check-declarations]{expl3}
\ExplSyntaxOn
\debug_on:n { deprecation }
@@ -11,18 +13,26 @@
% My package adds some code to be executed after the
% \note command from another package.
\AddToHook{cmd/note/after}{\typeout{There is a note above.}}
+%
+% this should error because cmd/note/after takes no arguments:
+\AddToHookWithArguments{cmd/note/after}{\typeout{The note was: #1.}}
+%
+% Also use the cmd/note/before hook to show off:
+\AddToHookWithArguments{cmd/note/before}%
+ {\typeout{The note below is: #1. More #2}}
\end{filecontents}
\begin{filecontents}{notepackage.sty}
% The note package places the hooks manually in the proper places:
\def\note#1{%
\begingroup
- \UseHook{cmd/note/before}
+ \UseHookWithArguments{cmd/note/before}{2}{#1}{stuff}
\typeout{NOTE: #1}%
\UseHook{cmd/note/after}
\endgroup}
% And creates the hooks so that they aren't auto-patched:
-\NewHook{cmd/note/before}
+% Make one with arguments and another without, to make it really confusing
+\NewHookWithArguments{cmd/note/before}{2}
\NewHook{cmd/note/after}
\end{filecontents}
diff --git a/base/testfiles-lthooks/ltcmdhooks-006.tlg b/base/testfiles-lthooks/ltcmdhooks-006.tlg
index ad852a7e..a4e7487e 100644
--- a/base/testfiles-lthooks/ltcmdhooks-006.tlg
+++ b/base/testfiles-lthooks/ltcmdhooks-006.tlg
@@ -2,8 +2,20 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
(notepackage.sty)
NOTE: Hello
-(mypackage.sty)
+(mypackage.sty
+! LaTeX hooks Error: Hook 'cmd/note/after' has no arguments.
+For immediate help type H <return>.
+ ...
+l. ......d/note/after}{\typeout{The note was: #1.}}
+You tried to use \AddToHookWithArguments on a hook that takes no arguments.
+Check the usage of the hook or use \AddToHook instead.
+LaTeX will use \AddToHook.
+)
+The note below is: Hello. More stuff
NOTE: Hello
There is a note above.
+The note was: ##1.
+The note below is: Hello. More stuff
NOTE: Hello
There is a note above.
+The note was: ##1.
diff --git a/base/testfiles-lthooks/ltcmdhooks-007.lvt b/base/testfiles-lthooks/ltcmdhooks-007.lvt
index 8254a18f..ba89ba82 100644
--- a/base/testfiles-lthooks/ltcmdhooks-007.lvt
+++ b/base/testfiles-lthooks/ltcmdhooks-007.lvt
@@ -1,3 +1,5 @@
+% This test file and ltcmdhooks-006 only differ in the
+% loading order of the two sample packages
\RequirePackage[enable-debug,check-declarations]{expl3}
\ExplSyntaxOn
\debug_on:n { deprecation }
@@ -11,18 +13,26 @@
% My package adds some code to be executed after the
% \note command from another package.
\AddToHook{cmd/note/after}{\typeout{There is a note above.}}
+%
+% this should error because cmd/note/after takes no arguments:
+\AddToHookWithArguments{cmd/note/after}{\typeout{The note was: #1.}}
+%
+% Also use the cmd/note/before hook to show off:
+\AddToHookWithArguments{cmd/note/before}%
+ {\typeout{The note below is: #1. More #2}}
\end{filecontents}
\begin{filecontents}{notepackage.sty}
% The note package places the hooks manually in the proper places:
\def\note#1{%
\begingroup
- \UseHook{cmd/note/before}
+ \UseHookWithArguments{cmd/note/before}{2}{#1}{stuff}
\typeout{NOTE: #1}%
\UseHook{cmd/note/after}
\endgroup}
% And creates the hooks so that they aren't auto-patched:
-\NewHook{cmd/note/before}
+% Make one with arguments and another without, to make it really confusing
+\NewHookWithArguments{cmd/note/before}{2}
\NewHook{cmd/note/after}
\end{filecontents}
diff --git a/base/testfiles-lthooks/ltcmdhooks-007.tlg b/base/testfiles-lthooks/ltcmdhooks-007.tlg
index 5f080534..f65f358d 100644
--- a/base/testfiles-lthooks/ltcmdhooks-007.tlg
+++ b/base/testfiles-lthooks/ltcmdhooks-007.tlg
@@ -1,7 +1,20 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
-(mypackage.sty) (notepackage.sty)
+(mypackage.sty) (notepackage.sty
+! Illegal parameter number in definition of hook 'cmd/note/after'.
+(hooks) Offending label: 'mypackage'.
+<to be read again>
+ 1
+l. ...\NewHook{cmd/note/after}
+You meant to type ## instead of #, right?
+Or maybe a } was forgotten somewhere earlier, and things
+are all screwed up? I'm going to assume that you meant ##.
+)
+The note below is: Hello. More stuff
NOTE: Hello
There is a note above.
+The note was: ##1.
+The note below is: Hello. More stuff
NOTE: Hello
There is a note above.
+The note was: ##1.
More information about the latex3-commits
mailing list.