[latex3-commits] [git/LaTeX3-latex3-latex3] master: add test for object existence, issue #711 (2b2cd0041)
Joseph Wright
joseph.wright at morningstar2.co.uk
Mon May 18 12:53:30 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/2b2cd0041e82ac63a9eaa9a87ba51df90e45af72
>---------------------------------------------------------------
commit 2b2cd0041e82ac63a9eaa9a87ba51df90e45af72
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Fri May 15 12:59:22 2020 +0200
add test for object existence, issue #711
>---------------------------------------------------------------
2b2cd0041e82ac63a9eaa9a87ba51df90e45af72
l3experimental/l3pdf/l3pdf.dtx | 16 +++++++++++++++-
l3experimental/l3pdf/testfiles/m3pdf002.lvt | 12 ++++++++++++
.../l3pdf/testfiles/m3pdf002.tlg | 5 ++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/l3experimental/l3pdf/l3pdf.dtx b/l3experimental/l3pdf/l3pdf.dtx
index 00fe92478..a4e6df42f 100644
--- a/l3experimental/l3pdf/l3pdf.dtx
+++ b/l3experimental/l3pdf/l3pdf.dtx
@@ -71,7 +71,13 @@
% The object may be referenced from this point on, and written later
% using \cs{pdf_object_write:nn}.
% \end{function}
-%
+% \begin{function}[EXP, pTF, added=2020-05-15]{\pdf_object_if_exist:n}
+% \begin{syntax}
+% \cs{pdf_object_new_p:n} \Arg{object}
+% \cs{pdf_object_new_p:nTF} \Arg{object}
+% \end{syntax}
+% Tests whether an object with name \Arg{object} has been defined.
+% \end{function}
% \begin{function}[added = 2019-06-02]
% {\pdf_object_write:nn, \pdf_object_write:nx}
% \begin{syntax}
@@ -231,6 +237,7 @@
% \subsection{Objects}
%
% \begin{macro}{\pdf_object_new:nn, \pdf_object_write:nn, \pdf_object_write:nx}
+% \begin{macro}[pTF]{\pdf_object_if_exist:n}
% \begin{macro}{\pdf_object_ref:n}
% \begin{macro}{\pdf_object_now:nn, \pdf_object_now:nx}
% \begin{macro}{\pdf_object_last:}
@@ -238,6 +245,12 @@
% \begin{macrocode}
\cs_new_protected:Npn \pdf_object_new:nn #1#2
{ \@@_backend_object_new:nn {#1} {#2} }
+\prg_new_conditional:Npnn \pdf_object_if_exist:n #1 { p , T , F , TF }
+ {
+ \int_if_exist:cTF { c__pdf_backend_object_ \tl_to_str:n {#1} _int }
+ { \prg_return_true: }
+ { \prg_return_false:}
+ }
\cs_new_protected:Npn \pdf_object_write:nn #1#2
{ \@@_backend_object_write:nn {#1} {#2} }
\cs_generate_variant:Nn \pdf_object_write:nn { nx }
@@ -251,6 +264,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Version}
%
diff --git a/l3experimental/l3pdf/testfiles/m3pdf002.lvt b/l3experimental/l3pdf/testfiles/m3pdf002.lvt
new file mode 100644
index 000000000..a813704df
--- /dev/null
+++ b/l3experimental/l3pdf/testfiles/m3pdf002.lvt
@@ -0,0 +1,12 @@
+\input{regression-test}
+\documentclass{article}
+\usepackage{l3pdf}
+\begin{document}
+\START
+\ExplSyntaxOn
+\pdf_object_new:nn {exist}{dict}
+\pdf_object_if_exist:nTF{exist}{\iow_term:n{true}}{\iow_term:n{false}}
+\pdf_object_if_exist:nTF{dontexist}{\iow_term:n{true}}{\iow_term:n{false}}
+\ExplSyntaxOff
+abc
+\end{document}
\ No newline at end of file
diff --git a/contrib/testfiles/ctex001.ptex.tlg b/l3experimental/l3pdf/testfiles/m3pdf002.tlg
similarity index 78%
copy from contrib/testfiles/ctex001.ptex.tlg
copy to l3experimental/l3pdf/testfiles/m3pdf002.tlg
index ae22b8ca6..114885c2b 100644
--- a/contrib/testfiles/ctex001.ptex.tlg
+++ b/l3experimental/l3pdf/testfiles/m3pdf002.tlg
@@ -1,3 +1,6 @@
This is a generated file for the LaTeX (2e + expl3) validation system.
Don't change this file in any respect.
-Not-supported-engine!
+true
+false
+[1
+] (m3pdf002.aux)
More information about the latex3-commits
mailing list.