summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex')
-rw-r--r--Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex296
1 files changed, 296 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex b/Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex
new file mode 100644
index 00000000000..8614c4ed06a
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xpackages/xbase/xparse-test.tex
@@ -0,0 +1,296 @@
+% \iffalse
+%% (C) Copyright 2000-2009 LaTeX3 Project
+%%
+%% It may be distributed and/or modified under the conditions of the
+%% LaTeX Project Public License (LPPL), either version 1.3a of this
+%% license or (at your option) any later version. The latest version
+%% of this license is in the file
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This file is part of the ``xbase bundle'' (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%%
+%% The released version of this bundle is available from CTAN.
+%%
+%% -----------------------------------------------------------------------
+%%
+%% The development version of the bundle can be found at
+%%
+%% http://www.latex-project.org/svnroot/experimental/trunk/
+%%
+%% for those people who are interested.
+%%
+%%%%%%%%%%%
+%% NOTE: %%
+%%%%%%%%%%%
+%%
+%% Snapshots taken from the repository represent work in progress and may
+%% not work or may contain conflicting material! We therefore ask
+%% people _not_ to put them into distributions, archives, etc. without
+%% prior consultation with the LaTeX Project Team.
+%%
+%% -----------------------------------------------------------------------
+%%
+%% $Id: xparse-test.tex 1628 2009-10-25 09:54:34Z mittelba $
+%%
+% \fi
+%
+
+\documentclass{minimal}
+
+\usepackage{xparse,l3box}
+
+
+\typeout{Testing the complicated makebox setup}
+\typeout{*****************************}
+\typeout{* look at dvi output for this part}
+\typeout{*****************************}
+
+\ExplSyntaxOn
+\makeatletter
+% Let's just take the error messages for a ride:
+\cs_set_nopar:Npn \makebox{}
+% Here should be an error because it is defined
+\NewDocumentCommand \makebox {m}{Gobbledygook}
+\cs_gundefine:N \makebox
+% And now one for being undefined
+\RenewDocumentCommand \makebox {m}{More~gobbledygook}
+\cs_set_eq:NN \makebox \scan_stop:
+% Another one for being undefined
+\RenewDocumentCommand \makebox {m}{Even~more~gobbledygook}
+% Now it should work
+\DeclareDocumentCommand \makebox
+ { >{\xparse_process_comma_split:n}d() o O{c} m}
+ {\IfNoValueTF{#1}
+ { \ltx@maketextbox{#2}{#3}{#4}\mbox }
+ { \ltx@makepicbox #1 {#2}{#4}\@firstofone }
+ }
+
+\DeclareDocumentCommand \framebox
+ { >{\xparse_process_comma_split:n} d() o O{c} m}
+ {
+ \IfNoValueTF{#1}
+ { \ltx@maketextbox{#2}{#3}{#4}\fbox }
+ { \ltx@makepicbox #1 {#2}{#4}\frame }
+ }
+
+\def\ltx@maketextbox#1#2#3#4{
+ \IfNoValueTF{#1}
+ {#4{#3}}
+ {
+ \leavevmode
+ \@begin@tempboxa\hbox{#3}
+ \setlength\@tempdima{#1}
+ \if_meaning:w #4\fbox
+ \setbox\@tempboxa\hb@xt@\@tempdima{
+ \kern\fboxsep
+ \use:c{bm@#2}
+ \kern\fboxsep
+ }
+ \@frameb@x{\kern-\fboxrule}
+ \else:
+ \hb@xt@\@tempdima{\use:c{bm@#2}}
+ \fi:
+ \@end@tempboxa
+ }
+}
+
+\def\ltx@makepicbox#1#2#3#4#5{
+ #5
+ {
+ \vbox to#2\unitlength {
+ \cs_set_eq:NN \mb@b\vss \cs_set_eq:NN \mb@l\hss
+ \cs_set_eq:NN \mb@r\hss \cs_set_eq:NN \mb@t\vss
+ \IfNoValueF{#3}{
+ \tl_map_variable:nNn {#3}\l_tmpa_tl {
+ \if:w s\l_tmpa_tl
+ \cs_set_eq:NN \mb@l \scan_stop:
+ \cs_set_eq:NN \mb@r \scan_stop:
+ \else:
+ \cs_set_eq:cN {mb@\l_tmpa_tl}\scan_stop:
+ \fi:
+ }
+ }
+ \mb@t
+ \hb@xt@ #1\unitlength{\mb@l #4\mb@r}
+ \mb@b
+ \kern\z@
+ }
+ }
+}
+
+\makeatother
+\ExplSyntaxOff
+
+\begin{document}
+
+
+\thicklines
+
+\makebox{A}
+\makebox(1,2){B}
+\makebox(0,0)[lt]{C}
+\makebox[20pt]{D}
+\makebox[30pt][r]{E}
+
+\vspace{1cm}
+
+
+\framebox{A}
+\framebox(1,2){B}
+\framebox(0,0)[lt]{C}
+\framebox[20pt]{D}
+\framebox[30pt][r]{E}
+
+
+\typeout{Testing optional coordinates}
+
+\DeclareDocumentCommand \foo { mmo }
+{ \typeout{1:#1}
+ \typeout{2:#2}
+}
+
+\show\foo
+
+\ExplSyntaxOn
+\DeclareDocumentCommand \foo
+ { m >{\xparse_process_comma_split:n} D(){0,0} m }
+{ \typeout{1:#1}
+ \typeout{2:#2}
+ \typeout{3:#3}
+}
+\ExplSyntaxOff
+
+\show\foo
+
+\foo A(1,2)B
+
+\foo A B
+
+\typeout{Testing mandatory coordinates (gives error on second examples)}
+
+\ExplSyntaxOn
+\DeclareDocumentCommand \foo { m >{\xparse_process_comma_split:n} d() m }
+{ \IfNoValueTF {#2} {
+ \ERROR
+ }{
+ \typeout{1:#1}
+ \typeout{2:#2}
+ \typeout{3:#3}
+ }
+}
+\ExplSyntaxOff
+
+\show\foo
+
+\foo A(1,2)B
+
+\foo A B
+
+\typeout{Testing normal optional arguments}
+
+
+\DeclareDocumentCommand \foo { mmmm o mm o }
+{ \typeout{1:#1}
+ \typeout{2:#2}
+ \typeout{3:#3}
+ \typeout{4:#4}
+ \typeout{5:#5}
+ \typeout{6:#6}
+ \typeout{7:#7}
+ \typeout{8:#8}
+}
+
+\foo 1234 [5]67[8]
+\foo 1234 [5]67 [8] % 8 should not be picked up here
+\foo 123467
+
+\show\foo
+\expandafter\show\csname\string\foo\endcsname
+
+
+\typeout{Testing optional arguments with default}
+
+\DeclareDocumentCommand \baz { O{?}mmm o mm m }
+{ \typeout{1:#1}
+ \typeout{2:#2}
+ \typeout{3:#3}
+ \typeout{4:#4}
+ \typeout{5:#5}
+ \typeout{6:#6}
+ \typeout{7:#7}
+ \typeout{8:#8}
+}
+
+\show\baz
+\expandafter\show\csname\string\baz\endcsname
+
+\baz [1]234[5]678
+\baz 234678
+
+%\tracingall\tracingassigns=1
+\DeclareDocumentCommand \bar { mmmm mmmm m}
+{ \typeout{1:#1}
+ \typeout{2:#2}
+ \typeout{3:#3}
+ \typeout{4:#4}
+ \typeout{5:#5}
+ \typeout{6:#6}
+ \typeout{7:#7}
+ \typeout{8:#8}
+ \typeout{9:#9}
+}
+
+\show\bar
+\expandafter\show\csname\string\bar\endcsname
+
+\bar 123456789
+
+\DeclareDocumentCommand\chapter{soom}
+{\typeout{a{#1}^^Jb{#2}^^Jc{#3}^^Jd{#4}^^Je}}
+
+\show\chapter
+\expandafter\show\csname\string\chapter\endcsname
+
+\typeout{1:}
+\chapter*[xxx][yyy]{zzz}
+
+\typeout{2:}
+\chapter[xxx][yyy]{zzz}
+
+\typeout{3:}
+\chapter*[xxx]{zzz}
+
+\typeout{4:}
+\typeout{\chapter*[xxx][yyy]{zzz}}
+
+
+
+
+\DeclareDocumentCommand\chapter{soom}
+{\typeout{a{#1}^^Jb{#2}^^Jc{#3}^^Jd{#4}^^Je}}
+
+\DeclareDocumentEnvironment{hello}{ooo}
+ {\typeout{B1(#1)^^JB2(#2)^^JB3(#3)^^J}}
+ {\typeout{E1(#1)^^JE2(#2)^^JE3(#3)^^J}}
+
+
+\show\hello
+\expandafter\show\csname\string\hello\endcsname
+
+\show\endhello
+\expandafter\show\csname end\string\\hello\endcsname
+
+\begin{hello}[abc][aabbcc]
+\typeout{body}
+\typeout{5:}
+\chapter[xxx][yyy]{zzz}
+\end{hello}
+
+\begin{hello}[1]
+\typeout{outer body}
+\hello[2]\typeout{inner body}\endhello
+\end{hello}
+
+\stop