Skip to content

Commit

Permalink
lthooks show test files 2023-06-01 release
Browse files Browse the repository at this point in the history
- tests for arguments
- show test file frozen for the 2023-06-01 release
- show test file for the latest release, will be used to change `\ShowHook` in a forthcoming PR

No date change, no code change
  • Loading branch information
jlaurens committed Jun 5, 2024
1 parent e8d5d41 commit d123529
Show file tree
Hide file tree
Showing 6 changed files with 2,973 additions and 4 deletions.
97 changes: 96 additions & 1 deletion base/testfiles-lthooks/helpers/lthooks-show.sty
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
% This is a library of commands used by various `lthooks*.lvt`

\ExplSyntaxOn
\tl_new:N \l__TESTHookShow_tl

\IncludeInRelease{2023-06-01}{\WithArgs}{With arguments}
\cs_new:Npn \TESTHookWithArgs:Nnn #1 #2 #3
% #1 the local tl variable holding the result
% #2 the template
% #3 the number of arguments
{
\tl_clear:N #1
\int_step_inline:nn { #3 } { \tl_put_right:Nn #1 { #2 } }
}
\def\TESTBlockHookCmdWithArgs#1#2#3{
% run at the top level
% #1: the title of the block
% #2: the csname of the command
\BEGINTEST{Command:~#1}
\DebugShowHookCmd{#2}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { ######1/ } { #3 }
\exp_args:Nnx
\AddToHookWithArguments { cmd/#2/before }
{ \exp_not:N \TYPE { <#2~BEFORE:~/\exp_not:V \l__TESTHookShow_tl> } }
\exp_args:Nnx
\AddToHookWithArguments { cmd/#2/after }
{ \exp_not:N \TYPE { <#2~AFTER :~/\exp_not:V \l__TESTHookShow_tl> } }
\DebugShowHookCmd{#2}
\ENDTEST
}
\def\TESTBlockHookWithArgs#1#2#3{
% run at the top level
% #1: the title of the block
% #2: the name of the hook
% #3: the number of arguments
% Not in the 2020-10-01 release
\BEGINTEST{#1}
\def\TEST{
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { { arg_####1 } } { #3 }
\TYPE{\token_to_str:N \UseHookWithArguments {#2} {#3} \l__TESTHookShow_tl =>}
\exp_last_unbraced:Nno
\use:n { \UseHookWithArguments {#2} {#3} } \l__TESTHookShow_tl
\ShowHook{#2}
}
\BEGINTEST{Undeclared~#2}
\TEST
\ENDTEST
\BEGINTEST{#2~+~TOP-LEVEL}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { arg~######1 / } { #3 }
\exp_args:Nnx
\use:n { \AddToHookWithArguments { #2 } }
{ \exp_not:N \TYPE { <#2~TOP-LEVEL:~/\exp_not:V \l__TESTHookShow_tl> } }
\TEST
\ENDTEST
\BEGINTEST{#2~+~A~LABEL}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { arg~######1 / } { #3 }
\exp_args:Nnx
\use:n { \AddToHookWithArguments { #2 }[A~LABEL] }
{ \exp_not:N \TYPE { <#2~A~CODE:~/\exp_not:V \l__TESTHookShow_tl> } }
\TEST
\ENDTEST
\BEGINTEST{#2~+~B~LABEL}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { arg~######1 / } { #3 }
\exp_args:Nnx
\use:n { \AddToHookWithArguments { #2 }[B~LABEL] }
{ \exp_not:N \TYPE { <#2~B~CODE:~/\exp_not:V \l__TESTHookShow_tl> } }
\TEST
\ENDTEST
\BEGINTEST{#2~+~C~LABEL}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { arg~######1 / } { #3 }
\exp_args:Nnx
\use:n { \AddToHookWithArguments { #2 }[C~LABEL] }
{ \exp_not:N \TYPE { <#2~C~CODE:~/\exp_not:V \l__TESTHookShow_tl> } }
\TEST
\ENDTEST
\BEGINTEST{#2~+~NEXT}
\TESTHookWithArgs:Nnn \l__TESTHookShow_tl { arg~######1 / } { #3 }
\exp_args:Nnx
\use:n { \AddToHookNextWithArguments { #2 } }
{ \exp_not:N \TYPE { <#2~NEXT-ONLY~CODE:~/\exp_not:V \l__TESTHookShow_tl> } }
\ShowHook{#2}
\TEST
\ENDTEST
\BEGINTEST{#2~+~C~LABEL~<~A~LABEL}
\DeclareHookRule{#2}{C~LABEL}{before}{A~LABEL}
\TEST
\ENDTEST
\BEGINTEST{#2~+~DEFAULT:~B~LABEL~>~C~LABEL}
\DeclareDefaultHookRule{B~LABEL}{after}{C~LABEL}
\TEST
\ENDTEST
\ENDTEST
}
\EndIncludeInRelease
\ExplSyntaxOff
%

\IncludeInRelease{2020-10-01}{\TESTBlockHook}{Message}

\def\DebugShowHookEnv#1{
Expand Down Expand Up @@ -74,7 +169,7 @@
\BEGINTEST{Undeclared #2}
\TEST
\ENDTEST
\BEGINTEST{#2 + TOP LEVEL}
\BEGINTEST{#2 + TOP-LEVEL}
\AddToHook{#2}{\TYPE{<#2 TOP-LEVEL>}}
\TEST
\ENDTEST
Expand Down
6 changes: 3 additions & 3 deletions base/testfiles-lthooks/lthooks-show-2020-10-01.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ TEST 10: Undeclared UNDECLARED HOOK
l. ... {UNDECLARED HOOK}
============================================================
============================================================
TEST 11: UNDECLARED HOOK + TOP LEVEL
TEST 11: UNDECLARED HOOK + TOP-LEVEL
============================================================
-> The hook 'UNDECLARED HOOK':
> The hook is not declared.
Expand Down Expand Up @@ -483,7 +483,7 @@ TEST 19: Undeclared DECLARED HOOK
l. ... {DECLARED HOOK}
============================================================
============================================================
TEST 20: DECLARED HOOK + TOP LEVEL
TEST 20: DECLARED HOOK + TOP-LEVEL
============================================================
<DECLARED HOOK TOP-LEVEL>
-> The hook 'DECLARED HOOK':
Expand Down Expand Up @@ -663,7 +663,7 @@ TEST 28: Undeclared DECLARED REVERSED
l. ... {DECLARED REVERSED}
============================================================
============================================================
TEST 29: DECLARED REVERSED + TOP LEVEL
TEST 29: DECLARED REVERSED + TOP-LEVEL
============================================================
<DECLARED REVERSED TOP-LEVEL>
-> The hook 'DECLARED REVERSED':
Expand Down
121 changes: 121 additions & 0 deletions base/testfiles-lthooks/lthooks-show-2023-06-01.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
% Frozen to the 2023-06-01 release.

\input{regression-test}
\RequirePackage[2023-06-01]{latexrelease}
\TYPE{********* RequirePackage[2023-06-01]{latexrelease}}
\RequirePackage{./lthooks-show}

\ExplSyntaxOn
\debug_on:n { check-declarations , deprecation }
\ExplSyntaxOff

\documentclass{article}

% There are many different hook profiles.

\START

\TESTBlockHookEnv
{Undefined environment envA}
{envA}
\NewDocumentEnvironment
{envA}{}
{\TYPE{<BEGIN{envA}>}}
{\TYPE{<END{envA}>}}
\begin{envA}\TYPE{<envA BODY>}\end{envA}

\NewDocumentEnvironment
{envB}{}
{\TYPE{<BEGIN{envB}>}}
{\TYPE{<END{envB}>}}
\TESTBlockHookEnv
{Defined environment envB}
{envB}
\begin{envB}\TYPE{<envB BODY>}\end{envB}

\TESTBlockHookCmd
{Undefined command with no arguments}
{cmdA}
\NewDocumentCommand\cmdA{}{\TYPE{<cmdA BODY>}}
\cmdA

\NewDocumentCommand\cmdB{}{\TYPE{<cmdB BODY>}}
\TESTBlockHookCmd
{Defined command with no arguments}
{cmdB}
\cmdA

\TESTBlockHookCmdWithArgs
{Undefined with two arguments}
{cmdTwoArgsA}
{2}
\NewDocumentCommand\cmdTwoArgsA{mm}{\TYPE{<cmdTwoArgsA BODY: /#1/#2/>}}
\cmdTwoArgsA{argA 1}{argA 2}

\NewDocumentCommand\cmdTwoArgsB{mm}{\TYPE{<cmdTwoArgsB BODY: /#1/#2/>}}
\TESTBlockHookCmdWithArgs
{Defined with two arguments}
{cmdTwoArgsB}
{2}
\cmdTwoArgsB{argB 1}{argB 2}

\TESTBlockHookCustomGeneric
{CUSTOM GENERIC HOOK}
{CUSTOM GENERIC HOOK}

\TESTBlockHook
{OTHER HOOK: Undeclared}
{UNDECLARED HOOK}

\NewHook{DECLARED HOOK}

\TESTBlockHook
{OTHER HOOK: declared}
{DECLARED HOOK}

\NewReversedHook{DECLARED REVERSED}

\TESTBlockHook
{OTHER HOOK: declared reversed}
{DECLARED REVERSED}

\NewHookWithArguments
{WITH TWO ARGUMENTS}
{2}

\TESTBlockHookWithArgs
{OTHER HOOK: with two arguments}
{WITH TWO ARGUMENTS}
{2}

\NewReversedHookWithArguments
{REVERSED WITH TWO ARGUMENTS}
{2}

\TESTBlockHookWithArgs
{OTHER HOOK: reversed with two arguments}
{REVERSED WITH TWO ARGUMENTS}
{2}

\OMIT
\begin{document}
\TIMO

\BEGINTEST{After \begin{document}}

\BEGINTEST{Commands}
\cmdA
\SEPARATOR
\cmdB
\SEPARATOR
\cmdTwoArgsA{argA 1}{argA 2}
\SEPARATOR
\cmdTwoArgsB{argB 1}{argB 2}
\ENDTEST

\ENDTEST


\TYPE{!!!! If this test changes the documentation needs updating !!!!}

\END
Loading

0 comments on commit d123529

Please sign in to comment.