diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/simple-example.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/example/simple-example.lua b/example/simple-example.lua index a7ca3d4..1d82944 100644 --- a/example/simple-example.lua +++ b/example/simple-example.lua @@ -153,3 +153,19 @@ local keys = [[ ]] lprint(supple.host.run(keys, "@keys", { foo="bar", baz="meta" })) + +-- Next demonstrate that using supple.host.loadstring works to allow +-- globals set in the parent to be seen/changed + +local function loader(n) + return supple.host.loadstring(([[return { print=print, name = %q }]]):format(n), "@" .. n) +end + +local getname = [[ + local f = ... + local mod = (f("Jeff"))() + return mod.print and "PRINT" or mod.name +]] + +-- Expect to see 'PRINT' +lprint(supple.host.run(getname, "@getname", loader)) |