%%; This is `etrip.tex' for e-TeX v3.14159-1.1 as of October 18, 1996.
%%;
%%; This is a diabolical test file for e-TeX, an extension of TeX82.
%%; It is not as diabolical as `trip.tex', Knuth's torture test for TeX.
%%;
%%; ==>> Do not use this TeX code and its macros as an example  <<==
%%; ==>> how you can make use of the new e-TeX features!  It is <<==
%%; ==>> meant to test these extensions and often uses slightly <<==
%%; ==>> wrong e-TeX input to produce errors and warnings.      <<==
%%;
\catcode`\{=1\catcode`\}=2\catcode`\#=6
\def\etripdate   {96/10/18}
\def\texversion  {3.14159}
\def\etripversion{1.1}
%
\message{This is the e-Trip test [\etripdate] for
         e-TeX v\texversion-\etripversion.}
%
% --- Make sure that e-Trip is run in e-TeX extended mode
\def\stop#1{\message{Emergency stop: #1!}}
\expandafter\ifx\csname eTeXversion\endcsname\relax
  \stop{You aren't using e-TeX in extended mode}
  \message{(Do not forget to give an asterisk `*' as the first non-blank}
  \message{character to make e-IniTeX enter extended mode.)}
  \expandafter\end
\fi
%     Check for beta test versions, \eTeXrevision has a leading `-'
\def\1#1-#2\relax{\ifx\relax#2\relax \edef\1{\the\eTeXversion#1}%
  \else {\count0=-1\advance\count0\eTeXversion
         \xdef\1{\number\count0 #2beta}}\fi}
\expandafter\1\eTeXrevision-\relax
\message{(You are using e-TeX version/revision \1)}
\ifx\1\etripversion \else
  \stop{I have expected e-TeX v3.14159...-\etripversion}
  \expandafter\end
\fi
%
% --- a special branch for e-IniTeX
\ifx\einitex\undefined \def\einitex{}
  %
  \message{e-IniTeX: Assigning category codes,}
  \catcode`\$=3\catcode`\&=4
  \catcode`\^=7\catcode`\^^I=10\catcode`\_=8
  \message{tracing switches}
  \tracingstats=4\tracinglostchars=2
  \message{other codes,}
  \endlinechar=`\^^M \newlinechar=`\^^J
  %
  \message{definitions for e-VirTeX e-Trip test run,}
  \def\error{\immediate\write15{Bug in your e-TeX implementation!}%
    \immediate\write15 }
  \def\typeout{\immediate\write15 }
  \def\space{ }
  %
  \message{constants and registers,}
  \chardef\zero=0\chardef\one=1\chardef\two=2
  \countdef\ctmp=255
  %
  \message{fonts,}
  \fontdimen12\nullfont=13pt
  \font\trip=etrip \trip
  \textfont0=\trip \textfont1=\trip
  \font\smalltrip=etrip scaled 500\relax % our symbols font
  \fontdimen22\smalltrip=7pt
  \textfont2=\smalltrip \scriptfont2=\smalltrip
  \scriptscriptfont2=\smalltrip
  \font\bigtrip=etrip at 20pt\relax % our extension font
  \textfont3=\bigtrip \scriptfont3=\bigtrip
  \scriptscriptfont3=\bigtrip
  %
  \message{some math characters,}
  \delcode`\[="161361 % small (family 1, character "61 (a)), large (3,"61)
  \delcode`\|="142342 % small (family 1, character "42 (B)), large (3,"42)
  \delcode`\]="162362 % small (family 1, character "62 (b)), large (3,"62)
  %
  \message{some math parameters,}
  \thinmuskip=18mu plus 3.6mu
  \medmuskip=27mu plus 9mu minus 18mu
  \thickmuskip=36mu minus 7.2mu
  %
  \message{enable e-TeX enhancements (TeXXeT),}
  \TeXXeTstate=1
  \message{everyjob ...dumped.}
  \everyjob={\message{e-IniTeX: e-Trip format loaded.}}
  \expandafter\dump
\fi
%
% -- Do the rest in silent, almost all of it:
\batchmode
%
% -- Check that all e-TeX enhancements are switched off
\ifnum\TeXXeTstate=0 \else
  \error{dumped e-TeX enhancement state registers aren't switch off}
\fi
%
%
% ============================== input/output: new csnames
%
% -- Check table of equivalents and the routines |id_lookup|,
%    |print_cmd_chr| for all new e-TeX control sequences
% -- Check new primitive \unexpanded (first test)
\typeout{Checking input/output of new csnames:}
\def\1{\eTeXversion \eTeXrevision \showgroups \showtokens
  \tracingassigns \tracinggroups \tracingifs \tracingscantokens
  \currentgrouplevel \currentgrouptype \middle \lastnodetype
  \TeXXeTstate \beginL \endL \beginR \endR \predisplaydirection
  \marks \topmarks \firstmarks \botmarks
  \splitfirstmarks \splittopmarks
  \protected \unexpanded \detokenize \scantokens \readline
  \unless \ifdefined \ifcsname \everyeof \middle}
% loop through the list, count the number of csnames,
% insert the \newlinechar after the 2nd, 4th, 6th, ...
\ctmp=0\def\3{}
\def\2#1{\ifx\relax#1\else
  \advance\ctmp\one
  \edef\3{\unexpanded\expandafter{\3 #1}\ifodd\ctmp\else ^^J\fi}%
  \expandafter\2\fi}
\expandafter\2\1\relax
\typeout{e-TeX has \number\ctmp\space new csnames:}%
\show\3
%
%
% ============================== create and output nodes
%
% -- Check |new_...| routines and |short_display|, |show_node_list|
%    for all new e-TeX node types and subtypes
% -- Check for new primitives disabled when read.
\typeout{Checking creation and printing for new node types:}
\tracingonline=1
\showboxbreadth=255\showboxdepth=255
\setbox0=\vbox{\hsize=0pt\TeXXeTstate=1\relax
  %% []\trip a[]b[]p$q [] t$u[][]    % <== \endR\endL at end
  a\beginL b\beginR p$q\left[\mathpunct{r}\middle|s\right]t$u
  %% \trip aMb
  $$aMb$$    % \hbox ..., display
  %% [][]\trip p[]q$st$u[]    % <== \beginL\beginR at beginning
  p\endR q\mathsurround=12.3pt$st$u    % <== \endL at end
  %% \trip rMs
  $$rMs$$    % \hbox ..., display
  %% []\trip tp[]u    % <== \beginL at beginning
  tp\endL u
  %% \trip rMs
  $$rMs$$    % \hbox ..., display
  %% \trip tp    % <== no \mark(s), no \(begin/end)(L/R)!
  tp\mark{0old}\marks0{0}\marks1{1}\marks15{15}\marks255{255}%
  \marks-1{-1}\marks256{256}% Bad number (-1) ...and (256).
  \TeXXeTstate=0\relax
  \beginL\beginR\endL\endR % Improper \(begin/end)(L/R)
}\showbox0
%
%
% ============================== \interactionmode
%
% -- Check new special register \interactionmode
\begingroup \ctmp=\interactionmode % save current value
\nonstopmode
\typeout{Checking \string\interactionmode:}
% test inquiry using \interactionmode
\def\3{\typeout{current interactionmode (l.\number\inputlineno): %
  \ifcase\interactionmode batch\or nonstop\or scroll\or
     errorstop\else UNKNOWN!\fi}}
\def\1#1{\relax\ifnum#1=\interactionmode \3 \else
  \typeout{wrong interactionmode: %
           \interactionmode\space should be \number#1!}\fi}
\batchmode     \1 0
\nonstopmode   \1 1
\scrollmode    \1 2
\errorstopmode \1 3
% test setting |interaction_mode| using this special register
\def\2#1{\interactionmode=#1\relax \1{#1}}
  \nonstopmode
  % generate two errors:
  \interactionmode=-1 \1 1 % nonstop
  \interactionmode=4  \1 1 % nonstop
\2 2 \2 2 \2 1 \2 1 \2 3 \2 3 \2 0 \2 0
\1 0{\interactionmode=3}\1 3 % global assignment!
% Test for the correct call of |new_interaction|, i.e.
% correct setting of |selector|:
\interactionmode=1 \message{1 (l.\number\inputlineno)}% log+term
\interactionmode=0 \message{0 (l.\number\inputlineno)}% log only
\interactionmode=1 \message{1 (l.\number\inputlineno)}% log+term
% Some tests with TeX's old command and register assignments
\batchmode \1 0 \2 3 \scrollmode \1 2 \2 1
\2 \ctmp
\endgroup
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STILL INCOMPLETE!!!
% %%%%% Missing:
% %%%%%   Test for all new primitives
%
% -- Check TeX--XeT's new primitives - incorrect matching & conversion
\typeout{Checking TeX--XeT enhancements:}
% (extra `endL/R' nodes are converted to `kern 0.0' nodes)
\setbox0=\vbox{\TeXXeTstate=1
  \parfillskip=0pt plus1fil\hsize=10pt\parindent=.5pt
  \beginL\kern1pt\par
  \beginR\kern2pt\par
  \beginL\beginR\kern3pt\penalty0\hbox{}\kern3pt\endL\endR\endL\par
  \endL\kern4pt\endR\par}
%%\showbox0
%
\showboxbreadth=10\showboxdepth=10
\tracingonline=1\tracingoutput=1
\end
\error{e-VirTeX: can't happen in e-trip test!}
%% End of file `etrip.tex'.
