%%
%% This is file `luatex-test4.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% luatex.dtx  (with options: `test4')
%% 
%% This is a generated file.
%% 
%% Project: luatex
%% Version: 2010/03/09 v0.4
%% 
%% Copyright (C) 2007, 2009, 2010 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% The Base Interpreter refers to any `TeX-Format',
%% because some files are installed in TDS:tex/generic//.
%% 
%% This work consists of the main source file luatex.dtx
%% and the derived files
%%    luatex.sty, luatex.pdf, luatex.ins, luatex.drv, luatex-loader.sty,
%%    luatex-test1.tex, luatex-test2.tex, luatex-test3.tex,
%%    luatex-test4.tex, luatex-test5.tex, oberdiek.luatex.lua.
%% 
\NeedsTeXFormat{LaTeX2e}
\count0=0 %
\chardef\TestLaTeX=1000 %
\chardef\TestMax=300 %
\loop
  \count\numexpr\TestLaTeX+\count0\relax=\catcode\count0 %
\ifnum\count0<\TestMax
  \advance\count0 by 1 %
\repeat
\documentclass{minimal}
\usepackage{luatex}[2010/03/09]
\usepackage{qstest}
\IncludeTests{*}
\LogTests{log}{*}{*}
\makeatletter
\def\Check#1{%
  \Expect*{\the\count@=\the\catcode\count@}%
         *{\the\count@=#1}%
}
\newcount\scratch
\def\Test#1#2{%
  \begin{qstest}{CatcodeTable#1}{CatcodeTable#1}%
    \luatexcatcodetable\csname CatcodeTable#1\endcsname
    \count@=\z@
    \loop
      \scratch=#2\relax
      \Expect*{\the\count@=\the\catcode\count@}%
             *{\the\count@=\the\scratch}%
    \ifnum\count@<\TestMax
      \advance\count@\@ne
    \repeat
  \end{qstest}%
}
\begingroup
  % luatex-unicode-letters.tex makes some slots to letters
  \def\TestMax{169}%
  \Test{LaTeX}{\the\count\numexpr\TestLaTeX+\count@}%
\endgroup
\Test{String}{\ifnum\count@=32 10\else 12\fi}
\Test{Other}{12}
\luatexinitcatcodetable99 %
\Test{IniTeX}{%
  0\relax
  \begingroup
    \luatexcatcodetable99 %
    \global\scratch=\the\catcode\count@
  \endgroup
}
\begin{qstest}{CatcodeTableNumStack}{CatcodeTableNumStack}
  \def\TestStack#1{%
    \Expect*{\LuT@NumStack}{#1}%
  }%
  \TestStack{0}%
  \PushCatcodeTableNumStack
  \TestStack{{0}0}%
  \@firstofone{%
    \begingroup
      \luatexinitcatcodetable12 %
      \luatexcatcodetable12 %
      \PushCatcodeTableNumStack
      \TestStack{{12}{0}0}%
      \PopCatcodeTableNumStack
      \TestStack{{0}0}%
      \PopCatcodeTableNumStack
      \TestStack{0}%
      \def\TestWarning{Missing empty stack warning}%
      \def\@PackageWarning#1#2{\def\TestWarning{empty stack}}%
      \PopCatcodeTableNumStack
      \TestStack{0}%
      \Expect*{\TestWarning}{empty stack}%
    \endgroup
  }%
\end{qstest}
\begin{qstest}{CatcodeTableStack}{CatcodeTableStack}
  \def\TestStack#1{%
    \Expect*{\the\CatcodeTableStack}{#1}%
  }%
  \TestStack{0}%
  \IncCatcodeTableStack
  \TestStack{2}%
  \IncCatcodeTableStack
  \TestStack{4}%
  \begingroup
    \IncCatcodeTableStack
    \TestStack{6}%
  \endgroup
  \TestStack{6}%
  \begingroup
    \DecCatcodeTableStack
    \TestStack{4}%
  \endgroup
  \TestStack{4}%
  \DecCatcodeTableStack
  \TestStack{2}%
  \DecCatcodeTableStack
  \TestStack{0}%
  \begingroup
    \def\TestError{Missing error}%
    \def\@PackageError#1#2#3{%
      \def\TestError{Empty stack}%
    }%
    \DecCatcodeTableStack
    \TestStack{0}%
    \Expect*{\TestError}{Empty stack}%
  \endgroup
\end{qstest}
\begin{qstest}{CatcodeRegime}{CatcodeRegime}
  \def\TestStacks#1#2#3{%
    \Expect*{\the\luatexcatcodetable}{#1}%
    \Expect*{\the\CatcodeTableStack}{#2}%
    \Expect*{\LuT@NumStack}{#3}%
  }%
  \TestStacks{0}{0}{0}%
  \catcode`\|=7 %
  \BeginCatcodeRegime\CatcodeTableLaTeX
    \TestStacks{2}{2}{{0}0}%
    \Expect*{\the\catcode`\|}{12}%
  \EndCatcodeRegime
  \TestStacks{0}{0}{0}%
  \Expect*{\the\catcode`\|}{7}%
\end{qstest}
\begin{qstest}{Attributes}{Attributes}
  \newattribute\TestAttr
  \Expect*{\meaning\TestAttr}%
         *{\string\attribute\number\allocationnumber}%
  \Expect*{\the\allocationnumber}{0}%
  \begingroup
    \newattribute\TestAttr
    \Expect*{\the\allocationnumber}{1}%
  \endgroup
  \Expect*{\the\allocationnumber}{0}%
  \Expect*{\meaning\TestAttr}*{\string\attribute1}%
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
  \def\Test#1{%
    \setattribute\TestAttr{#1}%
    \Expect*{\the\TestAttr}{#1}%
  }%
  \Test{0}%
  \Test{1}%
  \Test{-1}%
  \Test{123}%
  \unsetattribute\TestAttr
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
  \begingroup
    \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
    \Test{1234}%
  \endgroup
  \Expect*{\the\TestAttr}*{\number\LuT@UnsetAttributeValue}%
\end{qstest}
\@@end
\endinput
%%
%% End of file `luatex-test4.tex'.
