-
Notifications
You must be signed in to change notification settings - Fork 3
/
external.lua
31 lines (27 loc) · 1000 Bytes
/
external.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local luaunit = require('test.lib.luaunit')
local pink = require('pink.pink')
function testExternal()
local story = pink('test/external.ink')
luaunit.assertFalse(story.canContinue)
-- TODO the following error messages are not normally shown
-- because continue() is not called because canContinue is false
luaunit.assertErrorMsgContains('ext', function()
story.continue()
end)
luaunit.assertErrorMsgContains('ext2', function()
story.continue()
end)
local called = false
story.bindExternalFunction('ext', function()
called = true
end)
story.bindExternalFunction('ext2', function() end)
-- update called automatically in bind, is that ok?
luaunit.assertTrue(story.canContinue)
luaunit.assertEquals(story.continue(), 'Hello')
luaunit.assertTrue(called)
-- TODO test parameters and return values
luaunit.assertError(function()
story.bindExternalFunction('undefined', function() end)
end)
end