Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lthooks: new show related tests to fix issue #1243 #1248

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions base/lthooks.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -6786,8 +6786,6 @@
%
% \changes{v1.0s}{2021/09/28}
% {Correct usage of older \cs{@@_if_file_hook:wTF} (gh/675)}
% \changes{v1.1h}{2024/01/24}
% {Correct usage of older \cs{@@_if_file_hook:wTF} (gh/1243)}
Comment on lines -6789 to -6790
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deletion looks wired.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's spurious: will vanish when properly rebased

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's spurious: will vanish when properly rebased

% \begin{macrocode}
%<latexrelease>\cs_new_protected:Npn \@@_try_file_hook:n #1
%<latexrelease> {
Expand Down
111 changes: 111 additions & 0 deletions base/testfiles-lthooks/helpers/lthooks-show.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
% This is a library of commands used by various `lthooks*.lvt`

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

\def\DebugShowHookEnv#1{
\ShowHook{env/#1/before}
\ShowHook{env/#1/begin}
\ShowHook{env/#1/end}
\ShowHook{env/#1/after}
}

\def\DebugShowHookCmd#1{
\ShowHook{cmd/#1/before}
\ShowHook{cmd/#1/after}
}

\def\TESTBlockHookEnv#1#2{
% run at the top level
% #1: the title of the block
% #2: the name of the environment
\BEGINTEST{Environment: #2}
\DebugShowHookEnv{#2}
\AddToHook{env/#2/before}{\TYPE{<#2 BEFORE>}}
\AddToHook{env/#2/begin}{\TYPE{<#2 BEGIN>}}
\AddToHook{env/#2/end}{\TYPE{<#2 END>}}
\AddToHook{env/#2/after}{\TYPE{<#2 AFTER>}}
\DebugShowHookEnv{#2}
\ENDTEST
}

\def\TESTBlockHookCmd#1#2{
% run at the top level
% #1: the title of the block
% #2: the csname of the command
\BEGINTEST{Command: #1}
\DebugShowHookCmd{#2}
\AddToHook{cmd/#2/before}{\TYPE{<#2 BEFORE>}}
\AddToHook{cmd/#2/after}{\TYPE{<#2 AFTER>}}
\DebugShowHookCmd{#2}
\ENDTEST
}
\def\TESTBlockHookCustomGeneric#1#2{
% run at the top level
% #1: the title of the block
% #2: the name of the hook
\BEGINTEST{Custom generic hook: #1}
\def\TEST{
\UseHook{#2}
\ShowHook{#2}
}
\BEGINTEST{Raw: #2}
\AddToHook{#2}[LABEL]{\TYPE{<#2 CODE>}}
\TEST
\ENDTEST
\BEGINTEST{Activated: #2}
\ActivateGenericHook{#2}
\TEST
\ENDTEST
\BEGINTEST{Disabled: #2}
\DisableGenericHook{#2}
\TEST
\ENDTEST
\ENDTEST
}
\def\TESTBlockHook#1#2{
% run at the top level
% #1: the title of the block
% #2: the name of the hook
\BEGINTEST{#1}
\def\TEST{
\UseHook{#2}
\ShowHook{#2}
}
\BEGINTEST{Undeclared #2}
\TEST
\ENDTEST
\BEGINTEST{#2 + TOP LEVEL}
\AddToHook{#2}{\TYPE{<#2 TOP-LEVEL>}}
\TEST
\ENDTEST
\BEGINTEST{#2 + A LABEL}
\AddToHook{#2}[A LABEL]{\TYPE{<#2 A CODE>}}
\TEST
\ENDTEST
\BEGINTEST{#2 + B LABEL}
\AddToHook{#2}[B LABEL]{\TYPE{<#2 B CODE>}}
\TEST
\ENDTEST
\BEGINTEST{#2 + C LABEL}
\AddToHook{#2}[C LABEL]{\TYPE{<#2 C CODE>}}
\TEST
\ENDTEST
\BEGINTEST{#2 + NEXT}
\AddToHookNext{#2}{\TYPE{<NEXT-ONLY>}}
\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%{2020-10-01}{\TESTBlockHookOneArg}{Message}

\IncludeInRelease{0000-00-00}{\whatever}{Message}
\EndIncludeInRelease
86 changes: 86 additions & 0 deletions base/testfiles-lthooks/lthooks-show-2020-10-01.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
% This is somehow `lthooks-show.lvt` frozen to the 2020-10-01 release
% before hooks with arguments were introduced.

\input{regression-test}
\RequirePackage[2020-10-01]{latexrelease}
\TYPE{********* RequirePackage[2020-10-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}
\cmdB

\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}

\OMIT
\begin{document}
\TIMO

\BEGINTEST{After \begin{document}}

\BEGINTEST{Commands}
\cmdA
\SEPARATOR
\cmdB
\ENDTEST

\ENDTEST

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

\END
Loading