Skip to content

Commit

Permalink
Add tests and correct some issues as a result
Browse files Browse the repository at this point in the history
Not sure about the msg from \SetKeysOptions:
formally, it takes the family not the package name.
  • Loading branch information
josephwright committed Jan 12, 2022
1 parent a291002 commit 0313484
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 8 deletions.
15 changes: 7 additions & 8 deletions base/ltkeys.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -390,23 +390,22 @@
{
\clist_map_inline:Nn \l_@@_tmpa_tl
{
\keys_set:nn {#1}
\keys_define:nn {#1}
{
##1 .code:n =
\prop_get:NnNTF \l_@@_options_module_prop {#1} \l_@@_tmpa_tl
{ \exp_args:NV \@@_options_loaded:nn \l_@@_tmpa_tl }
{ \@@_options_loaded:nn {#1} }
{##1}
\@@_options_loaded:nn {#1} {##1}
}
}
}
}
\cs_new_protected:Npn \@@_options_loaded:nn #1#2
{
\bool_if:NTF \l_@@_options_loading_bool
{ \msg_warning:nnn { keys } { load-option-ignored } }
{ \msg_error:nnnn { keys } { load-only } }
{#1} {#2}
{
\msg_warning:nnxx { keys } { load-option-ignored }
{ \use:c { opt@fam@\@currname.\@currext } } {#2}
}
{ \msg_error:nnnn { keys } { load-only } {#1} {#2} }
}
\msg_new:nnn { keys } { load-option-ignored }
{ Package~"#1"~has~already~been~loaded:~ignoring~load-time~option~"#2". }
Expand Down
36 changes: 36 additions & 0 deletions base/testfiles/github-0710.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
\documentclass{article}
\begin{filecontents}{mypkg.sty}
\DeclareKeysOptions{
load-option-A .store = \my@A ,
load-option-A .usage = load ,
load-option-B .store = \my@B ,
load-option-B .usage = load ,
general-option-C .store = \my@C
}
\ProcessKeysOptions
\newcommand\mypkgtest{%
\begingroup
\edef\x{\my@A:\my@B:\my@C}%
\show\x
\endgroup
}
\end{filecontents}
\input{test2e}

\START
\AUTHOR{Joseph Wright}

\usepackage[load-option-A = 111]{mypkg} % 1
\mypkgtest
\usepackage[load-option-A = 222]{mypkg} % 2
\mypkgtest
\usepackage[load-option-A = 333, general-option-C = 333]{mypkg} % 3
\mypkgtest
\usepackage{mypkg} % 4
\mypkgtest
\usepackage[load-option-B = 555]{mypkg} % 5
\mypkgtest
\SetKeysOptions[mypkg]{load-option-A = 666} % 6
\mypkgtest

\END
48 changes: 48 additions & 0 deletions base/testfiles/github-0710.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
Author: Joseph Wright
(mypkg.sty)
> \x=macro:
->111::.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest
LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
(LaTeX3) option "load-option-A".
> \x=macro:
->111::.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest
LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
(LaTeX3) option "load-option-A".
> \x=macro:
->111::333.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest
> \x=macro:
->111::333.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest
LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
(LaTeX3) option "load-option-B".
> \x=macro:
->111::333.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest
! LaTeX3 Error: Key "load-option-A" may only be used in the during loading of
(LaTeX3) package "mypkg".
For immediate help type H <return>.
...
l. ...\SetKeysOptions[mypkg]{load-option-A = 666}
% 6
LaTeX was asked to set a key called "load-option-A", but this is only allowed
in the optional argument when loading package "mypkg".
> \x=macro:
->111::333.
\mypkgtest ...f \x {\my@A :\my@B :\my@C }\show \x
\endgroup
l. ...\mypkgtest

0 comments on commit 0313484

Please sign in to comment.