diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-11-05 00:17:35 +0100 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-11-11 15:50:31 +0100 |
commit | c1be5706a3752f24ab779f1116b476b206f298cc (patch) | |
tree | e00795fe6fb73d3c4495340871ed2941bb4f56eb | |
parent | a4c6009c7a7919fa4ed2d7a33fd56c9b4ad5d2c3 (diff) | |
download | luatexbase-c1be5706a3752f24ab779f1116b476b206f298cc.tar.gz |
Enhance test file coverage.
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | luatexbase-mcb.dtx | 53 |
2 files changed, 35 insertions, 19 deletions
@@ -10,6 +10,5 @@ declaration and no declaration? mcb --- -- Enhance test file: call each function at least once - General review of code and comments. - Update user documentation. diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx index 770097c..21786a3 100644 --- a/luatexbase-mcb.dtx +++ b/luatexbase-mcb.dtx @@ -766,13 +766,12 @@ function priority_in_callback (name, description) end % \end{macrocode} % -% Finally we -% overwrite \texttt{callback.register} so that it outputs an error. +% Finally, overwrite \code{callback.register} so that bails out in error. % % \begin{macrocode} callback.register = function () -err("function callback.register has been deleted by luamcallbacks, " -.."please use luatexbase.add_to_callback instead.") + err("function callback.register has been trapped,\n" + .."please use luatexbase.add_to_callback instead.") end % \end{macrocode} % @@ -792,26 +791,44 @@ end %<*testplain,testlatex> \catcode 64 11 \luatexbase@directlua{ - local function one(head,...) - texio.write_nl("I'm number 1") + local function sample(head,...) return head, true end - local function two(head,...) - texio.write_nl("I'm number 2") - return head, true - end + local prio = luatexbase.priority_in_callback + luatexbase.add_to_callback("hpack_filter", sample, "sample function one", 1) + luatexbase.add_to_callback("hpack_filter", sample, "sample function two", 2) + luatexbase.add_to_callback("hpack_filter", sample, "sample function three", 1) + texio.write_nl(prio("hpack_filter", "sample function three")) + luatexbase.remove_from_callback("hpack_filter", "sample function three") + texio.write_nl(prio("hpack_filter", "sample function three")) + luatexbase.reset_callback("hpack_filter") + texio.write_nl(prio("hpack_filter", "sample function one")) - local function three(head,...) - texio.write_nl("I'm number 3") - return head, true + local function data_one(s) + texio.write_nl("I'm data 1 whith argument: "..s) + return s + end + local function data_two(s) + texio.write_nl("I'm data 2 whith argument: "..s) + return s + end + local function data_three(s) + texio.write_nl("I'm data 3 whith argument: "..s) + return s end - luatexbase.add_to_callback("hpack_filter",one,"my sample function one",1) - luatexbase.add_to_callback("hpack_filter",two,"my sample function two",2) - luatexbase.add_to_callback("hpack_filter",three,"my sample function three",1) - - luatexbase.remove_from_callback("hpack_filter","my sample function three") +--[[ + luatexbase.create_callback("fooback", "data", data_one) + luatexbase.call_callback("fooback", "default") + luatexbase.add_to_callback("fooback", data_two, "my sample function two", 2) + luatexbase.add_to_callback("fooback", data_three, "my sample function three", 1) + luatexbase.call_callback("fooback", "all") + luatexbase.remove_from_callback("fooback", "my sample function three") + luatexbase.call_callback("fooback", "all but three") + luatexbase.reset_callback("fooback") + luatexbase.call_callback("fooback", "default") + --]] } %</testplain,testlatex> %<testplain>\bye |