summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--luamcallbacks.dtx89
2 files changed, 36 insertions, 59 deletions
diff --git a/Makefile b/Makefile
index f2e9a8d..2425163 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,8 @@ LOADER_RUN = luatexbase-loader.sty luatexbase.loader.lua
MOD_RUN = luatexbase-modutils.sty luatexbase.modutils.lua
# Files grouped by generation mode
-UNPACKED_MCB = test-luamcallbacks.tex luamcallbacks.lua
+UNPACKED_MCB = luamcallbacks.lua \
+ test-callbacks-latex.tex test-callbacks-plain.tex
UNPACKED_REGS = luatexbase-regs.sty \
test-regs-plain.tex test-regs-latex.tex
UNPACKED_ATTR = luatexbase-attr.sty luatexbase.attr.lua \
@@ -103,7 +104,8 @@ check-modutils: $(UNPACKED_MODUTILS) $(LOADER_RUN)
lualatex --interaction=batchmode test-modutils-latex.tex >/dev/null
check-mcb: $(UNPACKED_MCB) $(LOADER_RUN) $(MOD_RUN)
- luatex --interaction=batchmode test-luamcallbacks.tex >/dev/null
+ luatex --interaction=batchmode test-callbacks-plain.tex >/dev/null
+ lualatex --interaction=batchmode test-callbacks-latex.tex >/dev/null
$(CTAN_ZIP): $(SOURCE) $(COMPILED) $(TDS_ZIP)
@echo "Making $@ for CTAN upload."
diff --git a/luamcallbacks.dtx b/luamcallbacks.dtx
index 5bda6f5..19f875d 100644
--- a/luamcallbacks.dtx
+++ b/luamcallbacks.dtx
@@ -44,7 +44,8 @@ See source file '\inFileName' for details.
\generate{%
\usedir{doc/luatex/luatexbase}%
- \file{test-luamcallbacks.tex}{\from{luamcallbacks.dtx}{test}}%
+ \file{test-callbacks-plain.tex}{\from{luamcallbacks.dtx}{testplain}}%
+ \file{test-callbacks-latex.tex}{\from{luamcallbacks.dtx}{testlatex}}%
}
\def\MetaPrefix{-- }
@@ -773,67 +774,41 @@ end
%</lua>
% \fi
%
-% \iffalse
-%<*test>
-% \fi
-%
-% \section{Test file}
-%
-% The test file is made to run in plainTeX, but is trivial to adapt for
-% LaTeX. First we input the package, and we typeset a small sentence to
-% get a non-empty document.
-%
-% \begin{macrocode}
-\input luatexbase-loader.sty
-\input luatexbase-modutils.sty
-\directlua{require "luamcallbacks"}
-This is just a test file.
-% \end{macrocode}
+% \section{Test files}
%
-% Then we declare three functions that we will use.
+% A few basic tests for Plain and LaTeX.
%
% \begin{macrocode}
+%<testplain>\input luatexbase-modutils.sty
+%<testlatex>\RequirePackage{luatexbase-modutils}
+%<*testplain,testlatex>
\directlua{
-local function one(head,...)
- texio.write_nl("I'm number 1")
- return head, true
-end
-
-local function two(head,...)
- texio.write_nl("I'm number 2")
- return head, true
-end
-
-local function three(head,...)
- texio.write_nl("I'm number 3")
- return head, true
-end
-% \end{macrocode}
-%
-% Then we add the three functions to the hpack\_filter callback
-%
-% \begin{macrocode}
-callback.add("hpack_filter",one,"my example function one",1)
-callback.add("hpack_filter",two,"my example function two",2)
-callback.add("hpack_filter",three,"my example function three",1)
-% \end{macrocode}
-%
-% We remove the function three from the callback.
-%
-% \begin{macrocode}
-callback.remove("hpack_filter","my example function three")
-% \end{macrocode}
-%
-% And we remove a non-declared function to the callback, which will
-% generate an error.
-%
-% \begin{macrocode}
+ require "luamcallbacks"
+ local function one(head,...)
+ texio.write_nl("I'm number 1")
+ return head, true
+ end
+
+ local function two(head,...)
+ texio.write_nl("I'm number 2")
+ return head, true
+ end
+
+ local function three(head,...)
+ texio.write_nl("I'm number 3")
+ return head, true
+ end
+
+ callback.add("hpack_filter",one,"my example function one",1)
+ callback.add("hpack_filter",two,"my example function two",2)
+ callback.add("hpack_filter",three,"my example function three",1)
+
+ callback.remove("hpack_filter","my example function three")
}
-
-\bye
+%</testplain,testlatex>
+%<testplain>\bye
+%<testlatex>\stop
% \end{macrocode}
-% \iffalse
-%</test>
-% \fi
+%
% \Finale
\endinput