[latex3-commits] [git/LaTeX3-latex3-latex2e] callback_rules: Add testfile (e3d2eedf)

Marcel Fabian Krüger tex at 2krueger.de
Sun Sep 4 14:17:55 CEST 2022


Repository : https://github.com/latex3/latex2e
On branch  : callback_rules
Link       : https://github.com/latex3/latex2e/commit/e3d2eedf240eba0a04c4dc14854ae913f79ff628

>---------------------------------------------------------------

commit e3d2eedf240eba0a04c4dc14854ae913f79ff628
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sun Sep 4 14:17:19 2022 +0200

    Add testfile


>---------------------------------------------------------------

e3d2eedf240eba0a04c4dc14854ae913f79ff628
 base/testfiles/tlb-callbacks-002.luatex.tlg        | 14 +++++++
 base/testfiles/tlb-callbacks-002.lvt               | 48 ++++++++++++++++++++++
 ...ithub-0060.luatex.tlg => tlb-callbacks-002.tlg} |  1 +
 3 files changed, 63 insertions(+)

diff --git a/base/testfiles/tlb-callbacks-002.luatex.tlg b/base/testfiles/tlb-callbacks-002.luatex.tlg
new file mode 100644
index 00000000..61d211b6
--- /dev/null
+++ b/base/testfiles/tlb-callbacks-002.luatex.tlg
@@ -0,0 +1,14 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+ LuaTeX Callback ordering test
+Inserting `first' in `testcallback'.
+Inserting `second' in `testcallback'.
+Inserting `third' in `testcallback'.
+Inserting `forth' in `testcallback'.
+Inserting `fifth' in `testcallback'.
+First try: fifth second third forth first
+Second try: fifth third forth second first
+Third try: fifth forth third second first
+Cycle:
+./ltluatex.lua:335: Cycle occured at second -> forth -> third -> second
+Recovered: fifth second forth third first
diff --git a/base/testfiles/tlb-callbacks-002.lvt b/base/testfiles/tlb-callbacks-002.lvt
new file mode 100644
index 00000000..3afe3a47
--- /dev/null
+++ b/base/testfiles/tlb-callbacks-002.lvt
@@ -0,0 +1,48 @@
+\input{test2e}
+\START
+\typeout{^^J LuaTeX Callback ordering test^^J}
+\ifx\directlua\undefined
+\expandafter \END
+\fi
+
+\directlua{
+%
+% current ltluatex user-callbacks
+  luatexbase.create_callback('testcallback', 'data')
+%
+  local call_order
+  local function add_handler(name)
+    luatexbase.add_to_callback('testcallback', function()
+      texio.write('term and log', ' ' .. name)
+    end, name)
+  end
+  local function run(header)
+    texio.write_nl('term and log', header .. ':')
+    luatexbase.call_callback('testcallback')
+  end
+% Add a rule before the handlers
+  luatexbase.declare_callback_rule('testcallback', 'third', 'before', 'first')
+  add_handler'first'
+  add_handler'second'
+  add_handler'third'
+  add_handler'forth'
+  add_handler'fifth'
+  run'First try'
+% And add rules afterwards
+  luatexbase.declare_callback_rule('testcallback', 'third', 'before', 'second')
+  luatexbase.declare_callback_rule('testcallback', 'fifth', 'before', 'forth')
+  luatexbase.declare_callback_rule('testcallback', 'fifth', 'before', 'first')
+  luatexbase.declare_callback_rule('testcallback', 'first', 'after', 'second')
+  run'Second try'
+  luatexbase.declare_callback_rule('testcallback', 'third', 'before', 'forth')
+  luatexbase.declare_callback_rule('testcallback', 'second', 'after', 'third')
+  luatexbase.declare_callback_rule('testcallback', 'third', 'after', 'forth')
+  run'Third try'
+  luatexbase.declare_callback_rule('testcallback', 'second', 'before', 'forth')
+  local _, msg = pcall(run, 'Cycle')
+  texio.write_nl('term and log', msg)
+  luatexbase.declare_callback_rule('testcallback', 'third', 'unrelated', 'second')
+  run'Recovered'
+}
+
+\END
diff --git a/base/testfiles/github-0060.luatex.tlg b/base/testfiles/tlb-callbacks-002.tlg
similarity index 76%
copy from base/testfiles/github-0060.luatex.tlg
copy to base/testfiles/tlb-callbacks-002.tlg
index 1d0c6975..7b020a4c 100644
--- a/base/testfiles/github-0060.luatex.tlg
+++ b/base/testfiles/tlb-callbacks-002.tlg
@@ -1,2 +1,3 @@
 This is a generated file for the LaTeX2e validation system.
 Don't change this file in any respect.
+ LuaTeX Callback ordering test





More information about the latex3-commits mailing list.