From d990864834549275da5bdfac1d865b99aa38aed6 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Tue, 13 Aug 2024 10:27:34 +1200 Subject: [PATCH] Fix tests --- init.lua | 3 ++- test.lua | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index d833e11..14d5bc2 100644 --- a/init.lua +++ b/init.lua @@ -651,7 +651,8 @@ function field_value_transformers.dropdown(node, _, formspec_version) -- value of the dropdown is anyway, we can just enable index_event for new -- clients and keep the same behaviour if (formspec_version and formspec_version >= 4) or - (minetest.global_exists("fs51") and fs51.monkey_patching_enabled) then + (minetest.global_exists("fs51") and + fs51.monkey_patching_enabled) then node.index_event = true -- Detect reuse of the same Dropdown element (this is unsupported and diff --git a/test.lua b/test.lua index c26f86b..727c90b 100644 --- a/test.lua +++ b/test.lua @@ -81,15 +81,19 @@ string.split = string.split or function(str, chr) end function minetest.explode_textlist_event(event) - local event_type, number = event:match("^([A-Z]+):(%d+)#") + local event_type, number = event:match("^([A-Z]+):(%d+)$") return {type = event_type, index = tonumber(number) or 0} end function minetest.explode_table_event(event) - local event_type, row, column = event:match("^([A-Z]+):(%d+):(%d+)#") + local event_type, row, column = event:match("^([A-Z]+):(%d+):(%d+)$") return {type = event_type, row = tonumber(row) or 0, column = tonumber(column) or 0} end +function minetest.global_exists(var) + return rawget(_G, var) ~= nil +end + -- Load flow local f = assert(io.open("init.lua")) local code = f:read("*a") .. "\nreturn naive_str_width" @@ -819,7 +823,7 @@ describe("Flow", function() }, [[ size[1.6,1.6] style[_#0;hello=world] - button[0.3,0.3;1,1;\10;] + button[0.3,0.3;1,1;_#0;] ]]) end)