summaryrefslogtreecommitdiff
path: root/tests/invocation_intent_test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/invocation_intent_test.lua')
-rw-r--r--tests/invocation_intent_test.lua20
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)