[latex3-commits] [git/LaTeX3-latex3-latex2e] gh239: Add test for (emulated) etoolbox (c83421d7)

PhelypeOleinik tex.phelype at gmail.com
Sat May 9 04:43:24 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh239
Link       : https://github.com/latex3/latex2e/commit/c83421d71f960cc94830b4c6516907b6a45a9251

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

commit c83421d71f960cc94830b4c6516907b6a45a9251
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Fri May 8 23:43:24 2020 -0300

    Add test for (emulated) etoolbox


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

c83421d71f960cc94830b4c6516907b6a45a9251
 base/testfiles/github-0239.lvt | 42 ++++++++++++++++++++++++++++++++++--------
 base/testfiles/github-0239.tlg | 18 +++++++++++++-----
 2 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/base/testfiles/github-0239.lvt b/base/testfiles/github-0239.lvt
index 417675d3..668c7d51 100644
--- a/base/testfiles/github-0239.lvt
+++ b/base/testfiles/github-0239.lvt
@@ -8,6 +8,8 @@
 
 \START
 
+\makeatletter
+
 \def\testt#1#2#3#4{%
   #4%
   \DeclareCommandCopy#1#3%
@@ -20,6 +22,28 @@
   \typeout{\string#1=\meaning#1|}%
   \let#1\undefined}
 
+%% etoolbox emulation
+\def\@carsquare#1#2#3\@nil{#1#2}
+\def\ifrobustcmd#1{%
+  \edef\etb at tempa{\noexpand\@testopt
+    \expandafter\noexpand\csname\string#1\endcsname}%
+  \edef\etb at tempb{\unexpanded\expandafter\expandafter\expandafter
+    {\expandafter\@carsquare#1{}{}\@nil}}%
+  \ifx\etb at tempa\etb at tempb
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi}
+\def\letrobustcmd#1#2{%
+  \protected\edef#1{\noexpand\@testopt
+    \expandafter\noexpand\csname\string#1\endcsname}%
+  \expandafter\let
+    \csname\string#1\expandafter\endcsname
+    \csname\string#2\endcsname}
+\g at addto@macro\@declarecommandcopylisthook
+  {\ifrobustcmd\letrobustcmd}
+%%
+
 % Here we need control words
 \def\test{\testt\tmp{tmp}}
 
@@ -29,22 +53,24 @@
 
 \test\cmdc{\DeclareRobustCommand\cmdc[1][]{boo}}
 
-% \test\cmdd{\newrobustcmd\cmdd[1]{boo}}
-
-% \test\cmde{\newrobustcmd\cmde[1][]{boo}}
+\test\cmdd{%
+  \protected\edef\cmdd{\noexpand\@testopt
+    \expandafter\noexpand\csname\string\cmdd\endcsname{}}%
+  \expandafter\def\csname\string\cmdd\endcsname[#1]{boo}}
 
 % And here control symbols
 \def\test{\testt\+{+}}
 
 \test\!{\renewcommand\![1][]{boo}}
 
-\test\@{\DeclareRobustCommand\@[1]{boo}}
-
-\test\#{\DeclareRobustCommand\#[1][]{boo}}
+\test\#{\DeclareRobustCommand\#[1]{boo}}
 
-% \test\${\renewrobustcmd\$[1]{boo}}
+\test\${\DeclareRobustCommand\$[1][]{boo}}
 
-% \test\&{\renewrobustcmd\&[1][]{boo}}
+\test\%{%
+  \protected\edef\%{\noexpand\@testopt
+    \expandafter\noexpand\csname\string\%\endcsname{}}%
+  \expandafter\def\csname\string\%\endcsname[#1]{boo}}
 
 \end{document}
 
diff --git a/base/testfiles/github-0239.tlg b/base/testfiles/github-0239.tlg
index 43bcd13c..4e7e2894 100644
--- a/base/testfiles/github-0239.tlg
+++ b/base/testfiles/github-0239.tlg
@@ -12,18 +12,26 @@ Don't change this file in any respect.
 \tmp =macro:->\@protected at testopt \tmp  \\tmp  {}|
 \\tmp=\relax|
 \\tmp =\long macro:[#1]->boo|
+\tmp=\protected macro:->\@testopt \\tmp |
+\tmp =\relax|
+\\tmp=macro:[#1]->boo|
+\\tmp =\relax|
 \+=macro:->\@protected at testopt \+\\+ {}|
 \+ =\relax|
 \\+=\long macro:[#1]->boo|
 \\+ =\relax|
-LaTeX Info: Redefining \@ on input line ....
-\+=macro:->\protect \+  |
-\+ =\long macro:#1->boo|
-\\+=\relax|
-\\+ =\relax|
 LaTeX Info: Redefining \# on input line ....
 \+=macro:->\x at protect \#\protect \#  |
 \+ =\relax|
 \\+=\relax|
 \\+ =\relax|
+LaTeX Info: Redefining \$ on input line ....
+\+=macro:->\x at protect \$\protect \$  |
+\+ =\relax|
+\\+=\relax|
+\\+ =\relax|
+\+=\protected macro:->\@testopt \\+ |
+\+ =\relax|
+\\+=macro:[#1]->boo|
+\\+ =\relax|
 (github-0239.aux)





More information about the latex3-commits mailing list.