diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 15:01:53 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 15:01:53 +0200 |
| commit | 408c23872de49f055d886a2eb2a32214df399d53 (patch) | |
| tree | 611c5648401c0a12cb82d38ba5ce47c9604903ff /tests/invocation_intent_test.lua | |
| parent | 1e8322ae5c36d42820b5109544ef0ef5ad3da443 (diff) | |
Compose entry use case
Diffstat (limited to 'tests/invocation_intent_test.lua')
| -rw-r--r-- | tests/invocation_intent_test.lua | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/invocation_intent_test.lua b/tests/invocation_intent_test.lua index 5eb3e3a..a00711d 100644 --- a/tests/invocation_intent_test.lua +++ b/tests/invocation_intent_test.lua @@ -4,11 +4,25 @@ local file = assert(io.open(entry_path, "rb")) local source = assert(file:read("*a")) file:close() +local capture = [[ +capture_parser(parse_invocation_intent) +]] +local instrumented_source, replacement_count = source:gsub( + "\nreturn {\n\tentry = function", + "\n" .. capture .. "\nreturn {\n\tentry = function", + 1 +) +assert(replacement_count == 1, "parser capture point must occur once") + local prompt_calls = 0 +local parser local environment = { error = error, pairs = pairs, type = type, + capture_parser = function(value) + parser = value + end, ya = { sync = function(callback) return callback @@ -20,11 +34,11 @@ local environment = { }, } -local chunk = assert(load(source, "@" .. entry_path, "t", environment)) -local plugin = chunk() +assert(load(instrumented_source, "@" .. entry_path, "t", environment))() +assert(type(parser) == "function", "invocation parser was not captured") local function parse(args) - return plugin:entry({ args = args }) + return parser(args) end local function assert_equal(actual, expected, label) |