[latex3-commits] [git/LaTeX3-latex3-latex3] options: First tests for .usage:n (3872dc6ce)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Nov 30 23:43:08 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : options
Link       : https://github.com/latex3/latex3/commit/3872dc6ce50aadc1fa05cdf0491eef80d9e4a15c

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

commit 3872dc6ce50aadc1fa05cdf0491eef80d9e4a15c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Nov 30 22:43:08 2021 +0000

    First tests for .usage:n
    
    Plus some fixes


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

3872dc6ce50aadc1fa05cdf0491eef80d9e4a15c
 l3kernel/l3clist.dtx             | 20 ++++++++++----
 l3kernel/l3keys.dtx              | 14 +++++++---
 l3kernel/testfiles/m3keys007.lvt | 56 ++++++++++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3keys007.tlg | 45 ++++++++++++++++++++++++++++++++
 4 files changed, 126 insertions(+), 9 deletions(-)

diff --git a/l3kernel/l3clist.dtx b/l3kernel/l3clist.dtx
index a82314105..a6753f621 100644
--- a/l3kernel/l3clist.dtx
+++ b/l3kernel/l3clist.dtx
@@ -315,7 +315,9 @@
 % \begin{function}[updated = 2011-09-06]
 %   {
 %     \clist_remove_all:Nn,  \clist_remove_all:cn,
-%     \clist_gremove_all:Nn, \clist_gremove_all:cn
+%     \clist_remove_all:NV,  \clist_remove_all:cV,
+%     \clist_gremove_all:Nn, \clist_gremove_all:cn,
+%     \clist_gremove_all:NV, \clist_gremove_all:cV
 %   }
 %   \begin{syntax}
 %     \cs{clist_remove_all:Nn} \meta{comma list} \Arg{item}
@@ -1407,9 +1409,17 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\clist_remove_all:Nn, \clist_remove_all:cn}
+% \begin{macro}
+%   {
+%     \clist_remove_all:Nn, \clist_remove_all:cn,
+%     \clist_remove_all:NV, \clist_remove_all:cV
+%   }
 % \UnitTested
-% \begin{macro}{\clist_gremove_all:Nn, \clist_gremove_all:cn}
+% \begin{macro}
+%   {
+%     \clist_gremove_all:Nn, \clist_gremove_all:cn,
+%     \clist_gremove_all:NV, \clist_remove_all:cV
+%   }
 % \UnitTested
 % \begin{macro}{\@@_remove_all:NNNn}
 % \begin{macro}{\@@_remove_all:w}
@@ -1482,8 +1492,8 @@
 \cs_new:Npn \@@_remove_all:
   { \exp_after:wN \@@_remove_all:w \@@_tmp:w , }
 \cs_new:Npn \@@_remove_all:w #1 , \s_@@_mark , #2 , { \exp_not:n {#1} }
-\cs_generate_variant:Nn \clist_remove_all:Nn  { c }
-\cs_generate_variant:Nn \clist_gremove_all:Nn { c }
+\cs_generate_variant:Nn \clist_remove_all:Nn  { c , NV , cV }
+\cs_generate_variant:Nn \clist_gremove_all:Nn { c , NV , cV }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index 36b6d13d3..7b10189a8 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -1654,7 +1654,7 @@
 %   Global data for document-level information.
 %    \begin{macrocode}
 \prop_new:N \l_keys_usage_load_prop
-\seq_new:N \l_keys_usage_preamble_prop
+\prop_new:N \l_keys_usage_preamble_prop
 %    \end{macrocode}
 % \end{variable}
 %
@@ -2181,6 +2181,7 @@
 %
 % \begin{macro}{\@@_usage:n}
 % \begin{macro}{\@@_usage:NN}
+% \begin{macro}{\@@_usage:w}
 %   Save the relevant data.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_usage:n #1
@@ -2210,24 +2211,29 @@
           }
       }
       {
-        \msg_error:nnx { keys }
+        \msg_error:nnnn { keys }
           { choice-unknown }
           { .usage:n }
+          {#1}
       }
   }
 \cs_new_protected:Npn \@@_usage:NN #1#2
   {
     \prop_get:NVNF #1 \l_@@_module_str \l_@@_tmpa_tl
       { \tl_clear:N \l_@@_tmpa_tl }
+    \tl_set:Nx \l_@@_tmpb_tl
+      { \exp_after:wN \@@_usage:w \l_keys_path_str \s_@@_stop }
     \bool_if:NTF #2
-      { \clist_put_right:Nn \l_@@_tmpa_tl \l_keys_key_str }
-      { \clist_remove_all:Nn \l_@@_tmpa_tl \l_keys_key_str }
+      { \clist_put_right:NV \l_@@_tmpa_tl \l_@@_tmpb_tl }
+      { \clist_remove_all:NV \l_@@_tmpa_tl \l_@@_tmpb_tl }
     \prop_put:NVV #1 \l_@@_module_str
       \l_@@_tmpa_tl
   }
+\cs_new:Npn \@@_usage:w #1 / #2 \s_@@_stop {#2}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\@@_variable_set:NnnN, \@@_variable_set:cnnN}
 % \begin{macro}{\@@_variable_set_required:NnnN, \@@_variable_set_required:cnnN}
diff --git a/l3kernel/testfiles/m3keys007.lvt b/l3kernel/testfiles/m3keys007.lvt
new file mode 100644
index 000000000..efa32b3e4
--- /dev/null
+++ b/l3kernel/testfiles/m3keys007.lvt
@@ -0,0 +1,56 @@
+% Copyright (C) 2021 The LaTeX Project
+
+
+\documentclass{minimal}
+\input{regression-test}
+
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation , log-functions }
+\ExplSyntaxOff
+
+
+\begin{document}
+\START
+\AUTHOR{Joseph Wright}
+\ExplSyntaxOn
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\TEST { .usage:n ~ basics }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .code:n  = #1 ,
+        key-one .usage:n = load ,
+        key-two .code:n  = #1 ,
+        key-two .usage:n = preamble ,
+        key-three .code:n  = #1 ,
+        key-three .usage:n = general ,
+        key-four .code:n  = #1 ,
+        key-four .usage:n = oops
+      }
+    \prop_show:N \l_keys_usage_load_prop
+    \prop_show:N \l_keys_usage_preamble_prop
+  }
+
+\TEST { .usage:n ~ adding ~ and ~ removing }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .code:n  = #1 ,
+        key-one .usage:n = load ,
+        key-two .code:n  = #1 ,
+        key-two .usage:n = load ,
+        key-three .code:n  = #1 ,
+        key-three .usage:n = load ,
+        key-three .usage:n = preamble ,
+        key-four .code:n  = #1 ,
+        key-four .usage:n = load ,
+        key-four .usage:n = general
+      }
+    \prop_show:N \l_keys_usage_load_prop
+    \prop_show:N \l_keys_usage_preamble_prop
+  }
+
+\END
diff --git a/l3kernel/testfiles/m3keys007.tlg b/l3kernel/testfiles/m3keys007.tlg
new file mode 100644
index 000000000..a0f91975f
--- /dev/null
+++ b/l3kernel/testfiles/m3keys007.tlg
@@ -0,0 +1,45 @@
+This is a generated file for the LaTeX (2e + expl3) validation system.
+Don't change this file in any respect.
+Author: Joseph Wright
+============================================================
+TEST 1: .usage:n basics
+============================================================
+Defining key module/key-one on line ...
+Defining key module/key-two on line ...
+Defining key module/key-three on line ...
+Defining key module/key-four on line ...
+! LaTeX3 Error: Key '.usage:n' accepts only a fixed set of choices.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+The key '.usage:n' only accepts predefined values, and 'oops' is not one of
+these.
+The property list \l_keys_usage_load_prop contains the pairs (without outer
+braces):
+>  {module}  =>  {key-one}.
+<recently read> }
+l. ...  }
+The property list \l_keys_usage_preamble_prop contains the pairs (without
+outer braces):
+>  {module}  =>  {key-two}.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 2: .usage:n adding and removing
+============================================================
+Defining key module/key-one on line ...
+Defining key module/key-two on line ...
+Defining key module/key-three on line ...
+Defining key module/key-four on line ...
+The property list \l_keys_usage_load_prop contains the pairs (without outer
+braces):
+>  {module}  =>  {key-one,key-two}.
+<recently read> }
+l. ...  }
+The property list \l_keys_usage_preamble_prop contains the pairs (without
+outer braces):
+>  {module}  =>  {key-three}.
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.