[latex3-commits] [l3svn] r6918 - Add "check-declarations" support to l3flag

noreply at latex-project.org noreply at latex-project.org
Tue Feb 14 00:43:01 CET 2017


Author: bruno
Date: 2017-02-14 00:43:01 +0100 (Tue, 14 Feb 2017)
New Revision: 6918

Added:
   trunk/l3experimental/l3str/testfiles/m3flag001.luatex.tlg
Modified:
   trunk/l3experimental/l3str/l3flag.dtx
   trunk/l3experimental/l3str/testfiles/m3flag001.lvt
   trunk/l3experimental/l3str/testfiles/m3flag001.tlg
Log:
Add "check-declarations" support to l3flag

This is in preparation to moving it to l3kernel (see #336)


Modified: trunk/l3experimental/l3str/l3flag.dtx
===================================================================
--- trunk/l3experimental/l3str/l3flag.dtx	2017-02-13 23:17:06 UTC (rev 6917)
+++ trunk/l3experimental/l3str/l3flag.dtx	2017-02-13 23:43:01 UTC (rev 6918)
@@ -306,7 +306,52 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Option check-declarations}
+%
+% \begin{macro}[EXP,aux]{\@@_chk_exist:n}
+%   In package mode, there is an option to check all variables used are
+%   defined.  Since flags are not implemented in terms of other
+%   variables, we need to add checks by hand.
 %    \begin{macrocode}
+%<*package>
+\tex_ifodd:D \l at expl@check at declarations@bool
+  \cs_set_protected:Npn \flag_zero:n #1
+    {
+      \exp_args:Nc \__chk_if_exist_var:N { flag~#1 }
+      \@@_zero:wn 0 ; {#1}
+    }
+  \cs_set:Npn \@@_chk_exist:n #1
+    {
+      \flag_if_exist:nF {#1}
+        {
+          \__msg_kernel_expandable_error:nnn
+            { kernel } { bad-variable } { flag~#1~ }
+        }
+    }
+  \tl_map_inline:nn
+    {
+      \flag_if_raised_p:n
+      \flag_if_raised:nT
+      \flag_if_raised:nF
+      \flag_if_raised:nTF
+      \flag_use:n
+    }
+    {
+      \use:x
+        {
+          \exp_not:n { \cs_set:Npn #1 ##1 }
+            {
+              \exp_not:n { \@@_chk_exist:n {##1} }
+              \exp_not:o { #1 {##1} }
+            }
+        }
+    }
+\fi:
+%</package>
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
 %

Added: trunk/l3experimental/l3str/testfiles/m3flag001.luatex.tlg
===================================================================
--- trunk/l3experimental/l3str/testfiles/m3flag001.luatex.tlg	                        (rev 0)
+++ trunk/l3experimental/l3str/testfiles/m3flag001.luatex.tlg	2017-02-13 23:43:01 UTC (rev 6918)
@@ -0,0 +1,166 @@
+This is a generated file for the LaTeX (2e + expl3) validation system.
+Don't change this file in any respect.
+Author: Bruno Le Floch
+============================================================
+TEST 1: flag_new
+============================================================
+Defining \flag A on line ...
+\long macro:#1;->\exp_after:wN \use_none:n \cs:w flag A #1\cs_end: 
+\long macro:#1;->\exp_after:wN \use_none:n \cs:w flag A #1\cs_end: 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/command-already-defined"
+! 
+! Control sequence \flag A already defined.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to create a new control sequence '\flag A' but this
+| name has already been used elsewhere.
+| 
+| The current meaning is:
+|   \long macro:#1;->\exp_after:wN \use_none:n \cs:w flag A #1\cs_end: 
+|...............................................
+Defining \flag A on line ...
+Defining \flag B on line ...
+============================================================
+============================================================
+TEST 2: raise, test, height
+============================================================
+F 0 undefined undefined undefined 
+T 1 \relax undefined undefined 
+T 2 \relax \relax undefined 
+F 0 undefined undefined undefined 
+============================================================
+============================================================
+TEST 3: zero
+============================================================
+F 0 undefined undefined undefined 
+T 1 \relax undefined undefined 
+F 0 undefined undefined undefined 
+T 10 \relax \relax \relax 
+F 0 undefined undefined undefined 
+============================================================
+============================================================
+TEST 4: show, log
+============================================================
+> flag C height=1.
+<recently read> }
+l. ...  }
+> flag C height=3.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/variable-not-defined"
+! 
+! Variable \flag other undefined.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to show a variable \flag other, but this has not been
+| defined yet.
+|...............................................
+============================================================
+============================================================
+TEST 5: undefined
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "check/non-declared-variable"
+! 
+! The variable \flag other has not been declared on line ....
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| Checking is active, and you have tried do so something like:
+|   \tl_set:Nn \flag other { ... }
+| without first having:
+|   \tl_new:N \flag other
+| 
+| LaTeX will create the variable and continue.
+|...............................................
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|\flag other 0;|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|0|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+||
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+============================================================


Property changes on: trunk/l3experimental/l3str/testfiles/m3flag001.luatex.tlg
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/l3experimental/l3str/testfiles/m3flag001.lvt
===================================================================
--- trunk/l3experimental/l3str/testfiles/m3flag001.lvt	2017-02-13 23:17:06 UTC (rev 6917)
+++ trunk/l3experimental/l3str/testfiles/m3flag001.lvt	2017-02-13 23:43:01 UTC (rev 6918)
@@ -74,4 +74,17 @@
     \flag_log:n { other }
   }
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\TEST { undefined }
+  {
+    \flag_zero:n { other }
+    \flag_raise:n { other }
+    \TYPE { | \flag_raise:n { other } | }
+    \TYPE { | \flag_use:n { other } | }
+    \TYPE { | \flag_if_raised:nTF { other } {T} {F} | }
+    \TYPE { | \flag_if_raised:nT { other } {T} | }
+    \TYPE { | \flag_if_raised:nF { other } {F} | }
+    \TYPE { | \bool_if:nTF { \flag_if_raised_p:n { other } } {T} {F} | }
+  }
+
 \END

Modified: trunk/l3experimental/l3str/testfiles/m3flag001.tlg
===================================================================
--- trunk/l3experimental/l3str/testfiles/m3flag001.tlg	2017-02-13 23:17:06 UTC (rev 6917)
+++ trunk/l3experimental/l3str/testfiles/m3flag001.tlg	2017-02-13 23:43:01 UTC (rev 6918)
@@ -72,3 +72,95 @@
 | defined yet.
 |...............................................
 ============================================================
+============================================================
+TEST 5: undefined
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "check/non-declared-variable"
+! 
+! The variable \flag other has not been declared on line ....
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| Checking is active, and you have tried do so something like:
+|   \tl_set:Nn \flag other { ... }
+| without first having:
+|   \tl_new:N \flag other
+| 
+| LaTeX will create the variable and continue.
+|...............................................
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|\flag other 0;|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|0|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+||
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Erroneous variable flag other used!
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+|F|
+============================================================



More information about the latex3-commits mailing list