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 | |
| parent | 1e8322ae5c36d42820b5109544ef0ef5ad3da443 (diff) | |
Compose entry use case
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/invocation_intent_test.lua | 20 | ||||
| -rw-r--r-- | tests/package_shell_test.lua | 8 |
2 files changed, 23 insertions, 5 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) diff --git a/tests/package_shell_test.lua b/tests/package_shell_test.lua index 0f783ef..3982d42 100644 --- a/tests/package_shell_test.lua +++ b/tests/package_shell_test.lua @@ -31,6 +31,7 @@ local sync_callbacks = {} local environment = { cx = { active = { finder = nil, current = {} } }, error = error, + getmetatable = getmetatable, pairs = pairs, type = type, ya = { @@ -40,6 +41,9 @@ local environment = { assert(type(callback) == "function", "ya.sync requires a function") return callback end, + input = function() + return { recv = function() return nil, 2 end } + end, }, } @@ -50,8 +54,8 @@ assert(sync_calls == 1, "expected one top-level synchronous transaction") assert(type(plugin) == "table", "plugin must export a table") assert(type(plugin.entry) == "function", "plugin must export an entry method") -local intent = plugin:entry({ args = { "directory" } }) -assert(intent.mode == "directory", "entry shell must load with the bundled runtime") +local result = plugin:entry({ args = { "directory" } }) +assert(result == 0, "entry shell must load with the bundled runtime") assert(sync_callbacks[1](nil, "directory", "query") == 0, "commit must guard absent finder state") print("package shell checks passed") |