-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.lua
executable file
·63 lines (53 loc) · 2.25 KB
/
api.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env lua
local luaunit = require('test.lib.luaunit')
local pink = require('pink.pink')
require('test.external')
function testBasic()
local story = pink('test/hello.ink')
luaunit.assertEquals(story.continue(), 'hello world')
luaunit.assertFalse(story.canContinue)
end
function testOutputEachLineSeparately()
local story = pink('test/twolines.ink')
luaunit.assertEquals(story.continue(), 'hello')
luaunit.assertEquals(story.continue(), 'world')
luaunit.assertFalse(story.canContinue)
end
function testInvalidKnot()
local story = pink('test/branching.ink')
luaunit.assertErrorMsgContains('unknown path: nonexistent', function()
story.choosePathString('nonexistent')
end)
end
function testRVisitCount()
local story = pink('test/branching.ink')
story.choosePathString('hurry_outside')
luaunit.assertEquals(story.state.visitCountAtPathString('as_fast_as_we_could'), 0)
while story.canContinue do
story.continue()
end
--luaunit.assertEquals(story.state.visitCountAtPathString('as_fast_as_we_could'), 1)
--story.choosePathString('hurry_outside');
--while story.canContinue do story.continue() end
--luaunit.assertEquals(story.state.visitCountAtPathString('as_fast_as_we_could'), 2)
--luaunit.assertEquals(story.state.visitCountAtPathString('as_fast_as_we_could'), 2)
end
function testRInclude()
--local story = pink('test/include.ink')
--luaunit.assertEquals(story.continue(), 'hello world')
--luaunit.assertEquals(story.continue(), 'hello again')
--luaunit.assertFalse(story.canContinue)
end
function testRTags()
--local story = pink('test/tags.ink')
--luaunit.assertEquals(story.globalTags, {"author: Joseph Humfrey", "title: My Wonderful Ink Story"})
--luaunit.assertEquals(story.continue(), 'This is the line of content. ')
--luaunit.assertEquals(story.currentTags, {"the first tag", "the second tag", "the third tag"})
--story.continue()
--luaunit.assertEquals(story.currentTags, {"not this one"})
--luaunit.assertFalse(story.canContinue)
--luaunit.assertEquals(story.tagsForContentAtPath('Munich'),
--{"location: Germany", "overview: munich.ogg", "require: Train ticket"})
end
-----------------------------
os.exit(luaunit.LuaUnit.run())