模块:Deep2 ExecPF2

来自希服维基

可在模块:Deep2 ExecPF2/doc创建此模块的帮助文档

local p = {}
function p.test()
    -- Try different calling conventions: single arg as function, or name+args
    local results = {}

    -- Test 1: Call with name only (should return the function)
    local ok1, func1 = pcall(mw.executeFunction, "expr")
    results[1] = "expr_nameOnly=" .. tostring(ok1) .. ":" .. type(func1)

    -- Test 2: Call with function returned from another call
    local ok2, func2 = pcall(mw.executeFunction, "if")
    if ok2 and type(func2) == "function" then
        local ok3, result3 = pcall(func2, "1+1")
        results[2] = "if_call_result=" .. tostring(ok3) .. ":" .. tostring(result3)
    end

    -- Test 3: Try to pass the function name differently
    local nameTable = {name = "expr"}
    local ok4, result4 = pcall(mw.executeFunction, nameTable)
    results[3] = "table_arg=" .. tostring(ok4) .. ":" .. type(result4)

    return table.concat(results, " | ")
end
return p